Skip to content

Commit 55e6ba9

Browse files
authored
[CodeQuality] Skip UserInterface instance on ControllerMethodInjectionToConstructorRector (#904)
* [CodeQuality] Skip \Domain sub namespace on ControllerMethodInjectionToConstructorRector * skip object of user interface * revert Domain
1 parent 02f371f commit 55e6ba9

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\Symfony\Tests\CodeQuality\Rector\Class_\ControllerMethodInjectionToConstructorRector\Fixture;
6+
7+
use Rector\Symfony\Tests\CodeQuality\Rector\Class_\ControllerMethodInjectionToConstructorRector\Source\SomeUser;
8+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
9+
use Symfony\Component\Routing\Annotation\Route;
10+
11+
final class SkipUserImplementsUserInterface extends AbstractController
12+
{
13+
#[Route('/some-action', name: 'some_action')]
14+
public function someAction(SomeUser $user)
15+
{
16+
}
17+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\Symfony\Tests\CodeQuality\Rector\Class_\ControllerMethodInjectionToConstructorRector\Source;
6+
7+
use Symfony\Component\Security\Core\User\UserInterface;
8+
9+
class SomeUser implements UserInterface
10+
{
11+
}

rules/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ public function refactor(Node $node): ?Node
164164
continue;
165165
}
166166

167+
if ($this->isObjectType($param->type, new ObjectType(SymfonyClass::USER_INTERFACE))) {
168+
continue;
169+
}
170+
167171
foreach (self::COMMON_ENTITY_CONTAINS_SUBNAMESPACES as $commonEntityContainsNamespace) {
168172
if (str_contains($this->getName($param->type), $commonEntityContainsNamespace)) {
169173
continue 2;

0 commit comments

Comments
 (0)