mirror of
https://github.com/danog/psalm-plugin-phpunit.git
synced 2024-11-26 12:04:52 +01:00
Remove dead code
The code being removed is no longer used as composer constraints have been tightened to not include those older versions that required workarounds.
This commit is contained in:
parent
1ce1ef2c3f
commit
6ba908dab6
@ -1,5 +1,9 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="phpunit-psalm-plugin">
|
||||
<ruleset
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"
|
||||
name="phpunit-psalm-plugin"
|
||||
>
|
||||
<!-- display progress -->
|
||||
<arg value="p"/>
|
||||
<arg name="colors"/>
|
||||
|
@ -12,7 +12,6 @@ use Psalm\DocComment;
|
||||
use Psalm\Exception\DocblockParseException;
|
||||
use Psalm\IssueBuffer;
|
||||
use Psalm\Issue;
|
||||
use Psalm\PhpUnitPlugin\VersionUtils;
|
||||
use Psalm\Plugin\EventHandler\AfterClassLikeAnalysisInterface;
|
||||
use Psalm\Plugin\EventHandler\AfterClassLikeVisitInterface;
|
||||
use Psalm\Plugin\EventHandler\AfterCodebasePopulatedInterface;
|
||||
@ -441,23 +440,9 @@ class TestCaseHandler implements
|
||||
/** @return non-empty-array<string,Type\Atomic> */
|
||||
private static function getAtomics(Type\Union $union): array
|
||||
{
|
||||
if (method_exists($union, 'getAtomicTypes')) {
|
||||
/** @var non-empty-array<string, Type\Atomic> annotated for versions missing the method */
|
||||
return $union->getAtomicTypes();
|
||||
}
|
||||
|
||||
if (method_exists($union, 'getTypes')) {
|
||||
/**
|
||||
* @psalm-suppress DeprecatedMethod annotated for newer versions that deprecated the method
|
||||
* @var non-empty-array<string, Type\Atomic> annotated for versions missing the method
|
||||
*/
|
||||
$types = $union->getTypes();
|
||||
return $types;
|
||||
}
|
||||
|
||||
throw new RuntimeException('Unexpected: union has no way to get it constituent types');
|
||||
}
|
||||
|
||||
private static function unionizeIterables(Codebase $codebase, Type\Union $iterables): Type\Atomic\TIterable
|
||||
{
|
||||
/** @var Type\Union[] $key_types */
|
||||
@ -553,40 +538,15 @@ class TestCaseHandler implements
|
||||
/** @return array{description:string, specials:array<string,array<int,string>>} */
|
||||
private static function getParsedComment(Doc $comment): array
|
||||
{
|
||||
if (VersionUtils::packageVersionIs('vimeo/psalm', '>=', '3.11.6')) {
|
||||
// explanation for the suppressions below
|
||||
// Oldest supported psalm versions did not have parsePreservingLength() at all
|
||||
// Versions between 3.6 and 3.11.6 had that, but it was returning array
|
||||
|
||||
/** @psalm-suppress UndefinedMethod for oldest versions */
|
||||
$parsed_docblock = DocComment::parsePreservingLength($comment);
|
||||
|
||||
/**
|
||||
* @psalm-suppress InvalidPropertyFetch
|
||||
* @var string
|
||||
*/
|
||||
$description = $parsed_docblock->description;
|
||||
|
||||
/**
|
||||
* @psalm-suppress InvalidPropertyFetch
|
||||
* @var array<string,array<int,string>>
|
||||
*/
|
||||
$specials = $parsed_docblock->tags;
|
||||
|
||||
return [
|
||||
'description' => $description,
|
||||
'specials' => $specials,
|
||||
];
|
||||
} else {
|
||||
// before 3.11.6 parsePreservingLength() was returning array,
|
||||
// but parse() wasn't deprecated, so we just use that
|
||||
|
||||
/** @psalm-suppress DeprecatedMethod for newer Psalm versions */
|
||||
return DocComment::parse(
|
||||
(string) $comment->getReformattedText(),
|
||||
self::getCommentLine($comment)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private static function queueClassLikeForScanning(
|
||||
@ -604,14 +564,4 @@ class TestCaseHandler implements
|
||||
$codebase->scanner->queueClassLikeForScanning($fq_class_name, $file_path);
|
||||
}
|
||||
}
|
||||
|
||||
private static function getCommentLine(Doc $docblock): int
|
||||
{
|
||||
if (method_exists($docblock, 'getStartLine')) {
|
||||
//typecasting is done on purpose, compatability with psalm old versions
|
||||
return $docblock->getStartLine();
|
||||
}
|
||||
/** @psalm-suppress DeprecatedMethod */
|
||||
return $docblock->getLine();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user