Skip to content

Commit e3a8a7e

Browse files
committed
Move test cases for report-possibly-nonexistent-array-offset
1 parent d3baf76 commit e3a8a7e

File tree

2 files changed

+23
-25
lines changed

2 files changed

+23
-25
lines changed

tests/PHPStan/Analyser/nsrt/for-loop-expr.php

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,28 +50,3 @@ function getItemsArray(array $items): array
5050
assertType('array<string>', $items);
5151
return $items;
5252
}
53-
54-
/**
55-
* @param array<string> $items
56-
*/
57-
function skipFirstElement(array $items): void
58-
{
59-
for ($i = 1; count($items) > $i; ++$i) {
60-
$items[$i] = 'hello';
61-
}
62-
63-
assertType('array<string>', $items);
64-
}
65-
66-
/**
67-
* @param positive-int $skip
68-
* @param array<string> $items
69-
*/
70-
function skipByX(int $skip, array $items): void
71-
{
72-
for ($i = $skip; count($items) > $i; ++$i) {
73-
$items[$i] = 'hello';
74-
}
75-
76-
assertType('array<string>', $items);
77-
}

tests/PHPStan/Rules/Arrays/data/report-possibly-nonexistent-array-offset.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,26 @@ public function nonEmpty(array $a): void
5858
}
5959

6060
}
61+
62+
/**
63+
* @param array<string> $items
64+
*/
65+
function skipFirstElement(array $items): void
66+
{
67+
for ($i = 1; count($items) > $i; ++$i) {
68+
$element = $items[$i];
69+
\PHPStan\Testing\assertType('string', $element);
70+
}
71+
}
72+
73+
/**
74+
* @param positive-int $skip
75+
* @param array<string> $items
76+
*/
77+
function skipByX(int $skip, array $items): void
78+
{
79+
for ($i = $skip; count($items) > $i; ++$i) {
80+
$element = $items[$i];
81+
\PHPStan\Testing\assertType('string', $element);
82+
}
83+
}

0 commit comments

Comments
 (0)