Skip to content

Commit 9deb8f8

Browse files
committed
more tests
1 parent 67e510d commit 9deb8f8

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

tests/PHPStan/Analyser/NodeScopeResolverTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ private static function findTestFiles(): iterable
248248
yield __DIR__ . '/../Rules/Classes/data/bug-11591-property-tag.php';
249249
yield __DIR__ . '/../Rules/Classes/data/mixin-trait-use.php';
250250

251+
yield __DIR__ . '/../Rules/Arrays/data/bug-14234.php';
251252
yield __DIR__ . '/../Rules/Arrays/data/bug-11679.php';
252253
yield __DIR__ . '/../Rules/Methods/data/bug-4801.php';
253254
yield __DIR__ . '/../Rules/Arrays/data/narrow-superglobal.php';

tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,12 @@ public function testBug14234(): void
11931193
{
11941194
$this->reportPossiblyNonexistentGeneralArrayOffset = true;
11951195

1196-
$this->analyse([__DIR__ . '/data/bug-14234.php'], []);
1196+
$this->analyse([__DIR__ . '/data/bug-14234.php'], [
1197+
[
1198+
'Offset int<0, max> might not exist on array.',
1199+
48,
1200+
],
1201+
]);
11971202
}
11981203

11991204
}

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
namespace Bug14234;
44

5+
use function PHPStan\Testing\assertType;
6+
57
function getShortenedPath(string $identifier): string
68
{
79
$parts = explode('/', $identifier);
10+
assertType('non-empty-list<string>', $parts);
811

912
for ($i = 0; $i < count($parts) - 1; $i++) {
1013
$parts[$i] = substr($parts[$i], 0, 1);
@@ -16,10 +19,34 @@ function getShortenedPath(string $identifier): string
1619
function getShortenedPath2(string $identifier): string
1720
{
1821
$parts = explode('/', $identifier);
22+
assertType('non-empty-list<string>', $parts);
1923

2024
for ($i = 0; $i < count($parts); $i++) {
2125
$parts[$i] = substr($parts[$i], 0, 1);
2226
}
2327

2428
return implode("/", $parts);
2529
}
30+
31+
function getShortenedPath3(string $identifier): string
32+
{
33+
$parts = explode('/', $identifier);
34+
assertType('non-empty-list<string>', $parts);
35+
36+
for ($i = 0; $i < count($parts) - 4; $i++) {
37+
$parts[$i] = substr($parts[$i], 0, 1);
38+
}
39+
40+
return implode("/", $parts);
41+
}
42+
43+
function getShortenedPath4(array $parts): string
44+
{
45+
assertType('array', $parts);
46+
47+
for ($i = 0; $i < count($parts) - 4; $i++) {
48+
$parts[$i] = substr($parts[$i], 0, 1);
49+
}
50+
51+
return implode("/", $parts);
52+
}

0 commit comments

Comments
 (0)