Skip to content

Commit

Permalink
skip set in configure
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Jan 15, 2024
1 parent 08da9ca commit 8791c09
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Rector\Symfony\Tests\DowngradeSymfony70\Rector\Class_\DowngradeSymfonyCommandAttributeRector\Fixture;

use Symfony\Component\Console\Command\Command;

class SkipSetInConfigure extends Command
{
protected function configure(): void
{
$this->setName('app:create-user');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
use PHPStan\Reflection\ClassReflection;
use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer;

/**
* @see \Rector\Symfony\Tests\DowngradeSymfony70\Rector\Class_\DowngradeSymfonyCommandAttributeRector\DowngradeSymfonyCommandAttributeRectorTest
*/
final class DowngradeSymfonyCommandAttributeRector extends AbstractRector
{
public function __construct(private readonly ReflectionResolver $reflectionResolver)
public function __construct(
private readonly ReflectionResolver $reflectionResolver,
private readonly PhpAttributeAnalyzer $phpAttributeAnalyzer
)
{
}

Expand Down Expand Up @@ -70,6 +74,10 @@ public function refactor(Node $node): ?Node
return null;
}

if (! $this->phpAttributeAnalyzer->hasPhpAttribute($node, 'Symfony\Component\Console\Attribute\AsCommand')) {
return null;
}

return null;
}
}

0 comments on commit 8791c09

Please sign in to comment.