diff --git a/rules-tests/DowngradePhp82/Rector/FunctionLike/DowngradeStandaloneNullTrueFalseReturnTypeRector/Fixture/in_closure.php.inc b/rules-tests/DowngradePhp82/Rector/FunctionLike/DowngradeStandaloneNullTrueFalseReturnTypeRector/Fixture/in_closure.php.inc new file mode 100644 index 00000000..bdb4114d --- /dev/null +++ b/rules-tests/DowngradePhp82/Rector/FunctionLike/DowngradeStandaloneNullTrueFalseReturnTypeRector/Fixture/in_closure.php.inc @@ -0,0 +1,21 @@ + +----- + \ No newline at end of file diff --git a/rules/DowngradePhp82/Rector/FunctionLike/DowngradeStandaloneNullTrueFalseReturnTypeRector.php b/rules/DowngradePhp82/Rector/FunctionLike/DowngradeStandaloneNullTrueFalseReturnTypeRector.php index b9c81269..816e2d18 100644 --- a/rules/DowngradePhp82/Rector/FunctionLike/DowngradeStandaloneNullTrueFalseReturnTypeRector.php +++ b/rules/DowngradePhp82/Rector/FunctionLike/DowngradeStandaloneNullTrueFalseReturnTypeRector.php @@ -84,6 +84,8 @@ public function refactor(Node $node): ?Node if (! $node instanceof ClassMethod) { $node->returnType = new Identifier('mixed'); + // in closure and arrow function can't add `@return null` docblock as they are Expr + // that rely on Stmt $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $this->phpDocTypeChanger->changeReturnType($node, $phpDocInfo, new NullType());