Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Rector\Symfony\Tests\CodeQuality\Rector\Class_\ControllerMethodInjectionToConstructorRector\Fixture;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

final class SkipFromRoutePath extends AbstractController
{
#[Route(path: '/edit/{id}', name: 'edit')]
public function someAction(Request $request, ?string $id = null)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\Doctrine\NodeAnalyzer\AttributeFinder;
Expand Down Expand Up @@ -117,19 +117,17 @@ public function refactor(Node $node): ?Node

foreach ($classMethod->getParams() as $key => $param) {
// skip scalar and empty values, as not services
if ($param->type === null || $param->type instanceof Identifier) {
if ($param->type === null || ! $param->type instanceof FullyQualified) {
continue;
}

// request is allowed
if ($param->type instanceof Name) {
if ($this->isName($param->type, SymfonyClass::REQUEST)) {
continue;
}
if ($this->isName($param->type, SymfonyClass::REQUEST)) {
continue;
}

if ($this->isNames($param->type, $entityClasses)) {
continue;
}
if ($this->isNames($param->type, $entityClasses)) {
continue;
}

// @todo allow parameter converter
Expand Down