[DowngradePhp80] Handle DowngradeMixedTypeDeclarationRector on Closure (#106)

Co-authored-by: kaizen-ci <info@kaizen-ci.org>
This commit is contained in:
Abdul Malik Ikhsan 2021-05-26 17:07:49 +07:00 committed by GitHub
parent 21dc1db942
commit ed8487954d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 1 deletions

View File

@ -0,0 +1,37 @@
<?php
namespace Rector\Tests\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRector\Fixture;
class OnClosure
{
public function run()
{
$foo = array_filter(
$list,
function (mixed $fieldArgValue) {
return is_null($fieldArgValue);
}
);
}
}
?>
-----
<?php
namespace Rector\Tests\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRector\Fixture;
class OnClosure
{
public function run()
{
$foo = array_filter(
$list,
function ($fieldArgValue) {
return is_null($fieldArgValue);
}
);
}
}
?>

View File

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Rector\DowngradePhp80\Rector\FunctionLike;
use PhpParser\Node;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
use PHPStan\Type\MixedType;
@ -28,7 +29,7 @@ final class DowngradeMixedTypeDeclarationRector extends AbstractRector
*/
public function getNodeTypes(): array
{
return [Function_::class, ClassMethod::class];
return [Function_::class, ClassMethod::class, Closure::class];
}
public function getRuleDefinition(): RuleDefinition