Skip to content

Commit b333970

Browse files
committed
better test
1 parent 43abe4b commit b333970

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

tests/PHPStan/Rules/Classes/InstantiationRuleTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,4 +586,13 @@ public function testBug12951(): void
586586
]);
587587
}
588588

589+
public function testNamedArgumentsPhpversion(): void
590+
{
591+
if (PHP_VERSION_ID < 80000) {
592+
self::markTestSkipped('Test requires PHP 8.0');
593+
}
594+
595+
$this->analyse([__DIR__ . '/data/named-arguments-phpversion.php'], []);
596+
}
597+
589598
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace NamedArgumentsPhpversion;
4+
5+
use Exception;
6+
7+
class HelloWorld
8+
{
9+
/** @return mixed[] */
10+
public function sayHello(): array|null
11+
{
12+
if(PHP_VERSION_ID >= 80400) {
13+
} else {
14+
}
15+
return [
16+
new Exception(previous: new Exception()),
17+
];
18+
}
19+
}
20+
21+
class HelloWorld2
22+
{
23+
/** @return mixed[] */
24+
public function sayHello(): array|null
25+
{
26+
return [
27+
PHP_VERSION_ID >= 80400 ? 1 : 0,
28+
new Exception(previous: new Exception()),
29+
];
30+
}
31+
}

0 commit comments

Comments
 (0)