diff --git a/build/target-repository/composer.json b/build/target-repository/composer.json index 6b5f8e0a30d..68290e50bba 100644 --- a/build/target-repository/composer.json +++ b/build/target-repository/composer.json @@ -9,7 +9,7 @@ ], "require": { "php": "^7.4|^8.0", - "phpstan/phpstan": "^2.1.40" + "phpstan/phpstan": "^2.1.41" }, "autoload": { "files": [ diff --git a/composer.json b/composer.json index 48122114326..e7172771349 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "nikic/php-parser": "^5.7", "ondram/ci-detector": "^4.2", "phpstan/phpdoc-parser": "^2.3", - "phpstan/phpstan": "^2.1.40", + "phpstan/phpstan": "^2.1.41", "react/event-loop": "^1.6", "react/promise": "^3.3", "react/socket": "^1.17", diff --git a/rules/DeadCode/Rector/FunctionLike/NarrowWideUnionReturnTypeRector.php b/rules/DeadCode/Rector/FunctionLike/NarrowWideUnionReturnTypeRector.php index b90cc345753..2ecc8ddd341 100644 --- a/rules/DeadCode/Rector/FunctionLike/NarrowWideUnionReturnTypeRector.php +++ b/rules/DeadCode/Rector/FunctionLike/NarrowWideUnionReturnTypeRector.php @@ -35,7 +35,6 @@ use Rector\VersionBonding\Contract\MinPhpVersionInterface; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; -use Webmozart\Assert\Assert; /** * @see \Rector\Tests\DeadCode\Rector\FunctionLike\NarrowWideUnionReturnTypeRector\NarrowWideUnionReturnTypeRectorTest @@ -126,10 +125,11 @@ public function refactor(Node $node): ?Node $hasImplicitNullReturn = $this->silentVoidResolver->hasSilentVoid($node) || $this->hasImplicitNullReturn($returnStatements); + /** @var UnionType|NullableType $returnType */ $returnType = $node->returnType; - Assert::isInstanceOfAny($returnType, [UnionType::class, NullableType::class]); $returnType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($returnType); + $actualReturnTypes = $this->collectActualReturnTypes($returnStatements); if ($hasImplicitNullReturn) {