mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Skip callable tests for PHP 7
This commit is contained in:
parent
ea137fc20c
commit
1c5f6963a6
@ -88,10 +88,16 @@ class MethodAnalyzer extends FunctionLikeAnalyzer
|
|||||||
) {
|
) {
|
||||||
$codebase_methods = $codebase->methods;
|
$codebase_methods = $codebase->methods;
|
||||||
|
|
||||||
|
if ($method_id === 'Closure::fromcallable') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$original_method_id = $method_id;
|
||||||
|
|
||||||
$method_id = $codebase_methods->getDeclaringMethodId($method_id);
|
$method_id = $codebase_methods->getDeclaringMethodId($method_id);
|
||||||
|
|
||||||
if (!$method_id) {
|
if (!$method_id) {
|
||||||
throw new \LogicException('Method id should not be null');
|
throw new \LogicException('Declaring method for ' . $original_method_id . ' should not be null');
|
||||||
}
|
}
|
||||||
|
|
||||||
$storage = $codebase_methods->getStorage($method_id);
|
$storage = $codebase_methods->getStorage($method_id);
|
||||||
|
@ -631,7 +631,7 @@ class CallableTest extends TestCase
|
|||||||
);
|
);
|
||||||
}'
|
}'
|
||||||
],
|
],
|
||||||
'closureFromCallableInvokableNamedClass' => [
|
'PHP71-closureFromCallableInvokableNamedClass' => [
|
||||||
'<?php
|
'<?php
|
||||||
namespace NS;
|
namespace NS;
|
||||||
use Closure;
|
use Closure;
|
||||||
@ -647,7 +647,7 @@ class CallableTest extends TestCase
|
|||||||
|
|
||||||
acceptsIntToBool(Closure::fromCallable(new NamedInvokable));'
|
acceptsIntToBool(Closure::fromCallable(new NamedInvokable));'
|
||||||
],
|
],
|
||||||
'closureFromCallableInvokableAnonymousClass' => [
|
'PHP71-closureFromCallableInvokableAnonymousClass' => [
|
||||||
'<?php
|
'<?php
|
||||||
namespace NS;
|
namespace NS;
|
||||||
use Closure;
|
use Closure;
|
||||||
@ -1049,7 +1049,7 @@ class CallableTest extends TestCase
|
|||||||
f([C::class, "m"]);',
|
f([C::class, "m"]);',
|
||||||
'error_message' => 'InvalidScalarArgument',
|
'error_message' => 'InvalidScalarArgument',
|
||||||
],
|
],
|
||||||
'closureFromCallableInvokableNamedClassWrongArgs' => [
|
'PHP71-closureFromCallableInvokableNamedClassWrongArgs' => [
|
||||||
'<?php
|
'<?php
|
||||||
namespace NS;
|
namespace NS;
|
||||||
use Closure;
|
use Closure;
|
||||||
|
@ -24,8 +24,20 @@ trait InvalidCodeAnalysisTestTrait
|
|||||||
*/
|
*/
|
||||||
public function testInvalidCode($code, $error_message, $error_levels = [], $strict_mode = false)
|
public function testInvalidCode($code, $error_message, $error_levels = [], $strict_mode = false)
|
||||||
{
|
{
|
||||||
if (strpos($this->getTestName(), 'SKIPPED-') !== false) {
|
if (strpos($test_name, 'PHP7-') !== false) {
|
||||||
$this->markTestSkipped();
|
if (version_compare(PHP_VERSION, '7.0.0dev', '<')) {
|
||||||
|
$this->markTestSkipped('Test case requires PHP 7.');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} elseif (strpos($test_name, 'PHP71-') !== false) {
|
||||||
|
if (version_compare(PHP_VERSION, '7.1.0', '<')) {
|
||||||
|
$this->markTestSkipped('Test case requires PHP 7.1.');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} elseif (strpos($test_name, 'SKIPPED-') !== false) {
|
||||||
|
$this->markTestSkipped('Skipped due to a bug.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($strict_mode) {
|
if ($strict_mode) {
|
||||||
|
Loading…
Reference in New Issue
Block a user