mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Promote conditional tests to always-running
This commit is contained in:
parent
20567ff720
commit
cf962eebc2
@ -330,7 +330,7 @@ class ClosureTest extends TestCase
|
|||||||
}
|
}
|
||||||
}',
|
}',
|
||||||
],
|
],
|
||||||
'PHP71-mirrorCallableParams' => [
|
'mirrorCallableParams' => [
|
||||||
'<?php
|
'<?php
|
||||||
namespace NS;
|
namespace NS;
|
||||||
use Closure;
|
use Closure;
|
||||||
@ -357,7 +357,7 @@ class ClosureTest extends TestCase
|
|||||||
[1, 2, 3]
|
[1, 2, 3]
|
||||||
);',
|
);',
|
||||||
],
|
],
|
||||||
'PHP71-closureFromCallableInvokableNamedClass' => [
|
'closureFromCallableInvokableNamedClass' => [
|
||||||
'<?php
|
'<?php
|
||||||
namespace NS;
|
namespace NS;
|
||||||
use Closure;
|
use Closure;
|
||||||
@ -373,7 +373,7 @@ class ClosureTest extends TestCase
|
|||||||
|
|
||||||
acceptsIntToBool(Closure::fromCallable(new NamedInvokable));',
|
acceptsIntToBool(Closure::fromCallable(new NamedInvokable));',
|
||||||
],
|
],
|
||||||
'PHP71-closureFromCallableInvokableAnonymousClass' => [
|
'closureFromCallableInvokableAnonymousClass' => [
|
||||||
'<?php
|
'<?php
|
||||||
namespace NS;
|
namespace NS;
|
||||||
use Closure;
|
use Closure;
|
||||||
@ -389,7 +389,7 @@ class ClosureTest extends TestCase
|
|||||||
|
|
||||||
acceptsIntToBool(Closure::fromCallable($anonInvokable));',
|
acceptsIntToBool(Closure::fromCallable($anonInvokable));',
|
||||||
],
|
],
|
||||||
'PHP71-publicCallableFromInside' => [
|
'publicCallableFromInside' => [
|
||||||
'<?php
|
'<?php
|
||||||
class Base {
|
class Base {
|
||||||
public function publicMethod() : void {}
|
public function publicMethod() : void {}
|
||||||
@ -401,7 +401,7 @@ class ClosureTest extends TestCase
|
|||||||
}
|
}
|
||||||
}',
|
}',
|
||||||
],
|
],
|
||||||
'PHP71-protectedCallableFromInside' => [
|
'protectedCallableFromInside' => [
|
||||||
'<?php
|
'<?php
|
||||||
class Base {
|
class Base {
|
||||||
protected function protectedMethod() : void {}
|
protected function protectedMethod() : void {}
|
||||||
@ -413,7 +413,7 @@ class ClosureTest extends TestCase
|
|||||||
}
|
}
|
||||||
}',
|
}',
|
||||||
],
|
],
|
||||||
'PHP71-closureFromCallableNamedFunction' => [
|
'closureFromCallableNamedFunction' => [
|
||||||
'<?php
|
'<?php
|
||||||
$closure = Closure::fromCallable("strlen");
|
$closure = Closure::fromCallable("strlen");
|
||||||
',
|
',
|
||||||
@ -965,7 +965,7 @@ class ClosureTest extends TestCase
|
|||||||
}',
|
}',
|
||||||
'error_message' => 'TypeDoesNotContainType',
|
'error_message' => 'TypeDoesNotContainType',
|
||||||
],
|
],
|
||||||
'PHP71-closureFromCallableInvokableNamedClassWrongArgs' => [
|
'closureFromCallableInvokableNamedClassWrongArgs' => [
|
||||||
'<?php
|
'<?php
|
||||||
namespace NS;
|
namespace NS;
|
||||||
use Closure;
|
use Closure;
|
||||||
@ -999,7 +999,7 @@ class ClosureTest extends TestCase
|
|||||||
};',
|
};',
|
||||||
'error_message' => 'DuplicateParam',
|
'error_message' => 'DuplicateParam',
|
||||||
],
|
],
|
||||||
'PHP71-privateCallable' => [
|
'privateCallable' => [
|
||||||
'<?php
|
'<?php
|
||||||
class Base {
|
class Base {
|
||||||
private function privateMethod() : void {}
|
private function privateMethod() : void {}
|
||||||
|
@ -1032,7 +1032,7 @@ class FunctionCallTest extends TestCase
|
|||||||
'$c' => 'int',
|
'$c' => 'int',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'PHP73-hrtime' => [
|
'hrtime' => [
|
||||||
'<?php
|
'<?php
|
||||||
$a = hrtime(true);
|
$a = hrtime(true);
|
||||||
$b = hrtime();
|
$b = hrtime();
|
||||||
@ -1046,7 +1046,7 @@ class FunctionCallTest extends TestCase
|
|||||||
'$d' => 'array{0: int, 1: int}',
|
'$d' => 'array{0: int, 1: int}',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'PHP73-hrtimeCanBeFloat' => [
|
'hrtimeCanBeFloat' => [
|
||||||
'<?php
|
'<?php
|
||||||
$a = hrtime(true);
|
$a = hrtime(true);
|
||||||
|
|
||||||
@ -1239,7 +1239,7 @@ class FunctionCallTest extends TestCase
|
|||||||
/** @psalm-suppress TooFewArguments */
|
/** @psalm-suppress TooFewArguments */
|
||||||
min(0);',
|
min(0);',
|
||||||
],
|
],
|
||||||
'PHP73-allowIsCountableToInformType' => [
|
'allowIsCountableToInformType' => [
|
||||||
'<?php
|
'<?php
|
||||||
function getObject() : iterable{
|
function getObject() : iterable{
|
||||||
return [];
|
return [];
|
||||||
@ -1345,7 +1345,7 @@ class FunctionCallTest extends TestCase
|
|||||||
'$matches===' => 'array<array-key, array{string, int}>',
|
'$matches===' => 'array<array-key, array{string, int}>',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'PHP72-pregMatchWithFlagUnmatchedAsNull' => [
|
'pregMatchWithFlagUnmatchedAsNull' => [
|
||||||
'<?php
|
'<?php
|
||||||
$r = preg_match("{foo}", "foo", $matches, PREG_UNMATCHED_AS_NULL);',
|
$r = preg_match("{foo}", "foo", $matches, PREG_UNMATCHED_AS_NULL);',
|
||||||
'assertions' => [
|
'assertions' => [
|
||||||
@ -1353,7 +1353,7 @@ class FunctionCallTest extends TestCase
|
|||||||
'$matches===' => 'array<array-key, null|string>',
|
'$matches===' => 'array<array-key, null|string>',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'PHP72-pregMatchWithFlagOffsetCaptureAndUnmatchedAsNull' => [
|
'pregMatchWithFlagOffsetCaptureAndUnmatchedAsNull' => [
|
||||||
'<?php
|
'<?php
|
||||||
$r = preg_match("{foo}", "foo", $matches, PREG_OFFSET_CAPTURE | PREG_UNMATCHED_AS_NULL);',
|
$r = preg_match("{foo}", "foo", $matches, PREG_OFFSET_CAPTURE | PREG_UNMATCHED_AS_NULL);',
|
||||||
'assertions' => [
|
'assertions' => [
|
||||||
@ -1399,7 +1399,7 @@ class FunctionCallTest extends TestCase
|
|||||||
return compact("a", "b", "c");
|
return compact("a", "b", "c");
|
||||||
}',
|
}',
|
||||||
],
|
],
|
||||||
'PHP73-setCookiePhp73' => [
|
'setCookiePhp73' => [
|
||||||
'<?php
|
'<?php
|
||||||
setcookie(
|
setcookie(
|
||||||
"name",
|
"name",
|
||||||
|
@ -42,11 +42,7 @@ trait InvalidCodeAnalysisTestTrait
|
|||||||
string $php_version = '7.3'
|
string $php_version = '7.3'
|
||||||
): void {
|
): void {
|
||||||
$test_name = $this->getTestName();
|
$test_name = $this->getTestName();
|
||||||
if (strpos($test_name, 'PHP71-') !== false) {
|
if (strpos($test_name, 'PHP80-') !== false) {
|
||||||
if (version_compare(PHP_VERSION, '7.1.0', '<')) {
|
|
||||||
$this->markTestSkipped('Test case requires PHP 7.1.');
|
|
||||||
}
|
|
||||||
} elseif (strpos($test_name, 'PHP80-') !== false) {
|
|
||||||
if (version_compare(PHP_VERSION, '8.0.0', '<')) {
|
if (version_compare(PHP_VERSION, '8.0.0', '<')) {
|
||||||
$this->markTestSkipped('Test case requires PHP 8.0.');
|
$this->markTestSkipped('Test case requires PHP 8.0.');
|
||||||
}
|
}
|
||||||
|
@ -39,19 +39,7 @@ trait ValidCodeAnalysisTestTrait
|
|||||||
string $php_version = '7.3'
|
string $php_version = '7.3'
|
||||||
): void {
|
): void {
|
||||||
$test_name = $this->getTestName();
|
$test_name = $this->getTestName();
|
||||||
if (strpos($test_name, 'PHP71-') !== false) {
|
if (strpos($test_name, 'PHP80-') !== false) {
|
||||||
if (version_compare(PHP_VERSION, '7.1.0', '<')) {
|
|
||||||
$this->markTestSkipped('Test case requires PHP 7.1.');
|
|
||||||
}
|
|
||||||
} elseif (strpos($test_name, 'PHP72-') !== false) {
|
|
||||||
if (version_compare(PHP_VERSION, '7.2.0', '<')) {
|
|
||||||
$this->markTestSkipped('Test case requires PHP 7.2.');
|
|
||||||
}
|
|
||||||
} elseif (strpos($test_name, 'PHP73-') !== false) {
|
|
||||||
if (version_compare(PHP_VERSION, '7.3.0', '<')) {
|
|
||||||
$this->markTestSkipped('Test case requires PHP 7.3.');
|
|
||||||
}
|
|
||||||
} elseif (strpos($test_name, 'PHP80-') !== false) {
|
|
||||||
if (version_compare(PHP_VERSION, '8.0.0', '<')) {
|
if (version_compare(PHP_VERSION, '8.0.0', '<')) {
|
||||||
$this->markTestSkipped('Test case requires PHP 8.0.');
|
$this->markTestSkipped('Test case requires PHP 8.0.');
|
||||||
}
|
}
|
||||||
|
@ -1006,7 +1006,7 @@ class ConditionalTest extends TestCase
|
|||||||
atan($a);
|
atan($a);
|
||||||
atan($b);',
|
atan($b);',
|
||||||
],
|
],
|
||||||
'PHP71-removeNonCallable' => [
|
'removeNonCallable' => [
|
||||||
'<?php
|
'<?php
|
||||||
$f = rand(0, 1) ? "strlen" : 1.1;
|
$f = rand(0, 1) ? "strlen" : 1.1;
|
||||||
if (is_callable($f)) {
|
if (is_callable($f)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user