Skip to content

Commit

Permalink
in closure test
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Dec 11, 2023
1 parent ce5a94e commit 345d44c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

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

$a = function(): null
{
return null;
}

?>
-----
<?php

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

$a = function(): mixed
{
return null;
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down

0 comments on commit 345d44c

Please sign in to comment.