mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-31 20:51:46 +01:00
[DowngradePhp71] Nullable return on closure call on DowngradeNullableTypeDeclarationRector (#6303)
* [DowngradePhp71] Nullable return on closure call on DowngradeNullableTypeDeclarationRector * fix
This commit is contained in:
parent
37d818dae4
commit
a3f2346fa8
@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user