Skip to content

Commit

Permalink
Adjust test executions for older PHP versions
Browse files Browse the repository at this point in the history
  • Loading branch information
janedbal committed Oct 2, 2024
1 parent 03d7ee5 commit 5962e1e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
5 changes: 5 additions & 0 deletions tests/Rule/ForbidNotNormalizedTypeRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PHPStan\PhpDoc\TypeNodeResolver;
use PHPStan\Type\FileTypeMapper;
use ShipMonk\PHPStan\RuleTestCase;
use const PHP_VERSION_ID;

/**
* @extends RuleTestCase<ForbidNotNormalizedTypeRule>
Expand All @@ -25,6 +26,10 @@ protected function getRule(): ForbidNotNormalizedTypeRule

public function testRule(): void
{
if (PHP_VERSION_ID < 8_02_00) {
self::markTestSkipped('Test is for PHP 8.2+, we are using native true type there');
}

$this->analyseFile(__DIR__ . '/data/ForbidNotNormalizedTypeRule/code.php');
}

Expand Down
9 changes: 9 additions & 0 deletions tests/Rule/ForbidUnsafeArrayKeyRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PHPStan\Rules\Rule;
use ShipMonk\PHPStan\Rule\ForbidUnsafeArrayKeyRule;
use ShipMonk\PHPStan\RuleTestCase;
use const PHP_VERSION_ID;

/**
* @extends RuleTestCase<ForbidUnsafeArrayKeyRule>
Expand Down Expand Up @@ -35,13 +36,21 @@ protected function getRule(): Rule

public function testStrict(): void
{
if (PHP_VERSION_ID < 8_00_00) {
self::markTestSkipped('Test is for PHP 8.0+, we are using native mixed type there');
}

$this->checkMixed = true;
$this->checkInsideIsset = true;
$this->analyseFile(__DIR__ . '/data/ForbidUnsafeArrayKeyRule/default.php');
}

public function testLessStrict(): void
{
if (PHP_VERSION_ID < 8_00_00) {
self::markTestSkipped('Test is for PHP 8.0+, we are using native mixed type there');
}

$this->checkMixed = false;
$this->checkInsideIsset = false;
$this->analyseFile(__DIR__ . '/data/ForbidUnsafeArrayKeyRule/less-strict.php');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface Bar {}
int|float $intOrFloat,
float $float,
bool $bool,
mixed $mixed,
$mixed,
) {
$foos > $foo; // error: Comparison array > AllowComparingOnlyComparableTypesRule\Foo contains non-comparable type, only int|float|string|DateTimeInterface or comparable tuple is allowed.
$nullableInt > $int; // error: Comparison int|null > int contains non-comparable type, only int|float|string|DateTimeInterface or comparable tuple is allowed.
Expand Down
10 changes: 5 additions & 5 deletions tests/Rule/data/ForbidVariableTypeOverwritingRule/code.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ function testBasics(
}

function testIgnoredTypes(
mixed $mixed1,
mixed $mixed2,
mixed $mixed3,
mixed $mixed4,
$mixed1,
$mixed2,
$mixed3,
$mixed4,
?ParentClass $parentClass1,
ParentClass $parentClass2,
): void {
Expand All @@ -103,7 +103,7 @@ function testIgnoredTypes(
function testAdvancedTypesAreIgnored(
array $nonEmptyArray,
array $intList,
mixed $mixed,
$mixed,
int $int,
int $positiveInt,
int $intMask,
Expand Down

0 comments on commit 5962e1e

Please sign in to comment.