Skip to content

Commit d542f6d

Browse files
committed
refactor: fix implicit array creation
1 parent 0b0126c commit d542f6d

File tree

4 files changed

+8
-29
lines changed

4 files changed

+8
-29
lines changed

phpstan-baseline.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -889,12 +889,6 @@
889889
'count' => 3,
890890
'path' => __DIR__ . '/system/Commands/Utilities/Routes.php',
891891
];
892-
$ignoreErrors[] = [
893-
// identifier: variable.implicitArray
894-
'message' => '#^Implicit array creation is not allowed \\- variable \\$filters might not exist\\.$#',
895-
'count' => 1,
896-
'path' => __DIR__ . '/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollector.php',
897-
];
898892
$ignoreErrors[] = [
899893
// identifier: missingType.iterableValue
900894
'message' => '#^Method CodeIgniter\\\\Commands\\\\Utilities\\\\Routes\\\\AutoRouterImproved\\\\AutoRouteCollector\\:\\:addFilters\\(\\) has parameter \\$routes with no value type specified in iterable type array\\.$#',
@@ -7351,18 +7345,6 @@
73517345
'count' => 1,
73527346
'path' => __DIR__ . '/system/Helpers/url_helper.php',
73537347
];
7354-
$ignoreErrors[] = [
7355-
// identifier: variable.implicitArray
7356-
'message' => '#^Implicit array creation is not allowed \\- variable \\$atts might not exist\\.$#',
7357-
'count' => 1,
7358-
'path' => __DIR__ . '/system/Helpers/url_helper.php',
7359-
];
7360-
$ignoreErrors[] = [
7361-
// identifier: variable.undefined
7362-
'message' => '#^Variable \\$atts might not be defined\\.$#',
7363-
'count' => 1,
7364-
'path' => __DIR__ . '/system/Helpers/url_helper.php',
7365-
];
73667348
$ignoreErrors[] = [
73677349
// identifier: empty.notAllowed
73687350
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
@@ -12739,12 +12721,6 @@
1273912721
'count' => 1,
1274012722
'path' => __DIR__ . '/tests/system/Cookie/CookieTest.php',
1274112723
];
12742-
$ignoreErrors[] = [
12743-
// identifier: variable.implicitArray
12744-
'message' => '#^Implicit array creation is not allowed \\- variable \\$array does not exist\\.$#',
12745-
'count' => 1,
12746-
'path' => __DIR__ . '/tests/system/DataConverter/DataConverterTest.php',
12747-
];
1274812724
$ignoreErrors[] = [
1274912725
// identifier: missingType.callable
1275012726
'message' => '#^Method CodeIgniter\\\\DataConverter\\\\DataConverterTest\\:\\:createDataConverter\\(\\) has parameter \\$extractor with no signature specified for Closure\\.$#',

system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ private function addFilters($routes)
122122
$filtersShortest = $filterCollector->get($route['method'], $routePath . $sampleUri);
123123

124124
// Get common array elements
125+
$filters = [];
125126
$filters['before'] = array_intersect($filtersLongest['before'], $filtersShortest['before']);
126127
$filters['after'] = array_intersect($filtersLongest['after'], $filtersShortest['after']);
127128

system/Helpers/url_helper.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ function anchor_popup($uri = '', string $title = '', $attributes = false, ?App $
211211
$windowName = '_blank';
212212
}
213213

214+
$atts = [];
215+
214216
foreach (['width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'menubar' => 'no', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0'] as $key => $val) {
215217
$atts[$key] = $attributes[$key] ?? $val;
216218
unset($attributes[$key]);

tests/system/DataConverter/DataConverterTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -668,11 +668,11 @@ public function testExtractWithClosure(): void
668668
'updated_at' => 'datetime',
669669
];
670670
$extractor = static function ($obj): array {
671-
$array['id'] = $obj->id;
672-
$array['name'] = $obj->name;
673-
$array['created_at'] = $obj->created_at;
674-
675-
return $array;
671+
return [
672+
'id' => $obj->id,
673+
'name' => $obj->name,
674+
'created_at' => $obj->created_at,
675+
];
676676
};
677677
$converter = $this->createDataConverter($types, [], db_connect(), null, $extractor);
678678

0 commit comments

Comments
 (0)