Skip to content

Commit 6cfeb23

Browse files
committed
Skip more mixed tests
1 parent 3e3b051 commit 6cfeb23

15 files changed

+127
-12
lines changed

tests/PHPStan/Analyser/AnalyserIntegrationTest.php

+12
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,10 @@ public function testBug7094(): void
827827

828828
public function testOffsetAccess(): void
829829
{
830+
if (PHP_VERSION_ID < 80000) {
831+
self::markTestSkipped('Test requires PHP 8.0.');
832+
}
833+
830834
$errors = $this->runAnalyse(__DIR__ . '/nsrt/offset-access.php');
831835
$this->assertCount(1, $errors);
832836
$this->assertSame('PHPDoc tag @return contains unresolvable type.', $errors[0]->getMessage());
@@ -1063,6 +1067,10 @@ public function testBug8376(): void
10631067

10641068
public function testAssertDocblock(): void
10651069
{
1070+
if (PHP_VERSION_ID < 80000) {
1071+
self::markTestSkipped('Test requires PHP 8.0.');
1072+
}
1073+
10661074
$errors = $this->runAnalyse(__DIR__ . '/nsrt/assert-docblock.php');
10671075
$this->assertCount(4, $errors);
10681076
$this->assertSame('Call to method AssertDocblock\A::testInt() with string will always evaluate to false.', $errors[0]->getMessage());
@@ -1396,6 +1404,10 @@ public function testBug11147(): void
13961404

13971405
public function testBug11283(): void
13981406
{
1407+
if (PHP_VERSION_ID < 80000) {
1408+
self::markTestSkipped('Test requires PHP 8.0.');
1409+
}
1410+
13991411
$errors = $this->runAnalyse(__DIR__ . '/data/bug-11283.php');
14001412
$this->assertNoErrors($errors);
14011413
}

tests/PHPStan/Analyser/nsrt/bug-10131.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php // lint >= 8.0
22

33
namespace Bug10131;
44

tests/PHPStan/Analyser/nsrt/bug-7607.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types = 1);
1+
<?php // lint >= 8.0
2+
3+
declare(strict_types = 1);
24

35
namespace Bug7607;
46

tests/PHPStan/Analyser/nsrt/bug-7685.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php // lint >= 8.0
22

33
namespace bug7685;
44

tests/PHPStan/Analyser/nsrt/bug-9105.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php // lint >= 8.0
22

33
namespace Bug9105;
44

tests/PHPStan/Analyser/nsrt/falsey-ternary-certainty.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php // lint >= 8.0
22

33
namespace FalseyTernaryCertainty;
44

tests/PHPStan/Analyser/nsrt/in_array_loose.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php // lint >= 8.0
22

33
namespace InArrayLoose;
44

tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeMethodCallRuleTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,15 @@ public function testBug8169(): void
208208
$this->analyse([__DIR__ . '/data/bug-8169.php'], [
209209
[
210210
'Call to method Bug8169\HelloWorld::assertString() with string will always evaluate to true.',
211-
19,
211+
21,
212212
],
213213
[
214214
'Call to method Bug8169\HelloWorld::assertString() with string will always evaluate to true.',
215-
26,
215+
28,
216216
],
217217
[
218218
'Call to method Bug8169\HelloWorld::assertString() with int will always evaluate to false.',
219-
33,
219+
35,
220220
],
221221
]);
222222
}

tests/PHPStan/Rules/Comparison/data/bug-8169.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types = 1);
1+
<?php // lint >= 8.0
2+
3+
declare(strict_types = 1);
24

35
namespace Bug8169;
46

tests/PHPStan/Rules/Functions/ExistingClassesInTypehintsRuleTest.php

+12
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,10 @@ public function dataRequiredParameterAfterOptional(): array
368368
*/
369369
public function testRequiredParameterAfterOptional(int $phpVersionId, array $errors): void
370370
{
371+
if (PHP_VERSION_ID < 80000) {
372+
self::markTestSkipped('Test requires PHP 8.0.');
373+
}
374+
371375
$this->phpVersionId = $phpVersionId;
372376
$this->analyse([__DIR__ . '/data/required-parameter-after-optional.php'], $errors);
373377
}
@@ -439,6 +443,10 @@ public function testTrueTypehint(): void
439443

440444
public function testConditionalReturnType(): void
441445
{
446+
if (PHP_VERSION_ID < 80000) {
447+
self::markTestSkipped('Test requires PHP 8.0.');
448+
}
449+
442450
$this->analyse([__DIR__ . '/data/conditional-return-type.php'], [
443451
[
444452
'Template type T of function FunctionConditionalReturnType\notGet() is not referenced in a parameter.',
@@ -449,6 +457,10 @@ public function testConditionalReturnType(): void
449457

450458
public function testTemplateInParamOut(): void
451459
{
460+
if (PHP_VERSION_ID < 80000) {
461+
self::markTestSkipped('Test requires PHP 8.0.');
462+
}
463+
452464
$this->analyse([__DIR__ . '/data/param-out.php'], [
453465
[
454466
'Template type S of function ParamOutTemplate\uselessGeneric() is not referenced in a parameter.',

tests/PHPStan/Rules/Methods/ExistingClassesInTypehintsRuleTest.php

+31
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,25 @@ public function testTrueTypehint(): void
437437
{
438438
if (PHP_VERSION_ID >= 80200) {
439439
$errors = [];
440+
} elseif (PHP_VERSION_ID >= 80000) {
441+
$errors = [
442+
[
443+
'Parameter $v of method NativeTrueType\Truthy::foo() has invalid type NativeTrueType\true.',
444+
10,
445+
],
446+
[
447+
'Method NativeTrueType\Truthy::foo() has invalid return type NativeTrueType\true.',
448+
10,
449+
],
450+
[
451+
'Parameter $trueUnion of method NativeTrueType\Truthy::trueUnion() has invalid type NativeTrueType\true.',
452+
14,
453+
],
454+
[
455+
'Method NativeTrueType\Truthy::trueUnionReturn() has invalid return type NativeTrueType\true.',
456+
31,
457+
],
458+
];
440459
} else {
441460
$errors = [
442461
[
@@ -447,14 +466,26 @@ public function testTrueTypehint(): void
447466
'Method NativeTrueType\Truthy::foo() has invalid return type NativeTrueType\true.',
448467
10,
449468
],
469+
[
470+
"Method NativeTrueType\Truthy::trueUnion() uses native union types but they're supported only on PHP 8.0 and later.",
471+
14,
472+
],
450473
[
451474
'Parameter $trueUnion of method NativeTrueType\Truthy::trueUnion() has invalid type NativeTrueType\true.',
452475
14,
453476
],
477+
[
478+
'Parameter $trueUnion of method NativeTrueType\Truthy::trueUnion() has invalid type NativeTrueType\null.',
479+
14,
480+
],
454481
[
455482
'Method NativeTrueType\Truthy::trueUnionReturn() has invalid return type NativeTrueType\true.',
456483
31,
457484
],
485+
[
486+
'Method NativeTrueType\Truthy::trueUnionReturn() has invalid return type NativeTrueType\null.',
487+
31,
488+
],
458489
];
459490
}
460491

tests/PHPStan/Rules/Methods/ReturnTypeRuleTest.php

+31
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,31 @@ public function testReturnTypeRule(): void
283283
]);
284284
}
285285

286+
public function testMisleadingMixedType(): void
287+
{
288+
if (PHP_VERSION_ID >= 80000) {
289+
$errors = [];
290+
} else {
291+
$errors = [
292+
[
293+
'Method MethodMisleadingMixedReturn\Foo::misleadingMixedReturnType() should return MethodMisleadingMixedReturn\mixed but returns int.',
294+
11,
295+
],
296+
[
297+
'Method MethodMisleadingMixedReturn\Foo::misleadingMixedReturnType() should return MethodMisleadingMixedReturn\mixed but returns true.',
298+
14,
299+
],
300+
];
301+
}
302+
$this->analyse([__DIR__ . '/data/method-misleading-mixed-return.php'], $errors);
303+
}
304+
286305
public function testMisleadingTypehintsInClassWithoutNamespace(): void
287306
{
307+
if (PHP_VERSION_ID < 80000) {
308+
self::markTestSkipped('Test requires PHP 8.0.');
309+
}
310+
288311
$this->analyse([__DIR__ . '/data/misleadingTypehints.php'], [
289312
[
290313
'Method FooWithoutNamespace::misleadingBoolReturnType() should return boolean but returns true.',
@@ -522,6 +545,10 @@ public function testBug2573(): void
522545

523546
public function testBug4603(): void
524547
{
548+
if (PHP_VERSION_ID < 80000) {
549+
self::markTestSkipped('Test requires PHP 8.0.');
550+
}
551+
525552
$this->analyse([__DIR__ . '/data/bug-4603.php'], []);
526553
}
527554

@@ -774,6 +801,10 @@ public function testBug6358(): void
774801

775802
public function testBug8071(): void
776803
{
804+
if (PHP_VERSION_ID < 80000) {
805+
self::markTestSkipped('Test requires PHP 8.0.');
806+
}
807+
777808
$this->checkExplicitMixed = true;
778809
$this->analyse([__DIR__ . '/data/bug-8071.php'], [
779810
[
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace MethodMisleadingMixedReturn;
4+
5+
class Foo
6+
{
7+
8+
public function misleadingMixedReturnType(): mixed
9+
{
10+
if (rand(0, 1)) {
11+
return 1;
12+
}
13+
if (rand(0, 1)) {
14+
return true;
15+
}
16+
if (rand(0, 1)) {
17+
return new mixed();
18+
}
19+
}
20+
21+
}

tests/PHPStan/Rules/Methods/data/returnTypes.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ public function misleadingIntReturnType(): \ReturnTypes\integer
375375
}
376376
}
377377

378-
public function misleadingMixedReturnType(): mixed
378+
/*public function misleadingMixedReturnType(): mixed
379379
{
380380
if (rand(0, 1)) {
381381
return 1;
@@ -386,7 +386,7 @@ public function misleadingMixedReturnType(): mixed
386386
if (rand(0, 1)) {
387387
return new mixed();
388388
}
389-
}
389+
}*/
390390
}
391391

392392
class FooChild extends Foo

tests/PHPStan/Rules/Properties/NullsafePropertyFetchRuleTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public function testBug8517(): void
6666

6767
public function testBug9105(): void
6868
{
69+
if (PHP_VERSION_ID < 80000) {
70+
self::markTestSkipped('Test requires PHP 8.0.');
71+
}
72+
6973
$this->analyse([__DIR__ . '/../../Analyser/nsrt/bug-9105.php'], []);
7074
}
7175

0 commit comments

Comments
 (0)