add sensio tag to one with = instead of :

This commit is contained in:
TomasVotruba 2020-06-08 17:06:58 +02:00
parent e35b506fd0
commit fa5319bf74
2 changed files with 10 additions and 4 deletions

View File

@ -12,6 +12,7 @@ use Rector\BetterPhpDocParser\Contract\Doctrine\DoctrineTagNodeInterface;
use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface;
use Rector\BetterPhpDocParser\Contract\PhpDocNode\SilentKeyNodeInterface;
use Rector\BetterPhpDocParser\Contract\PhpDocNode\TagAwareNodeInterface;
use Rector\BetterPhpDocParser\PhpDocNode\Sensio\SensioRouteTagValueNode;
use Rector\BetterPhpDocParser\PhpDocNode\Symfony\SymfonyRouteTagValueNode;
use Rector\BetterPhpDocParser\Utils\ArrayItemStaticHelper;
use Symfony\Component\Routing\Annotation\Route;
@ -151,7 +152,7 @@ abstract class AbstractTagValueNode implements AttributeAwareNodeInterface, PhpD
$json = Strings::replace($json, '#\\\\\\\\#', '\\');
// replace ":" with "=" for @Route
if ($this instanceof SymfonyRouteTagValueNode || $this instanceof DoctrineTagNodeInterface) {
if ($this instanceof SymfonyRouteTagValueNode || $this instanceof DoctrineTagNodeInterface || $this instanceof SensioRouteTagValueNode) {
// @see https://regex101.com/r/XfKi4A/1/
$json = Strings::replace($json, '#(\"|\w)\:(\"|\w)#', '$1=$2');
}

View File

@ -23,6 +23,11 @@ use Symplify\SmartFileSystem\SmartFileInfo;
final class NodeNameResolver
{
/**
* @var string
*/
public const FILE = 'file';
/**
* @var NodeNameResolverInterface[]
*/
@ -219,11 +224,11 @@ final class NodeNameResolver
if ($rectorBacktrace) {
// issues to find the file in prefixed
if (file_exists($rectorBacktrace['file'])) {
$fileInfo = new SmartFileInfo($rectorBacktrace['file']);
if (file_exists($rectorBacktrace[self::FILE])) {
$fileInfo = new SmartFileInfo($rectorBacktrace[self::FILE]);
$fileAndLine = $fileInfo->getRelativeFilePathFromCwd() . ':' . $rectorBacktrace['line'];
} else {
$fileAndLine = $rectorBacktrace['file'] . ':' . $rectorBacktrace['line'];
$fileAndLine = $rectorBacktrace[self::FILE] . ':' . $rectorBacktrace['line'];
}
$message .= PHP_EOL . PHP_EOL;