From 9044b30475630b2498b97f742943610ccef3ee1a Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 1 Nov 2022 13:40:16 +0100 Subject: [PATCH] Fix --- src/Hooks/TestCaseHandler.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Hooks/TestCaseHandler.php b/src/Hooks/TestCaseHandler.php index 0ecf897..57a64b7 100644 --- a/src/Hooks/TestCaseHandler.php +++ b/src/Hooks/TestCaseHandler.php @@ -337,12 +337,12 @@ static function ( $provider_docblock_location ): void { if ($is_optional) { - if (method_exists($param_type, 'setPossiblyUndefined')) { - /** @var Union */ - $param_type = $param_type->setPossiblyUndefined(true); - } else { + if (VersionUtils::packageVersionIs('vimeo/psalm', '<', '5.0')) { $param_type = clone $param_type; $param_type->possibly_undefined = true; + } else { + /** @var Union */ + $param_type = $param_type->setPossiblyUndefined(true); } } if ($codebase->isTypeContainedByType($potential_argument_type, $param_type)) {