Skip to content

Commit

Permalink
add arrow function
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Dec 11, 2023
1 parent d587951 commit d43ac44
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Rector\Tests\DowngradePhp82\Rector\Class_\DowngradeStandaloneNullTrueFalseReturnTypeRector\Fixture;

fn (): null => null;

?>
-----
<?php

namespace Rector\Tests\DowngradePhp82\Rector\Class_\DowngradeStandaloneNullTrueFalseReturnTypeRector\Fixture;

fn (): mixed => null;

?>
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\FunctionLike;
use PhpParser\Node\Identifier;
use PhpParser\Node\NullableType;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
use PhpParser\Node\UnionType;
use PHPStan\Type\Constant\ConstantBooleanType;
use PHPStan\Type\NullType;
use PHPStan\Type\Type;
Expand Down Expand Up @@ -118,7 +120,7 @@ private function resolveNativeType(Node $node, Node $returnType): Node
{
if ($node instanceof ClassMethod) {
$returnTypeFromParent = $this->resolveParentNativeReturnType($node);
if ($returnTypeFromParent instanceof Node) {
if ($returnTypeFromParent instanceof UnionType || $returnTypeFromParent instanceof NullableType) {
$this->traverseNodesWithCallable($returnTypeFromParent, static function (Node $subNode): void {
$subNode->setAttribute(AttributeKey::ORIGINAL_NODE, null);
});
Expand Down

0 comments on commit d43ac44

Please sign in to comment.