Skip to content

Commit 42f1391

Browse files
author
Sebastian Krätzig
committed
Refactor/Improve php-cs-fixer rules and apply necessary changes to code
1 parent f1e316b commit 42f1391

14 files changed

+140
-134
lines changed

.php-cs-fixer.dist.php

+26-21
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,35 @@
77
return (new PhpCsFixer\Config())
88
->setRiskyAllowed(true)
99
->setRules([
10-
'@Symfony' => true,
11-
'@Symfony:risky' => true,
12-
'@PHP71Migration' => true, // @PHP72Migration does not exist
13-
'@PHP71Migration:risky' => true, // @PHP72Migration:risky does not exist
10+
'@PSR12' => true,
1411
'array_syntax' => ['syntax' => 'short'],
15-
'declare_strict_types' => true,
16-
'global_namespace_import' => [
17-
'import_classes' => true,
18-
'import_constants' => true,
19-
'import_functions' => false,
20-
],
21-
'native_constant_invocation' => true,
22-
'native_function_invocation' => [
23-
'strict' => false,
24-
'include' => ['@compiler_optimized'],
25-
],
12+
'single_quote' => true,
13+
'include' => true,
2614
'no_superfluous_phpdoc_tags' => true,
27-
'ordered_class_elements' => true,
15+
'no_extra_blank_lines' => true,
16+
'no_empty_comment' => true,
17+
'no_empty_phpdoc' => true,
2818
'ordered_imports' => true,
29-
'php_unit_dedicate_assert' => ['target' => 'newest'],
30-
'php_unit_method_casing' => true,
31-
'php_unit_test_case_static_method_calls' => ['call_type' => 'this'],
32-
'phpdoc_to_comment' => false,
33-
'void_return' => true,
19+
'phpdoc_align' => true,
20+
'phpdoc_annotation_without_dot' => true,
21+
'phpdoc_indent' => true,
22+
'phpdoc_inline_tag_normalizer' => true,
23+
'phpdoc_no_access' => true,
24+
'phpdoc_no_alias_tag' => true,
25+
'phpdoc_no_package' => true,
26+
'phpdoc_no_useless_inheritdoc' => true,
27+
'phpdoc_return_self_reference' => true,
28+
'phpdoc_scalar' => true,
29+
'phpdoc_separation' => true,
30+
'phpdoc_single_line_var_spacing' => true,
31+
'phpdoc_summary' => true,
32+
'phpdoc_tag_type' => true,
33+
'phpdoc_to_comment' => true,
34+
'phpdoc_trim' => true,
35+
'phpdoc_trim_consecutive_blank_line_separation' => true,
36+
'phpdoc_types' => true,
37+
'phpdoc_types_order' => true,
38+
'phpdoc_var_without_name' => true
3439
])
3540
->setFinder(PhpCsFixer\Finder::create()
3641
->exclude('vendor')

src/PhpImap/DataPartInfo.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class DataPartInfo
3434
*/
3535
public $encoding;
3636

37-
/** @var string|null */
37+
/** @var null|string */
3838
public $charset;
3939

4040
/**
@@ -58,7 +58,7 @@ class DataPartInfo
5858
*/
5959
public $options;
6060

61-
/** @var string|null */
61+
/** @var null|string */
6262
protected $data;
6363

6464
/**

src/PhpImap/Imap.php

+16-16
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ final class Imap
6969
];
7070

7171
/**
72-
* @param resource|false $imap_stream
72+
* @param false|resource $imap_stream
7373
*
7474
* @return true
7575
*
@@ -143,7 +143,7 @@ public static function check($imap_stream): object
143143
throw new UnexpectedValueException('Could not check imap mailbox!', 0, self::HandleErrors(\imap_errors(), 'imap_check'));
144144
}
145145

146-
/** @var object */
146+
/* @var object */
147147
return $result;
148148
}
149149

@@ -233,7 +233,7 @@ public static function createmailbox($imap_stream, string $mailbox): bool
233233

234234
/**
235235
* @param false|resource $imap_stream
236-
* @param string|int $msg_number
236+
* @param int|string $msg_number
237237
*
238238
* @return true
239239
*/
@@ -339,13 +339,13 @@ public static function fetch_overview(
339339
throw new UnexpectedValueException('Could not fetch overview for message from mailbox!', 0, self::HandleErrors(\imap_errors(), 'imap_fetch_overview'));
340340
}
341341

342-
/** @psalm-var list<object> */
342+
/* @psalm-var list<object> */
343343
return $result;
344344
}
345345

346346
/**
347347
* @param false|resource $imap_stream
348-
* @param string|int $section
348+
* @param int|string $section
349349
*/
350350
public static function fetchbody(
351351
$imap_stream,
@@ -418,7 +418,7 @@ public static function fetchstructure(
418418
throw new UnexpectedValueException('Could not fetch message structure from mailbox!', 0, self::HandleErrors(\imap_errors(), 'imap_fetchstructure'));
419419
}
420420

421-
/** @psalm-var PARTSTRUCTURE */
421+
/* @psalm-var PARTSTRUCTURE */
422422
return $result;
423423
}
424424

@@ -446,7 +446,7 @@ public static function get_quotaroot(
446446
}
447447

448448
/**
449-
* @param resource|false $imap_stream
449+
* @param false|resource $imap_stream
450450
*
451451
* @return object[]
452452
*
@@ -479,12 +479,12 @@ public static function getmailboxes(
479479
throw new UnexpectedValueException('Call to imap_getmailboxes() with supplied arguments returned false, not array!', 0, self::HandleErrors(\imap_errors(), 'imap_getmailboxes'));
480480
}
481481

482-
/** @psalm-var list<object> */
482+
/* @psalm-var list<object> */
483483
return $result;
484484
}
485485

486486
/**
487-
* @param resource|false $imap_stream
487+
* @param false|resource $imap_stream
488488
*
489489
* @return object[]
490490
*
@@ -507,7 +507,7 @@ public static function getsubscribed(
507507
throw new UnexpectedValueException('Call to imap_getsubscribed() with supplied arguments returned false, not array!', 0, self::HandleErrors(\imap_errors(), 'imap_getsubscribed'));
508508
}
509509

510-
/** @psalm-var list<object> */
510+
/* @psalm-var list<object> */
511511
return $result;
512512
}
513513

@@ -716,7 +716,7 @@ public static function open(
716716
}
717717

718718
/**
719-
* @param resource|false $imap_stream
719+
* @param false|resource $imap_stream
720720
*
721721
* @psalm-pure
722722
*/
@@ -779,7 +779,7 @@ public static function reopen(
779779

780780
/**
781781
* @param false|resource $imap_stream
782-
* @param string|false|resource $file
782+
* @param false|resource|string $file
783783
*
784784
* @return true
785785
*/
@@ -852,7 +852,7 @@ public static function search(
852852
throw new UnexpectedValueException('Could not search mailbox!', 0, self::HandleErrors($errors, 'imap_search'));
853853
}
854854

855-
/** @psalm-var list<int> */
855+
/* @psalm-var list<int> */
856856
return $result;
857857
}
858858

@@ -954,7 +954,7 @@ public static function sort(
954954
throw new UnexpectedValueException('Could not sort messages!', 0, self::HandleErrors(\imap_errors(), 'imap_sort'));
955955
}
956956

957-
/** @psalm-var list<int> */
957+
/* @psalm-var list<int> */
958958
return $result;
959959
}
960960

@@ -1001,7 +1001,7 @@ public static function subscribe($imap_stream, string $mailbox): void
10011001
/**
10021002
* @psalm-param value-of<self::TIMEOUT_TYPES> $timeout_type
10031003
*
1004-
* @return true|int
1004+
* @return int|true
10051005
*/
10061006
public static function timeout(
10071007
int $timeout_type,
@@ -1095,7 +1095,7 @@ private static function EnsureResource($maybe, string $method, int $argument)
10951095
throw new InvalidArgumentException('Argument '.(string) $argument.' passed to '.$method.' must be a valid resource!');
10961096
}
10971097

1098-
/** @var resource */
1098+
/* @var resource */
10991099
return $maybe;
11001100
}
11011101

src/PhpImap/IncomingMail.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ class IncomingMail extends IncomingMailHeader
3434
*/
3535
protected $dataInfo = [[], []];
3636

37-
/** @var string|null */
37+
/** @var null|string */
3838
private $textPlain;
3939

40-
/** @var string|null */
40+
/** @var null|string */
4141
private $textHtml;
4242

4343
/**
@@ -70,7 +70,7 @@ public function __get(string $name): string
7070
$this->$name .= \trim($data->fetch());
7171
}
7272

73-
/** @var string */
73+
/* @var string */
7474
return $this->$name;
7575
}
7676

@@ -99,7 +99,7 @@ public function setHeader(IncomingMailHeader $header): void
9999
}
100100

101101
/**
102-
* @param DataPartInfo::TEXT_PLAIN|DataPartInfo::TEXT_HTML $type
102+
* @param DataPartInfo::TEXT_HTML|DataPartInfo::TEXT_PLAIN $type
103103
*/
104104
public function addDataPartInfo(DataPartInfo $dataInfo, int $type): void
105105
{
@@ -197,7 +197,7 @@ public function replaceInternalLinks(string $baseUri): string
197197
}
198198
}
199199

200-
/** @psalm-var string */
200+
/* @psalm-var string */
201201
return \str_replace($search, $replace, $fetchedHtml);
202202
}
203203

@@ -219,7 +219,7 @@ public function embedImageAttachments(): void
219219
$cid = \str_replace('cid:', '', $match);
220220

221221
foreach ($attachments as $attachment) {
222-
/**
222+
/*
223223
* Inline images can contain a "Content-Disposition: inline", but only a "Content-ID" is also enough.
224224
* See https://github.com/barbushin/php-imap/issues/569.
225225
*/

src/PhpImap/IncomingMailAttachment.php

+21-21
Original file line numberDiff line numberDiff line change
@@ -13,70 +13,70 @@
1313
*
1414
* @author Barbushin Sergey http://linkedin.com/in/barbushin
1515
*
16-
* @property string|false|null $filePath lazy attachment data file
16+
* @property null|false|string $filePath lazy attachment data file
1717
*
1818
* @psalm-type fileinfoconst = 0|2|16|1024|1040|8|32|128|256|16777216
1919
*/
2020
class IncomingMailAttachment
2121
{
22-
/** @var string|null */
22+
/** @var null|string */
2323
public $id;
2424

25-
/** @var string|null */
25+
/** @var null|string */
2626
public $contentId;
2727

28-
/** @var int|null */
28+
/** @var null|int */
2929
public $type;
3030

31-
/** @var int|null */
31+
/** @var null|int */
3232
public $encoding;
3333

34-
/** @var string|null */
34+
/** @var null|string */
3535
public $subtype;
3636

37-
/** @var string|null */
37+
/** @var null|string */
3838
public $description;
3939

40-
/** @var string|null */
40+
/** @var null|string */
4141
public $name;
4242

43-
/** @var int|null */
43+
/** @var null|int */
4444
public $sizeInBytes;
4545

46-
/** @var string|null */
46+
/** @var null|string */
4747
public $disposition;
4848

49-
/** @var string|null */
49+
/** @var null|string */
5050
public $charset;
5151

52-
/** @var bool|null */
52+
/** @var null|bool */
5353
public $emlOrigin;
5454

55-
/** @var string|null */
55+
/** @var null|string */
5656
public $fileInfoRaw;
5757

58-
/** @var string|null */
58+
/** @var null|string */
5959
public $fileInfo;
6060

61-
/** @var string|null */
61+
/** @var null|string */
6262
public $mime;
6363

64-
/** @var string|null */
64+
/** @var null|string */
6565
public $mimeEncoding;
6666

67-
/** @var string|null */
67+
/** @var null|string */
6868
public $fileExtension;
6969

70-
/** @var string|null */
70+
/** @var null|string */
7171
public $mimeType;
7272

73-
/** @var string|null */
73+
/** @var null|string */
7474
private $file_path;
7575

76-
/** @var DataPartInfo|null */
76+
/** @var null|DataPartInfo */
7777
private $dataInfo;
7878

79-
/** @var string|null */
79+
/** @var null|string */
8080
private $filePath;
8181

8282
/**

0 commit comments

Comments
 (0)