|
4 | 4 |
|
5 | 5 | use PHPStan\Rules\Rule;
|
6 | 6 | use PHPStan\Testing\RuleTestCase;
|
| 7 | +use function array_merge; |
7 | 8 | use const PHP_VERSION_ID;
|
8 | 9 |
|
9 | 10 | /**
|
@@ -142,7 +143,7 @@ public function testTreatPhpDocTypesAsCertain(bool $treatPhpDocTypesAsCertain, a
|
142 | 143 |
|
143 | 144 | public function testBug11694(): void
|
144 | 145 | {
|
145 |
| - $this->analyse([__DIR__ . '/data/bug-11694.php'], [ |
| 146 | + $expectedErrors = [ |
146 | 147 | [
|
147 | 148 | 'Loose comparison using == between 3 and int<10, 20> will always evaluate to false.',
|
148 | 149 | 17,
|
@@ -173,6 +174,24 @@ public function testBug11694(): void
|
173 | 174 | 27,
|
174 | 175 | 'Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.',
|
175 | 176 | ],
|
| 177 | + ]; |
| 178 | + |
| 179 | + if (PHP_VERSION_ID >= 80000) { |
| 180 | + $expectedErrors = array_merge($expectedErrors, [ |
| 181 | + [ |
| 182 | + "Loose comparison using == between '13foo' and int<10, 20> will always evaluate to false.", |
| 183 | + 29, |
| 184 | + 'Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.', |
| 185 | + ], |
| 186 | + [ |
| 187 | + "Loose comparison using == between int<10, 20> and '13foo' will always evaluate to false.", |
| 188 | + 30, |
| 189 | + 'Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.', |
| 190 | + ], |
| 191 | + ]); |
| 192 | + } |
| 193 | + |
| 194 | + $expectedErrors = array_merge($expectedErrors, [ |
176 | 195 | [
|
177 | 196 | 'Loose comparison using == between \' 3\' and int<10, 20> will always evaluate to false.',
|
178 | 197 | 32,
|
@@ -204,6 +223,8 @@ public function testBug11694(): void
|
204 | 223 | 'Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.',
|
205 | 224 | ],
|
206 | 225 | ]);
|
| 226 | + |
| 227 | + $this->analyse([__DIR__ . '/data/bug-11694.php'], $expectedErrors); |
207 | 228 | }
|
208 | 229 |
|
209 | 230 | }
|
0 commit comments