Skip to content

Commit 03fc68b

Browse files
committed
Regression tests
Closes phpstan/phpstan#8900 Closes phpstan/phpstan#8222
1 parent 2879ebc commit 03fc68b

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

tests/PHPStan/Rules/Comparison/MatchExpressionRuleTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,4 +452,13 @@ public function testBug8932(): void
452452
$this->analyse([__DIR__ . '/data/bug-8932.php'], []);
453453
}
454454

455+
public function testBug8900(): void
456+
{
457+
if (PHP_VERSION_ID < 80000) {
458+
$this->markTestSkipped('Test requires PHP 8.0.');
459+
}
460+
461+
$this->analyse([__DIR__ . '/data/bug-8900.php'], []);
462+
}
463+
455464
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Bug8900;
4+
5+
class Foo
6+
{
7+
8+
public function doFoo(): void
9+
{
10+
$test_array = [];
11+
for($index = 0; $index++; $index < random_int(1,100)) {
12+
$test_array[] = 'entry';
13+
}
14+
15+
foreach($test_array as $key => $value) {
16+
$key_mod_4 = match($key % 4) {
17+
0 => '0',
18+
1 => '1',
19+
2 => '2',
20+
3 => '3',
21+
};
22+
}
23+
}
24+
25+
}

tests/PHPStan/Rules/Properties/TypesAssignedToPropertiesRuleTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,4 +536,14 @@ public function testBug9131(): void
536536
$this->analyse([__DIR__ . '/data/bug-9131.php'], []);
537537
}
538538

539+
public function testBug8222(): void
540+
{
541+
if (PHP_VERSION_ID < 70400) {
542+
$this->markTestSkipped('Test requires PHP 7.4.');
543+
}
544+
545+
$this->checkExplicitMixed = true;
546+
$this->analyse([__DIR__ . '/data/bug-8222.php'], []);
547+
}
548+
539549
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php // lint >= 7.4
2+
3+
namespace Bug8222;
4+
5+
class ValueCollection
6+
{
7+
/** @var array<positive-int|0, string> */
8+
public array $values;
9+
10+
public function addValue(string $value): void
11+
{
12+
$this->values[] = $value;
13+
}
14+
}

0 commit comments

Comments
 (0)