Fix type widening command (#5883)

* skip parent type for construtc

* skip magic method
This commit is contained in:
Tomas Votruba 2021-03-17 23:56:45 +01:00 committed by GitHub
parent 0e383192ae
commit 6ad6bdc2d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,21 @@
<?php
namespace Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\Fixture;
use Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\Source\AnyService;
use Symfony\Component\Console\Command\Command;
final class SkipCommand extends Command
{
/**
* @var AnyService
*/
private $anyService;
public function __construct(AnyService $anyService)
{
$this->anyService = $anyService;
parent::__construct();
}
}

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector\Source;
final class AnyService
{
}

View File

@ -98,6 +98,10 @@ CODE_SAMPLE
*/
public function refactor(Node $node): ?Node
{
if ($node->isMagic()) {
return null;
}
if ($node->params === []) {
return null;
}