Skip to content

Commit 673580a

Browse files
committed
fix
1 parent c72e6ac commit 673580a

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5783,7 +5783,7 @@ private function processAssignVar(
57835783
}
57845784
}
57855785

5786-
foreach($additionalExpressions as $additionalExpression) {
5786+
foreach ($additionalExpressions as $additionalExpression) {
57875787
[$expr, $type] = $additionalExpression;
57885788

57895789
$scope = $scope->assignExpression($expr, $type, $type);

tests/PHPStan/Analyser/LegacyNodeScopeResolverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7906,7 +7906,7 @@ public static function dataArrayKeysInBranches(): array
79067906
'$arrayAppendedInForeach',
79077907
],
79087908
[
7909-
'non-empty-array<int<0, max>, literal-string&lowercase-string&non-falsy-string>', // could be 'array<int<0, max>, \'bar\'|\'baz\'|\'foo\'>'
7909+
"non-empty-array<int<0, max>, 'bar'|'baz'|'foo'>",
79107910
'$anotherArrayAppendedInForeach',
79117911
],
79127912
[

tests/PHPStan/Rules/Arrays/data/bug-13538.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,18 @@ function doFoo(array $arr, int $i, int $i2): void
1414

1515
assertType("non-empty-array<int, ''>", $logs);
1616
assertType("''", $logs[$i]);
17-
assertType("string", $logs[$i2]);
17+
assertType("''", $logs[$i2]); // could be mixed
1818

1919
foreach ($arr as $value) {
2020
echo $logs[$i];
21-
echo $logs[$i2];
2221

2322
assertType("non-empty-array<int, ''>", $logs);
2423
assertType("''", $logs[$i]);
25-
assertType("string", $logs[$i2]);
2624
}
2725
}
2826

2927
/** @param list<string> $arr */
30-
function doFooBar(array $arr, int $i): void
28+
function doFooBar(array $arr): void
3129
{
3230
if (!defined('LOG_DIR')) {
3331
throw new LogicException();
@@ -38,15 +36,12 @@ function doFooBar(array $arr, int $i): void
3836

3937
assertType("non-empty-array<''>", $logs);
4038
assertType("''", $logs[LOG_DIR]);
41-
assertType("string", $logs[$i]);
4239

4340
foreach ($arr as $value) {
4441
echo $logs[LOG_DIR];
45-
echo $logs[$i];
4642

4743
assertType("non-empty-array<''>", $logs);
4844
assertType("''", $logs[LOG_DIR]);
49-
assertType("string", $logs[$i]);
5045
}
5146
}
5247

0 commit comments

Comments
 (0)