Skip to content

Commit

Permalink
[DowngradePhp70] Handle DowngradeScalarTypeDeclarationRector on Closu…
Browse files Browse the repository at this point in the history
…re (#102)
  • Loading branch information
samsonasik authored May 25, 2021
1 parent 592ca48 commit 4da81fa
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Rector\Tests\DowngradePhp70\Rector\FunctionLike\DowngradeScalarTypeDeclarationRector\Fixture;

do_something(function ( string $to_return ) : string {
return $to_return;
});

function do_something($returner) {
$returned = $returner('abc123');
}

?>
-----
<?php

namespace Rector\Tests\DowngradePhp70\Rector\FunctionLike\DowngradeScalarTypeDeclarationRector\Fixture;

do_something(function ( $to_return ) {
$to_return = (string) $to_return;
return $to_return;
});

function do_something($returner) {
$returned = $returner('abc123');
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use PhpParser\Node\Expr\Cast\Double;
use PhpParser\Node\Expr\Cast\Int_;
use PhpParser\Node\Expr\Cast\String_;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\FunctionLike;
use PhpParser\Node\Param;
Expand Down Expand Up @@ -44,7 +45,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

0 comments on commit 4da81fa

Please sign in to comment.