Skip to content

Commit

Permalink
Merge pull request #8341 from kenjis/add-SimplifyEmptyCheckOnEmptyArr…
Browse files Browse the repository at this point in the history
…ayRector

refactor: apply SimplifyEmptyCheckOnEmptyArrayRector
  • Loading branch information
kenjis authored Dec 19, 2023
2 parents 2198dfd + 392beac commit 4433c90
Show file tree
Hide file tree
Showing 40 changed files with 108 additions and 156 deletions.
106 changes: 28 additions & 78 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 13,
'count' => 10,
'path' => __DIR__ . '/system/Autoloader/FileLocator.php',
];
$ignoreErrors[] = [
Expand All @@ -33,7 +33,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 16,
'count' => 10,
'path' => __DIR__ . '/system/BaseModel.php',
];
$ignoreErrors[] = [
Expand Down Expand Up @@ -63,7 +63,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 5,
'count' => 2,
'path' => __DIR__ . '/system/CLI/BaseCommand.php',
];
$ignoreErrors[] = [
Expand All @@ -83,7 +83,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 6,
'count' => 1,
'path' => __DIR__ . '/system/CLI/CLI.php',
];
$ignoreErrors[] = [
Expand Down Expand Up @@ -856,11 +856,6 @@
'count' => 4,
'path' => __DIR__ . '/system/Config/Services.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Controller.php',
];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in a negated boolean, array given\\.$#',
'count' => 1,
Expand Down Expand Up @@ -1033,7 +1028,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 10,
'count' => 2,
'path' => __DIR__ . '/system/Database/BaseResult.php',
];
$ignoreErrors[] = [
Expand Down Expand Up @@ -1148,7 +1143,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 8,
'count' => 6,
'path' => __DIR__ . '/system/Database/MigrationRunner.php',
];
$ignoreErrors[] = [
Expand Down Expand Up @@ -1206,11 +1201,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Database/ModelFactory.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Database/MySQLi/Builder.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 12,
Expand Down Expand Up @@ -1543,7 +1533,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 15,
'count' => 10,
'path' => __DIR__ . '/system/Database/SQLSRV/Builder.php',
];
$ignoreErrors[] = [
Expand Down Expand Up @@ -1593,7 +1583,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 6,
'count' => 5,
'path' => __DIR__ . '/system/Database/SQLSRV/Forge.php',
];
$ignoreErrors[] = [
Expand Down Expand Up @@ -1713,7 +1703,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 3,
'count' => 2,
'path' => __DIR__ . '/system/Database/SQLite3/Table.php',
];
$ignoreErrors[] = [
Expand Down Expand Up @@ -1761,36 +1751,21 @@
'count' => 3,
'path' => __DIR__ . '/system/Debug/Exceptions.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Debug/Iterator.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 5,
'path' => __DIR__ . '/system/Debug/Timer.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 5,
'count' => 2,
'path' => __DIR__ . '/system/Debug/Toolbar.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Debug/Toolbar/Collectors/Database.php',
];
$ignoreErrors[] = [
'message' => '#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Debug/Toolbar/Collectors/Database.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Debug/Toolbar/Collectors/History.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 2,
Expand Down Expand Up @@ -1888,7 +1863,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 4,
'count' => 3,
'path' => __DIR__ . '/system/Entity/Entity.php',
];
$ignoreErrors[] = [
Expand Down Expand Up @@ -1958,7 +1933,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 2,
'count' => 1,
'path' => __DIR__ . '/system/HTTP/CLIRequest.php',
];
$ignoreErrors[] = [
Expand All @@ -1978,7 +1953,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 9,
'count' => 7,
'path' => __DIR__ . '/system/HTTP/ContentSecurityPolicy.php',
];
$ignoreErrors[] = [
Expand Down Expand Up @@ -2031,11 +2006,6 @@
'count' => 1,
'path' => __DIR__ . '/system/HTTP/Files/FileCollection.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/HTTP/Files/FileCollection.php',
];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in &&, array given on the right side\\.$#',
'count' => 2,
Expand Down Expand Up @@ -2133,7 +2103,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 3,
'count' => 2,
'path' => __DIR__ . '/system/HTTP/Negotiate.php',
];
$ignoreErrors[] = [
Expand Down Expand Up @@ -2188,7 +2158,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 6,
'count' => 5,
'path' => __DIR__ . '/system/HTTP/Response.php',
];
$ignoreErrors[] = [
Expand Down Expand Up @@ -2266,11 +2236,6 @@
'count' => 4,
'path' => __DIR__ . '/system/HTTP/UserAgent.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 3,
'path' => __DIR__ . '/system/Helpers/array_helper.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 1,
Expand Down Expand Up @@ -2358,7 +2323,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 4,
'count' => 1,
'path' => __DIR__ . '/system/Helpers/form_helper.php',
];
$ignoreErrors[] = [
Expand All @@ -2378,7 +2343,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 6,
'count' => 5,
'path' => __DIR__ . '/system/Helpers/html_helper.php',
];
$ignoreErrors[] = [
Expand All @@ -2398,7 +2363,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 3,
'count' => 1,
'path' => __DIR__ . '/system/Helpers/text_helper.php',
];
$ignoreErrors[] = [
Expand All @@ -2408,7 +2373,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 2,
'count' => 1,
'path' => __DIR__ . '/system/Helpers/url_helper.php',
];
$ignoreErrors[] = [
Expand Down Expand Up @@ -2551,19 +2516,14 @@
'count' => 1,
'path' => __DIR__ . '/system/Log/Handlers/FileHandler.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Log/Logger.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$level \\(string\\) of method CodeIgniter\\\\Log\\\\Logger\\:\\:log\\(\\) should be contravariant with parameter \\$level \\(mixed\\) of method Psr\\\\Log\\\\LoggerInterface\\:\\:log\\(\\)$#',
'count' => 1,
'path' => __DIR__ . '/system/Log/Logger.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 18,
'count' => 16,
'path' => __DIR__ . '/system/Model.php',
];
$ignoreErrors[] = [
Expand Down Expand Up @@ -2648,7 +2608,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 6,
'count' => 3,
'path' => __DIR__ . '/system/Router/AutoRouter.php',
];
$ignoreErrors[] = [
Expand Down Expand Up @@ -2838,7 +2798,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 5,
'count' => 4,
'path' => __DIR__ . '/system/Router/Router.php',
];
$ignoreErrors[] = [
Expand Down Expand Up @@ -2963,7 +2923,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 3,
'count' => 2,
'path' => __DIR__ . '/system/Session/Handlers/MemcachedHandler.php',
];
$ignoreErrors[] = [
Expand All @@ -2988,7 +2948,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 13,
'count' => 12,
'path' => __DIR__ . '/system/Session/Session.php',
];
$ignoreErrors[] = [
Expand Down Expand Up @@ -3273,7 +3233,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 7,
'count' => 6,
'path' => __DIR__ . '/system/Test/DOMParser.php',
];
$ignoreErrors[] = [
Expand Down Expand Up @@ -3851,11 +3811,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Validation/CreditCardRules.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Validation/DotArrayFilter.php',
];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in a negated boolean, array\\|null given\\.$#',
'count' => 6,
Expand All @@ -3868,7 +3823,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 11,
'count' => 8,
'path' => __DIR__ . '/system/Validation/Rules.php',
];
$ignoreErrors[] = [
Expand Down Expand Up @@ -3908,7 +3863,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 9,
'count' => 6,
'path' => __DIR__ . '/system/View/Parser.php',
];
$ignoreErrors[] = [
Expand All @@ -3918,12 +3873,7 @@
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/View/Plugins.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 9,
'count' => 7,
'path' => __DIR__ . '/system/View/Table.php',
];
$ignoreErrors[] = [
Expand Down
2 changes: 2 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector;
Expand Down Expand Up @@ -137,6 +138,7 @@
$rectorConfig->rule(FuncGetArgsToVariadicParamRector::class);
$rectorConfig->rule(MakeInheritedMethodVisibilitySameAsParentRector::class);
$rectorConfig->rule(SimplifyEmptyArrayCheckRector::class);
$rectorConfig->rule(SimplifyEmptyCheckOnEmptyArrayRector::class);
$rectorConfig->rule(StringClassNameToClassConstantRector::class);
$rectorConfig->rule(PrivatizeFinalClassPropertyRector::class);
$rectorConfig->rule(CompleteDynamicPropertiesRector::class);
Expand Down
Loading

0 comments on commit 4433c90

Please sign in to comment.