Skip to content

Commit

Permalink
Dumb version detection
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Nov 3, 2022
1 parent 6d93259 commit 1b62fa7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Hooks/TestCaseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Psalm\PhpUnitPlugin\Hooks;

use Error;
use PhpParser\Comment\Doc;
use PhpParser\Node\Stmt\ClassLike;
use PhpParser\Node\Stmt\ClassMethod;
Expand Down Expand Up @@ -167,10 +168,10 @@ public static function afterStatementAnalysis(AfterClassLikeAnalysisEvent $event
}

foreach ($specials['dataProvider'] as $line => $provider) {
if (VersionUtils::packageVersionIs('vimeo/psalm', '<=', '4.99')) {
try {
$provider_docblock_location = clone $method_storage->location;
$provider_docblock_location->setCommentLine($line);
} else {
} catch (Error $_) {
/** @var CodeLocation */
$provider_docblock_location = $method_storage->location->setCommentLine($line);
}
Expand Down Expand Up @@ -337,12 +338,12 @@ static function (
$provider_docblock_location
): void {
if ($is_optional) {
if (VersionUtils::packageVersionIs('vimeo/psalm', '<=', '4.99')) {
$param_type = clone $param_type;
$param_type->possibly_undefined = true;
} else {
if (method_exists($param_type, 'setPossiblyUndefined')) {
/** @var Union */
$param_type = $param_type->setPossiblyUndefined(true);
} else {
$param_type = clone $param_type;
$param_type->possibly_undefined = true;
}
}
if ($codebase->isTypeContainedByType($potential_argument_type, $param_type)) {
Expand Down

0 comments on commit 1b62fa7

Please sign in to comment.