|
7 | 7 | use PHPStan\ShouldNotHappenException;
|
8 | 8 | use PHPStan\Testing\PHPStanTestCase;
|
9 | 9 | use PHPStan\TrinaryLogic;
|
| 10 | +use PHPStan\Type\ArrayType; |
10 | 11 | use PHPStan\Type\IntegerType;
|
| 12 | +use PHPStan\Type\MixedType; |
11 | 13 | use PHPUnit\Framework\Attributes\DataProvider;
|
12 | 14 | use function count;
|
13 | 15 | use function get_class;
|
@@ -127,6 +129,22 @@ public static function dataIsAlwaysTerminating(): array
|
127 | 129 | 'var_dump(exit()."a");',
|
128 | 130 | true,
|
129 | 131 | ],
|
| 132 | + [ |
| 133 | + 'array_push($arr, fn() => "exit");', |
| 134 | + false, |
| 135 | + ], |
| 136 | + [ |
| 137 | + 'array_push($arr, function() { exit(); });', |
| 138 | + false, |
| 139 | + ], |
| 140 | + [ |
| 141 | + 'array_push($arr, "exit");', |
| 142 | + false, |
| 143 | + ], |
| 144 | + [ |
| 145 | + 'array_unshift($arr, "exit");', |
| 146 | + false, |
| 147 | + ], |
130 | 148 | ];
|
131 | 149 | }
|
132 | 150 |
|
@@ -155,7 +173,8 @@ public function testIsAlwaysTerminating(
|
155 | 173 | /** @var ScopeFactory $scopeFactory */
|
156 | 174 | $scopeFactory = self::getContainer()->getByType(ScopeFactory::class);
|
157 | 175 | $scope = $scopeFactory->create(ScopeContext::create('test.php'))
|
158 |
| - ->assignVariable('x', new IntegerType(), new IntegerType(), TrinaryLogic::createYes()); |
| 176 | + ->assignVariable('x', new IntegerType(), new IntegerType(), TrinaryLogic::createYes()) |
| 177 | + ->assignVariable('arr', new ArrayType(new MixedType(), new MixedType()), new ArrayType(new MixedType(), new MixedType()), TrinaryLogic::createYes()); |
159 | 178 |
|
160 | 179 | $result = $nodeScopeResolver->processExprNode(
|
161 | 180 | $stmt,
|
|
0 commit comments