Skip to content

Commit 4433c90

Browse files
authored
Merge pull request #8341 from kenjis/add-SimplifyEmptyCheckOnEmptyArrayRector
refactor: apply SimplifyEmptyCheckOnEmptyArrayRector
2 parents 2198dfd + 392beac commit 4433c90

40 files changed

+108
-156
lines changed

phpstan-baseline.php

Lines changed: 28 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
];
1919
$ignoreErrors[] = [
2020
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
21-
'count' => 13,
21+
'count' => 10,
2222
'path' => __DIR__ . '/system/Autoloader/FileLocator.php',
2323
];
2424
$ignoreErrors[] = [
@@ -33,7 +33,7 @@
3333
];
3434
$ignoreErrors[] = [
3535
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
36-
'count' => 16,
36+
'count' => 10,
3737
'path' => __DIR__ . '/system/BaseModel.php',
3838
];
3939
$ignoreErrors[] = [
@@ -63,7 +63,7 @@
6363
];
6464
$ignoreErrors[] = [
6565
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
66-
'count' => 5,
66+
'count' => 2,
6767
'path' => __DIR__ . '/system/CLI/BaseCommand.php',
6868
];
6969
$ignoreErrors[] = [
@@ -83,7 +83,7 @@
8383
];
8484
$ignoreErrors[] = [
8585
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
86-
'count' => 6,
86+
'count' => 1,
8787
'path' => __DIR__ . '/system/CLI/CLI.php',
8888
];
8989
$ignoreErrors[] = [
@@ -856,11 +856,6 @@
856856
'count' => 4,
857857
'path' => __DIR__ . '/system/Config/Services.php',
858858
];
859-
$ignoreErrors[] = [
860-
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
861-
'count' => 1,
862-
'path' => __DIR__ . '/system/Controller.php',
863-
];
864859
$ignoreErrors[] = [
865860
'message' => '#^Only booleans are allowed in a negated boolean, array given\\.$#',
866861
'count' => 1,
@@ -1033,7 +1028,7 @@
10331028
];
10341029
$ignoreErrors[] = [
10351030
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
1036-
'count' => 10,
1031+
'count' => 2,
10371032
'path' => __DIR__ . '/system/Database/BaseResult.php',
10381033
];
10391034
$ignoreErrors[] = [
@@ -1148,7 +1143,7 @@
11481143
];
11491144
$ignoreErrors[] = [
11501145
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
1151-
'count' => 8,
1146+
'count' => 6,
11521147
'path' => __DIR__ . '/system/Database/MigrationRunner.php',
11531148
];
11541149
$ignoreErrors[] = [
@@ -1206,11 +1201,6 @@
12061201
'count' => 1,
12071202
'path' => __DIR__ . '/system/Database/ModelFactory.php',
12081203
];
1209-
$ignoreErrors[] = [
1210-
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
1211-
'count' => 1,
1212-
'path' => __DIR__ . '/system/Database/MySQLi/Builder.php',
1213-
];
12141204
$ignoreErrors[] = [
12151205
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
12161206
'count' => 12,
@@ -1543,7 +1533,7 @@
15431533
];
15441534
$ignoreErrors[] = [
15451535
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
1546-
'count' => 15,
1536+
'count' => 10,
15471537
'path' => __DIR__ . '/system/Database/SQLSRV/Builder.php',
15481538
];
15491539
$ignoreErrors[] = [
@@ -1593,7 +1583,7 @@
15931583
];
15941584
$ignoreErrors[] = [
15951585
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
1596-
'count' => 6,
1586+
'count' => 5,
15971587
'path' => __DIR__ . '/system/Database/SQLSRV/Forge.php',
15981588
];
15991589
$ignoreErrors[] = [
@@ -1713,7 +1703,7 @@
17131703
];
17141704
$ignoreErrors[] = [
17151705
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
1716-
'count' => 3,
1706+
'count' => 2,
17171707
'path' => __DIR__ . '/system/Database/SQLite3/Table.php',
17181708
];
17191709
$ignoreErrors[] = [
@@ -1761,36 +1751,21 @@
17611751
'count' => 3,
17621752
'path' => __DIR__ . '/system/Debug/Exceptions.php',
17631753
];
1764-
$ignoreErrors[] = [
1765-
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
1766-
'count' => 1,
1767-
'path' => __DIR__ . '/system/Debug/Iterator.php',
1768-
];
17691754
$ignoreErrors[] = [
17701755
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
17711756
'count' => 5,
17721757
'path' => __DIR__ . '/system/Debug/Timer.php',
17731758
];
17741759
$ignoreErrors[] = [
17751760
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
1776-
'count' => 5,
1761+
'count' => 2,
17771762
'path' => __DIR__ . '/system/Debug/Toolbar.php',
17781763
];
1779-
$ignoreErrors[] = [
1780-
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
1781-
'count' => 1,
1782-
'path' => __DIR__ . '/system/Debug/Toolbar/Collectors/Database.php',
1783-
];
17841764
$ignoreErrors[] = [
17851765
'message' => '#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#',
17861766
'count' => 1,
17871767
'path' => __DIR__ . '/system/Debug/Toolbar/Collectors/Database.php',
17881768
];
1789-
$ignoreErrors[] = [
1790-
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
1791-
'count' => 1,
1792-
'path' => __DIR__ . '/system/Debug/Toolbar/Collectors/History.php',
1793-
];
17941769
$ignoreErrors[] = [
17951770
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
17961771
'count' => 2,
@@ -1888,7 +1863,7 @@
18881863
];
18891864
$ignoreErrors[] = [
18901865
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
1891-
'count' => 4,
1866+
'count' => 3,
18921867
'path' => __DIR__ . '/system/Entity/Entity.php',
18931868
];
18941869
$ignoreErrors[] = [
@@ -1958,7 +1933,7 @@
19581933
];
19591934
$ignoreErrors[] = [
19601935
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
1961-
'count' => 2,
1936+
'count' => 1,
19621937
'path' => __DIR__ . '/system/HTTP/CLIRequest.php',
19631938
];
19641939
$ignoreErrors[] = [
@@ -1978,7 +1953,7 @@
19781953
];
19791954
$ignoreErrors[] = [
19801955
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
1981-
'count' => 9,
1956+
'count' => 7,
19821957
'path' => __DIR__ . '/system/HTTP/ContentSecurityPolicy.php',
19831958
];
19841959
$ignoreErrors[] = [
@@ -2031,11 +2006,6 @@
20312006
'count' => 1,
20322007
'path' => __DIR__ . '/system/HTTP/Files/FileCollection.php',
20332008
];
2034-
$ignoreErrors[] = [
2035-
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
2036-
'count' => 1,
2037-
'path' => __DIR__ . '/system/HTTP/Files/FileCollection.php',
2038-
];
20392009
$ignoreErrors[] = [
20402010
'message' => '#^Only booleans are allowed in &&, array given on the right side\\.$#',
20412011
'count' => 2,
@@ -2133,7 +2103,7 @@
21332103
];
21342104
$ignoreErrors[] = [
21352105
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
2136-
'count' => 3,
2106+
'count' => 2,
21372107
'path' => __DIR__ . '/system/HTTP/Negotiate.php',
21382108
];
21392109
$ignoreErrors[] = [
@@ -2188,7 +2158,7 @@
21882158
];
21892159
$ignoreErrors[] = [
21902160
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
2191-
'count' => 6,
2161+
'count' => 5,
21922162
'path' => __DIR__ . '/system/HTTP/Response.php',
21932163
];
21942164
$ignoreErrors[] = [
@@ -2266,11 +2236,6 @@
22662236
'count' => 4,
22672237
'path' => __DIR__ . '/system/HTTP/UserAgent.php',
22682238
];
2269-
$ignoreErrors[] = [
2270-
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
2271-
'count' => 3,
2272-
'path' => __DIR__ . '/system/Helpers/array_helper.php',
2273-
];
22742239
$ignoreErrors[] = [
22752240
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
22762241
'count' => 1,
@@ -2358,7 +2323,7 @@
23582323
];
23592324
$ignoreErrors[] = [
23602325
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
2361-
'count' => 4,
2326+
'count' => 1,
23622327
'path' => __DIR__ . '/system/Helpers/form_helper.php',
23632328
];
23642329
$ignoreErrors[] = [
@@ -2378,7 +2343,7 @@
23782343
];
23792344
$ignoreErrors[] = [
23802345
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
2381-
'count' => 6,
2346+
'count' => 5,
23822347
'path' => __DIR__ . '/system/Helpers/html_helper.php',
23832348
];
23842349
$ignoreErrors[] = [
@@ -2398,7 +2363,7 @@
23982363
];
23992364
$ignoreErrors[] = [
24002365
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
2401-
'count' => 3,
2366+
'count' => 1,
24022367
'path' => __DIR__ . '/system/Helpers/text_helper.php',
24032368
];
24042369
$ignoreErrors[] = [
@@ -2408,7 +2373,7 @@
24082373
];
24092374
$ignoreErrors[] = [
24102375
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
2411-
'count' => 2,
2376+
'count' => 1,
24122377
'path' => __DIR__ . '/system/Helpers/url_helper.php',
24132378
];
24142379
$ignoreErrors[] = [
@@ -2551,19 +2516,14 @@
25512516
'count' => 1,
25522517
'path' => __DIR__ . '/system/Log/Handlers/FileHandler.php',
25532518
];
2554-
$ignoreErrors[] = [
2555-
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
2556-
'count' => 1,
2557-
'path' => __DIR__ . '/system/Log/Logger.php',
2558-
];
25592519
$ignoreErrors[] = [
25602520
'message' => '#^Parameter \\#1 \\$level \\(string\\) of method CodeIgniter\\\\Log\\\\Logger\\:\\:log\\(\\) should be contravariant with parameter \\$level \\(mixed\\) of method Psr\\\\Log\\\\LoggerInterface\\:\\:log\\(\\)$#',
25612521
'count' => 1,
25622522
'path' => __DIR__ . '/system/Log/Logger.php',
25632523
];
25642524
$ignoreErrors[] = [
25652525
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
2566-
'count' => 18,
2526+
'count' => 16,
25672527
'path' => __DIR__ . '/system/Model.php',
25682528
];
25692529
$ignoreErrors[] = [
@@ -2648,7 +2608,7 @@
26482608
];
26492609
$ignoreErrors[] = [
26502610
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
2651-
'count' => 6,
2611+
'count' => 3,
26522612
'path' => __DIR__ . '/system/Router/AutoRouter.php',
26532613
];
26542614
$ignoreErrors[] = [
@@ -2838,7 +2798,7 @@
28382798
];
28392799
$ignoreErrors[] = [
28402800
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
2841-
'count' => 5,
2801+
'count' => 4,
28422802
'path' => __DIR__ . '/system/Router/Router.php',
28432803
];
28442804
$ignoreErrors[] = [
@@ -2963,7 +2923,7 @@
29632923
];
29642924
$ignoreErrors[] = [
29652925
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
2966-
'count' => 3,
2926+
'count' => 2,
29672927
'path' => __DIR__ . '/system/Session/Handlers/MemcachedHandler.php',
29682928
];
29692929
$ignoreErrors[] = [
@@ -2988,7 +2948,7 @@
29882948
];
29892949
$ignoreErrors[] = [
29902950
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
2991-
'count' => 13,
2951+
'count' => 12,
29922952
'path' => __DIR__ . '/system/Session/Session.php',
29932953
];
29942954
$ignoreErrors[] = [
@@ -3273,7 +3233,7 @@
32733233
];
32743234
$ignoreErrors[] = [
32753235
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
3276-
'count' => 7,
3236+
'count' => 6,
32773237
'path' => __DIR__ . '/system/Test/DOMParser.php',
32783238
];
32793239
$ignoreErrors[] = [
@@ -3851,11 +3811,6 @@
38513811
'count' => 1,
38523812
'path' => __DIR__ . '/system/Validation/CreditCardRules.php',
38533813
];
3854-
$ignoreErrors[] = [
3855-
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
3856-
'count' => 1,
3857-
'path' => __DIR__ . '/system/Validation/DotArrayFilter.php',
3858-
];
38593814
$ignoreErrors[] = [
38603815
'message' => '#^Only booleans are allowed in a negated boolean, array\\|null given\\.$#',
38613816
'count' => 6,
@@ -3868,7 +3823,7 @@
38683823
];
38693824
$ignoreErrors[] = [
38703825
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
3871-
'count' => 11,
3826+
'count' => 8,
38723827
'path' => __DIR__ . '/system/Validation/Rules.php',
38733828
];
38743829
$ignoreErrors[] = [
@@ -3908,7 +3863,7 @@
39083863
];
39093864
$ignoreErrors[] = [
39103865
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
3911-
'count' => 9,
3866+
'count' => 6,
39123867
'path' => __DIR__ . '/system/View/Parser.php',
39133868
];
39143869
$ignoreErrors[] = [
@@ -3918,12 +3873,7 @@
39183873
];
39193874
$ignoreErrors[] = [
39203875
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
3921-
'count' => 1,
3922-
'path' => __DIR__ . '/system/View/Plugins.php',
3923-
];
3924-
$ignoreErrors[] = [
3925-
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
3926-
'count' => 9,
3876+
'count' => 7,
39273877
'path' => __DIR__ . '/system/View/Table.php',
39283878
];
39293879
$ignoreErrors[] = [

rector.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
1313
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
14+
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
1415
use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
1516
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
1617
use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector;
@@ -137,6 +138,7 @@
137138
$rectorConfig->rule(FuncGetArgsToVariadicParamRector::class);
138139
$rectorConfig->rule(MakeInheritedMethodVisibilitySameAsParentRector::class);
139140
$rectorConfig->rule(SimplifyEmptyArrayCheckRector::class);
141+
$rectorConfig->rule(SimplifyEmptyCheckOnEmptyArrayRector::class);
140142
$rectorConfig->rule(StringClassNameToClassConstantRector::class);
141143
$rectorConfig->rule(PrivatizeFinalClassPropertyRector::class);
142144
$rectorConfig->rule(CompleteDynamicPropertiesRector::class);

0 commit comments

Comments
 (0)