mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 21:38:22 +01:00
fix for Template and Route annotatoin
This commit is contained in:
parent
da47c3145f
commit
de875ab00d
@ -40,18 +40,42 @@ final class SymfonyRouteTagValueNode extends AbstractTagValueNode
|
||||
*/
|
||||
private $isPathExplicit = true;
|
||||
|
||||
/**
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $options = [];
|
||||
|
||||
/**
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $defaults = [];
|
||||
|
||||
/**
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $requirements = [];
|
||||
|
||||
/**
|
||||
* @param string[] $methods
|
||||
* @param string[] $options
|
||||
* @param string[] $defaults
|
||||
* @param string[] $requirements
|
||||
*/
|
||||
public function __construct(
|
||||
string $path,
|
||||
?string $name = null,
|
||||
array $methods = [],
|
||||
array $options = [],
|
||||
array $defaults = [],
|
||||
array $requirements = [],
|
||||
?string $originalContent = null
|
||||
) {
|
||||
$this->path = $path;
|
||||
$this->name = $name;
|
||||
$this->methods = $methods;
|
||||
$this->options = $options;
|
||||
$this->defaults = $defaults;
|
||||
$this->requirements = $requirements;
|
||||
|
||||
if ($originalContent !== null) {
|
||||
$this->isPathExplicit = (bool) Strings::contains($originalContent, 'path=');
|
||||
@ -80,6 +104,18 @@ final class SymfonyRouteTagValueNode extends AbstractTagValueNode
|
||||
$contentItems['methods'] = $this->printArrayItem($this->methods, 'methods');
|
||||
}
|
||||
|
||||
if ($this->options) {
|
||||
$contentItems['options'] = $this->printArrayItem($this->options, 'options');
|
||||
}
|
||||
|
||||
if ($this->defaults) {
|
||||
$contentItems['defaults'] = $this->printArrayItem($this->defaults, 'defaults');
|
||||
}
|
||||
|
||||
if ($this->requirements) {
|
||||
$contentItems['requirements'] = $this->printArrayItem($this->requirements, 'requirements');
|
||||
}
|
||||
|
||||
return $this->printContentItems($contentItems);
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,9 @@ final class SymfonyRoutePhpDocNodeFactory extends AbstractPhpDocNodeFactory
|
||||
$route->getPath(),
|
||||
$route->getName(),
|
||||
$route->getMethods(),
|
||||
$route->getOptions(),
|
||||
$route->getDefaults(),
|
||||
$route->getRequirements(),
|
||||
$annotationContent
|
||||
);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ use Symfony\Component\Routing\Annotation\Route;
|
||||
class WithRouteOptions
|
||||
{
|
||||
/**
|
||||
* @Route("/{category}", name="report_overview", defaults={"category" = null}, requirements={"category" = "\d+"})
|
||||
* @Route("/{category}", name="report_overview", defaults={"category":null}, requirements={"category":"\d+"})
|
||||
* @Template("PAPPReportBundle:Report:report_list.html.twig")
|
||||
*/
|
||||
public function index($category = null)
|
||||
@ -31,7 +31,7 @@ use Symfony\Component\Routing\Annotation\Route;
|
||||
class WithRouteOptions
|
||||
{
|
||||
/**
|
||||
* @Route("/{category}", name="report_overview", defaults={"category" = null}, requirements={"category" = "\d+"})
|
||||
* @Route("/{category}", name="report_overview", defaults={"category":null}, requirements={"category":"\d+"})
|
||||
*/
|
||||
public function index($category = null)
|
||||
{
|
||||
|
0
packages/Sensio/tests/Rector/FrameworkExtraBundle/TemplateAnnotationRector/TemplateAnnotationVersion5RectorTest.php
Executable file → Normal file
0
packages/Sensio/tests/Rector/FrameworkExtraBundle/TemplateAnnotationRector/TemplateAnnotationVersion5RectorTest.php
Executable file → Normal file
Loading…
x
Reference in New Issue
Block a user