Skip to content

Commit

Permalink
[DowngradePhp71] Apply DowngradeIterablePseudoTypeDeclarationRector o…
Browse files Browse the repository at this point in the history
…n closures as well (#6662) (#760)

Co-authored-by: Bobab12 <bobab12@users.noreply.github.com>
  • Loading branch information
bobab12 and bobab12 committed Aug 25, 2021
1 parent 3603d73 commit db9cfd6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Rector\Tests\DowngradePhp71\Rector\FunctionLike\DowngradeIterablePseudoTypeDeclarationRector\Fixture;

final class ClosureIterable
{
public function run()
{
return function (): iterable {
return [];
};
}
}

?>
-----
<?php

namespace Rector\Tests\DowngradePhp71\Rector\FunctionLike\DowngradeIterablePseudoTypeDeclarationRector\Fixture;

final class ClosureIterable
{
public function run()
{
return function () {
return [];
};
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Rector\DowngradePhp71\Rector\FunctionLike;

use PhpParser\Node;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
use PHPStan\Type\IterableType;
Expand All @@ -31,7 +32,7 @@ public function __construct(
*/
public function getNodeTypes(): array
{
return [Function_::class, ClassMethod::class];
return [Function_::class, ClassMethod::class, Closure::class];
}

public function getRuleDefinition(): RuleDefinition
Expand Down Expand Up @@ -69,7 +70,7 @@ public function run($iterator)
}

/**
* @param Function_|ClassMethod $node
* @param Function_|ClassMethod|Closure $node
*/
public function refactor(Node $node): ?Node
{
Expand Down

0 comments on commit db9cfd6

Please sign in to comment.