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:
Bruce Weirdan 2021-06-19 02:50:24 +03:00
parent 1ce1ef2c3f
commit 6ba908dab6
No known key found for this signature in database
GPG Key ID: CFC3AAB181751B0D
2 changed files with 13 additions and 59 deletions

View File

@ -1,5 +1,9 @@
<?xml version="1.0"?> <?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 --> <!-- display progress -->
<arg value="p"/> <arg value="p"/>
<arg name="colors"/> <arg name="colors"/>

View File

@ -12,7 +12,6 @@ use Psalm\DocComment;
use Psalm\Exception\DocblockParseException; use Psalm\Exception\DocblockParseException;
use Psalm\IssueBuffer; use Psalm\IssueBuffer;
use Psalm\Issue; use Psalm\Issue;
use Psalm\PhpUnitPlugin\VersionUtils;
use Psalm\Plugin\EventHandler\AfterClassLikeAnalysisInterface; use Psalm\Plugin\EventHandler\AfterClassLikeAnalysisInterface;
use Psalm\Plugin\EventHandler\AfterClassLikeVisitInterface; use Psalm\Plugin\EventHandler\AfterClassLikeVisitInterface;
use Psalm\Plugin\EventHandler\AfterCodebasePopulatedInterface; use Psalm\Plugin\EventHandler\AfterCodebasePopulatedInterface;
@ -441,21 +440,7 @@ class TestCaseHandler implements
/** @return non-empty-array<string,Type\Atomic> */ /** @return non-empty-array<string,Type\Atomic> */
private static function getAtomics(Type\Union $union): array private static function getAtomics(Type\Union $union): array
{ {
if (method_exists($union, 'getAtomicTypes')) { return $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 private static function unionizeIterables(Codebase $codebase, Type\Union $iterables): Type\Atomic\TIterable
@ -553,40 +538,15 @@ class TestCaseHandler implements
/** @return array{description:string, specials:array<string,array<int,string>>} */ /** @return array{description:string, specials:array<string,array<int,string>>} */
private static function getParsedComment(Doc $comment): array private static function getParsedComment(Doc $comment): array
{ {
if (VersionUtils::packageVersionIs('vimeo/psalm', '>=', '3.11.6')) { $parsed_docblock = DocComment::parsePreservingLength($comment);
// 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 */ $description = $parsed_docblock->description;
$parsed_docblock = DocComment::parsePreservingLength($comment); $specials = $parsed_docblock->tags;
/** return [
* @psalm-suppress InvalidPropertyFetch 'description' => $description,
* @var string 'specials' => $specials,
*/ ];
$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( private static function queueClassLikeForScanning(
@ -604,14 +564,4 @@ class TestCaseHandler implements
$codebase->scanner->queueClassLikeForScanning($fq_class_name, $file_path); $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();
}
} }