mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
fix code style remove debug code
This commit is contained in:
parent
d13a428cb5
commit
f8e548e811
@ -3,9 +3,8 @@
|
|||||||
namespace Psalm\Tests\Internal\Codebase;
|
namespace Psalm\Tests\Internal\Codebase;
|
||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Var_;
|
|
||||||
use PHPUnit\Framework\Error\Warning;
|
|
||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
use PHPUnit\Framework\SkippedTestError;
|
||||||
use Psalm\Codebase;
|
use Psalm\Codebase;
|
||||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||||
use Psalm\Internal\Codebase\InternalCallMapHandler;
|
use Psalm\Internal\Codebase\InternalCallMapHandler;
|
||||||
@ -20,9 +19,8 @@ use Psalm\Type;
|
|||||||
use ReflectionFunction;
|
use ReflectionFunction;
|
||||||
use ReflectionParameter;
|
use ReflectionParameter;
|
||||||
use ReflectionType;
|
use ReflectionType;
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
use function Amp\call;
|
use function class_exists;
|
||||||
use function count;
|
use function count;
|
||||||
use function explode;
|
use function explode;
|
||||||
use function function_exists;
|
use function function_exists;
|
||||||
@ -30,6 +28,7 @@ use function in_array;
|
|||||||
use function json_encode;
|
use function json_encode;
|
||||||
use function preg_match;
|
use function preg_match;
|
||||||
use function print_r;
|
use function print_r;
|
||||||
|
use function sort;
|
||||||
use function strncmp;
|
use function strncmp;
|
||||||
use function strpos;
|
use function strpos;
|
||||||
use function substr;
|
use function substr;
|
||||||
@ -436,7 +435,6 @@ class InternalCallMapHandlerTest extends TestCase
|
|||||||
);
|
);
|
||||||
$callMap = InternalCallMapHandler::getCallMap();
|
$callMap = InternalCallMapHandler::getCallMap();
|
||||||
foreach ($callMap as $function => $entry) {
|
foreach ($callMap as $function => $entry) {
|
||||||
if ($function !== 'hash_hmac_file') continue;
|
|
||||||
// Skip class methods
|
// Skip class methods
|
||||||
if (strpos($function, '::') !== false || !function_exists($function)) {
|
if (strpos($function, '::') !== false || !function_exists($function)) {
|
||||||
continue;
|
continue;
|
||||||
@ -451,14 +449,12 @@ class InternalCallMapHandlerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
private function isIgnored(string $functionName)
|
private function isIgnored(string $functionName): bool
|
||||||
{
|
{
|
||||||
/** @psalm-assert callable-string $functionName */
|
/** @psalm-assert callable-string $functionName */
|
||||||
if (in_array($functionName, self::$ignoredFunctions)) {
|
if (in_array($functionName, self::$ignoredFunctions)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -484,24 +480,21 @@ class InternalCallMapHandlerTest extends TestCase
|
|||||||
unset($callMapEntry[0]);
|
unset($callMapEntry[0]);
|
||||||
/** @var array<string, string> $callMapEntry */
|
/** @var array<string, string> $callMapEntry */
|
||||||
$this->assertEntryIsCorrect($callMapEntry, $functionName);
|
$this->assertEntryIsCorrect($callMapEntry, $functionName);
|
||||||
|
} catch (InvalidArgumentException $t) {
|
||||||
|
|
||||||
} catch(\InvalidArgumentException $t) {
|
|
||||||
// Silence this one for now.
|
// Silence this one for now.
|
||||||
$this->markTestSkipped('IA');
|
$this->markTestSkipped('IA');
|
||||||
} catch(\PHPUnit\Framework\SkippedTestError $t) {
|
} catch (SkippedTestError $t) {
|
||||||
die('this should not happen');
|
die('this should not happen');
|
||||||
} catch(ExpectationFailedException $e) {
|
} catch (ExpectationFailedException $e) {
|
||||||
// This is good!
|
// This is good!
|
||||||
throw $e;
|
throw $e;
|
||||||
} catch(InvalidArgumentException $e) {
|
} catch (InvalidArgumentException $e) {
|
||||||
// This can happen if a class does not exist, we handle the message to check for this case.
|
// This can happen if a class does not exist, we handle the message to check for this case.
|
||||||
if (preg_match('/^Could not get class storage for (.*)$/', $e->getMessage(), $matches)
|
if (preg_match('/^Could not get class storage for (.*)$/', $e->getMessage(), $matches)
|
||||||
&& !class_exists($matches[1])
|
&& !class_exists($matches[1])
|
||||||
) {
|
) {
|
||||||
die("Class mentioned in callmap does not exist: " . $matches[1]);
|
die("Class mentioned in callmap does not exist: " . $matches[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->markTestIncomplete("Remove function '{$functionName}' from your ignores");
|
$this->markTestIncomplete("Remove function '{$functionName}' from your ignores");
|
||||||
@ -616,14 +609,14 @@ class InternalCallMapHandlerTest extends TestCase
|
|||||||
$expectedType = Reflection::getPsalmTypeFromReflectionType($reflected);
|
$expectedType = Reflection::getPsalmTypeFromReflectionType($reflected);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$parsedType = Type::parseString($specified);
|
$parsedType = Type::parseString($specified);
|
||||||
} catch(\Throwable $t) {
|
} catch (Throwable $t) {
|
||||||
die("Failed to parse type: $specified -- $message");
|
die("Failed to parse type: $specified -- $message");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->assertTrue(UnionTypeComparator::isContainedBy(self::$codebase, $parsedType, $expectedType), $message);
|
$this->assertTrue(UnionTypeComparator::isContainedBy(self::$codebase, $parsedType, $expectedType), $message);
|
||||||
} catch(InvalidArgumentException $e) {
|
} catch (InvalidArgumentException $e) {
|
||||||
if (preg_match('/^Could not get class storage for (.*)$/', $e->getMessage(), $matches)
|
if (preg_match('/^Could not get class storage for (.*)$/', $e->getMessage(), $matches)
|
||||||
&& !class_exists($matches[1])
|
&& !class_exists($matches[1])
|
||||||
) {
|
) {
|
||||||
|
Loading…
Reference in New Issue
Block a user