Merge pull request #1129 from rectorphp/nts-route-fix

[NetteToSymfony] Fix new route for already present annotation above method
This commit is contained in:
Tomáš Votruba 2019-02-27 21:09:18 +01:00 committed by GitHub
commit a77d4618f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 9 deletions

View File

@ -3,18 +3,23 @@
namespace Rector\NetteToSymfony\Annotation;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use Symplify\BetterPhpDocParser\Attributes\Attribute\AttributeTrait;
use Symplify\BetterPhpDocParser\Attributes\Contract\Ast\AttributeAwareNodeInterface;
final class RouteTagValueNode implements PhpDocChildNode
final class SymfonyRoutePhpDocTagNode extends PhpDocTagNode implements PhpDocChildNode, AttributeAwareNodeInterface
{
/**
* @var string
*/
private $path;
use AttributeTrait;
/**
* @var string|null
*/
private $name;
public $name;
/**
* @var string
*/
private $path;
/**
* @var string

View File

@ -9,7 +9,7 @@ use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\NetteToSymfony\Annotation\RouteTagValueNode;
use Rector\NetteToSymfony\Annotation\SymfonyRoutePhpDocTagNode;
use Rector\NetteToSymfony\Route\RouteInfo;
use Rector\NetteToSymfony\Route\RouteInfoFactory;
use Rector\NodeTypeResolver\Application\ClassLikeNodeCollector;
@ -192,7 +192,7 @@ CODE_SAMPLE
continue;
}
$phpDocTagNode = new RouteTagValueNode(
$phpDocTagNode = new SymfonyRoutePhpDocTagNode(
$this->routeAnnotationClass,
$routeInfo->getPath(),
null,
@ -283,7 +283,7 @@ CODE_SAMPLE
/** @var ClassMethod $classStmt */
$path = $this->resolvePathFromClassAndMethodNodes($presenterClass, $classStmt);
$phpDocTagNode = new RouteTagValueNode($this->routeAnnotationClass, $path);
$phpDocTagNode = new SymfonyRoutePhpDocTagNode($this->routeAnnotationClass, $path);
$this->docBlockAnalyzer->addTag($classStmt, $phpDocTagNode);
}

View File

@ -19,6 +19,9 @@ final class WithParameterRouterFactory
final class WithParameterSomePresenter
{
/**
* @todo
*/
public function run()
{
}
@ -46,6 +49,7 @@ final class WithParameterRouterFactory
final class WithParameterSomePresenter
{
/**
* @todo
* @\Symfony\Component\Routing\Annotation\Route(path="some-path/{id}")
*/
public function run()

View File

@ -128,3 +128,5 @@ parameters:
- '#Parameter \#2 \$constFetch of method Rector\\CodeQuality\\Rector\\Identical\\SimplifyArraySearchRector\:\:resolveIsNot\(\) expects PhpParser\\Node\\Expr\\ConstFetch, PhpParser\\Node given#'
- '#Parameter \#1 \$binaryOp of method Rector\\CodeQuality\\Rector\\Identical\\SimplifyConditionsRector\:\:createInversedBooleanOp\(\) expects PhpParser\\Node\\Expr\\BinaryOp, PhpParser\\Node given#'
- '#Parameter \#2 \$classMethod of method Rector\\NetteToSymfony\\Rector\\ClassMethod\\RouterListToControllerAnnotationsRector\:\:resolvePathFromClassAndMethodNodes\(\) expects PhpParser\\Node\\Stmt\\ClassMethod, PhpParser\\Node\\Stmt given#'
- '#Rector\\NetteToSymfony\\Annotation\\SymfonyRoutePhpDocTagNode\:\:__construct\(\) does not call parent constructor from PHPStan\\PhpDocParser\\Ast\\PhpDoc\\PhpDocTagNode#'