Skip to content

Commit 2eaafa0

Browse files
authored
Do not move Uuids into the constructor (#896)
1 parent 9775f3d commit 2eaafa0

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

Lines changed: 17 additions & 0 deletions
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 Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
8+
use Symfony\Component\Routing\Annotation\Route;
9+
use Symfony\Component\Uid\Uuid;
10+
11+
final class SkipUser extends AbstractController
12+
{
13+
#[Route('/some-action/{id}', name: 'some_action')]
14+
public function someAction(Uuid $id)
15+
{
16+
}
17+
}

rules/CodeQuality/Rector/Class_/ControllerMethodInjectionToConstructorRector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ public function refactor(Node $node): ?Node
146146
continue;
147147
}
148148

149-
// skip allowed known objectsallowed
149+
// skip allowed known objects
150150
if ($this->isNames(
151151
$param->type,
152-
[SymfonyClass::USER_INTERFACE, SymfonyClass::REQUEST, FosClass::PARAM_FETCHER, ...$entityClasses]
152+
[SymfonyClass::USER_INTERFACE, SymfonyClass::REQUEST, FosClass::PARAM_FETCHER, SymfonyClass::UUID, ...$entityClasses]
153153
)) {
154154
continue;
155155
}

src/Enum/SymfonyClass.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,9 @@ final class SymfonyClass
215215
* @var string
216216
*/
217217
public const USER_INTERFACE = 'Symfony\Component\Security\Core\User\UserInterface';
218+
219+
/**
220+
* @var string
221+
*/
222+
public const UUID = 'Symfony\Component\Uid\Uuid';
218223
}

0 commit comments

Comments
 (0)