|
5 | 5 | use Closure;
|
6 | 6 | use PHPStan\Testing\PHPStanTestCase;
|
7 | 7 | use PHPUnit\Framework\Attributes\DataProvider;
|
| 8 | +use const PHP_VERSION_ID; |
8 | 9 |
|
9 | 10 | /**
|
10 | 11 | * @phpstan-consistent-constructor
|
11 | 12 | */
|
12 | 13 | class ClosureTypeFactoryTest extends PHPStanTestCase
|
13 | 14 | {
|
14 | 15 |
|
15 | | - public static function dataFromClosureObjectReturnType(): array |
| 16 | + public static function dataFromClosureObjectReturnType(): iterable |
16 | 17 | {
|
17 | | - return [ |
18 | | - [static function (): void { |
19 | | - }, 'void'], |
20 | | - [static function () { // @phpcs:ignore |
21 | | - }, 'mixed'], |
22 | | - [static fn (): int => 5, 'int'], |
23 | | - [ |
24 | | - static fn (): self => new self('name'), |
25 | | - self::class, |
26 | | - ], |
27 | | - [ |
28 | | - static fn (): static => new static('name'), |
29 | | - 'static(' . self::class . ')', |
30 | | - ], |
| 18 | + yield [static function (): void { |
| 19 | + }, 'void']; |
| 20 | + yield [static function () { // @phpcs:ignore |
| 21 | + }, 'mixed']; |
| 22 | + yield [static fn (): int => 5, 'int']; |
| 23 | + yield [ |
| 24 | + static fn (): self => new self('name'), |
| 25 | + self::class, |
| 26 | + ]; |
| 27 | + |
| 28 | + if (PHP_VERSION_ID < 80000) { |
| 29 | + return; |
| 30 | + } |
| 31 | + |
| 32 | + yield [ |
| 33 | + static fn (): static => new static('name'), |
| 34 | + 'static(' . self::class . ')', |
31 | 35 | ];
|
32 | 36 | }
|
33 | 37 |
|
|
0 commit comments