mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
Merge pull request #1044 from rectorphp/route-list-wrapper
Fix param wrapper conversion in RouterListToControllerAnnotationsRector
This commit is contained in:
commit
2ea051674d
@ -89,6 +89,8 @@ final class RouteInfoFactory
|
||||
return null;
|
||||
}
|
||||
|
||||
$routePath = $this->normalizeArgumentWrappers($routePath);
|
||||
|
||||
$targetNode = $expr->args[1]->value;
|
||||
if ($targetNode instanceof ClassConstFetch) {
|
||||
/** @var ClassConstFetch $controllerMethodNode */
|
||||
@ -154,4 +156,9 @@ final class RouteInfoFactory
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function normalizeArgumentWrappers(string $routePath): string
|
||||
{
|
||||
return str_replace(['<', '>'], ['{', '}'], $routePath);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\NetteToSymfony\Tests\Rector\MethodCall\RouterListToControllerAnnotationsRetor\Fixture;
|
||||
|
||||
use Rector\NetteToSymfony\Tests\Rector\ClassMethod\RouterListToControllerAnnotationsRetor\Source\Route;
|
||||
use Rector\NetteToSymfony\Tests\Rector\ClassMethod\RouterListToControllerAnnotationsRetor\Source\RouteList;
|
||||
|
||||
final class WithParameterRouterFactory
|
||||
{
|
||||
public function create(): RouteList
|
||||
{
|
||||
$routeList = new RouteList();
|
||||
|
||||
$routeList[] = new Route('some-path/<id>', WithParameterSomePresenter::class);
|
||||
|
||||
return $routeList;
|
||||
}
|
||||
}
|
||||
|
||||
final class WithParameterSomePresenter
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\NetteToSymfony\Tests\Rector\MethodCall\RouterListToControllerAnnotationsRetor\Fixture;
|
||||
|
||||
use Rector\NetteToSymfony\Tests\Rector\ClassMethod\RouterListToControllerAnnotationsRetor\Source\Route;
|
||||
use Rector\NetteToSymfony\Tests\Rector\ClassMethod\RouterListToControllerAnnotationsRetor\Source\RouteList;
|
||||
|
||||
final class WithParameterRouterFactory
|
||||
{
|
||||
public function create(): RouteList
|
||||
{
|
||||
$routeList = new RouteList();
|
||||
|
||||
return $routeList;
|
||||
}
|
||||
}
|
||||
|
||||
final class WithParameterSomePresenter
|
||||
{
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="some-path/{id}")
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -7,7 +7,7 @@ use Rector\NetteToSymfony\Tests\Rector\ClassMethod\RouterListToControllerAnnotat
|
||||
use Rector\NetteToSymfony\Tests\Rector\ClassMethod\RouterListToControllerAnnotationsRetor\Source\RouteList;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
|
||||
final class RouterListToControllerAnnotationsRetorTest extends AbstractRectorTestCase
|
||||
final class RouterListToControllerAnnotationsRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
public function test(): void
|
||||
{
|
||||
@ -17,6 +17,7 @@ final class RouterListToControllerAnnotationsRetorTest extends AbstractRectorTes
|
||||
__DIR__ . '/Fixture/constant_reference_route_to_annotation.php.inc',
|
||||
__DIR__ . '/Fixture/method_named_routes.php.inc',
|
||||
__DIR__ . '/Fixture/general_method_named_routes.php.inc',
|
||||
__DIR__ . '/Fixture/with_parameter.php.inc',
|
||||
]);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user