diff --git a/rules/CodeQuality/Rector/ClassMethod/ExplicitReturnNullRector.php b/rules/CodeQuality/Rector/ClassMethod/ExplicitReturnNullRector.php index b1eb0d4b377..6cf5d3d168c 100644 --- a/rules/CodeQuality/Rector/ClassMethod/ExplicitReturnNullRector.php +++ b/rules/CodeQuality/Rector/ClassMethod/ExplicitReturnNullRector.php @@ -102,10 +102,10 @@ CODE_SAMPLE */ public function getNodeTypes() : array { - return [ClassMethod::class]; + return [ClassMethod::class, Function_::class]; } /** - * @param ClassMethod $node + * @param ClassMethod|Function_ $node */ public function refactor(Node $node) : ?Node { @@ -113,7 +113,7 @@ CODE_SAMPLE if ($node->returnType instanceof Node) { return null; } - if ($this->isName($node, MethodName::CONSTRUCT)) { + if ($node instanceof ClassMethod && $this->isName($node, MethodName::CONSTRUCT)) { return null; } $returnType = $this->returnTypeInferer->inferFunctionLike($node); @@ -143,9 +143,12 @@ CODE_SAMPLE $this->transformDocUnionVoidToUnionNull($node); return $node; } - private function transformDocUnionVoidToUnionNull(ClassMethod $classMethod) : void + /** + * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $node + */ + private function transformDocUnionVoidToUnionNull($node) : void { - $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod); + $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $returnType = $phpDocInfo->getReturnType(); if (!$returnType instanceof UnionType) { return; @@ -166,6 +169,6 @@ CODE_SAMPLE if (!$type instanceof UnionType) { return; } - $this->phpDocTypeChanger->changeReturnType($classMethod, $phpDocInfo, $type); + $this->phpDocTypeChanger->changeReturnType($node, $phpDocInfo, $type); } } diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index de999b3a8fc..5b3102a9795 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = '97e2433a8378ccc6666c67d4a01ace3abc97589f'; + public const PACKAGE_VERSION = 'c45f0e2cef30cb0b3090d51fd14dc6ffaa1fc095'; /** * @api * @var string */ - public const RELEASE_DATE = '2024-03-23 13:26:17'; + public const RELEASE_DATE = '2024-03-23 13:36:05'; /** * @var int */