[DowngradePhp71] Nullable return on closure call on DowngradeNullableTypeDeclarationRector (#6303)

* [DowngradePhp71] Nullable return on closure call on DowngradeNullableTypeDeclarationRector

* fix
This commit is contained in:
Abdul Malik Ikhsan 2021-05-03 17:20:55 +07:00 committed by GitHub
parent 37d818dae4
commit a3f2346fa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 1 deletions

View File

@ -0,0 +1,31 @@
<?php
namespace Rector\Tests\DowngradePhp71\Rector\FunctionLike\DowngradeNullableTypeDeclarationRector\Fixture;
class NullableOnClosure
{
public function run()
{
$this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (\PhpParser\Node $node) use($propertyName, &$assignedParamName) : ?int {
return null;
});
}
}
?>
-----
<?php
namespace Rector\Tests\DowngradePhp71\Rector\FunctionLike\DowngradeNullableTypeDeclarationRector\Fixture;
class NullableOnClosure
{
public function run()
{
$this->simpleCallableNodeTraverser->traverseNodesWithCallable((array) $classMethod->stmts, function (\PhpParser\Node $node) use($propertyName, &$assignedParamName) {
return null;
});
}
}
?>

View File

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Rector\DowngradePhp71\Rector\FunctionLike;
use PhpParser\Node;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\FunctionLike;
use PhpParser\Node\NullableType;
use PhpParser\Node\Param;
@ -45,7 +46,7 @@ final class DowngradeNullableTypeDeclarationRector extends AbstractRector
*/
public function getNodeTypes(): array
{
return [Function_::class, ClassMethod::class];
return [Function_::class, ClassMethod::class, Closure::class];
}
public function getRuleDefinition(): RuleDefinition