Updated Rector to commit 15bc1157be538b34bf81428997ef2aab5b974336

15bc1157be [phpstan] cleanup fixed errors
This commit is contained in:
Tomas Votruba 2023-10-01 11:35:14 +00:00
parent eb54ca1e35
commit fd3e7ba154
4 changed files with 43 additions and 25 deletions

View File

@ -1879,12 +1879,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "d74f7788d3b0783c38964cffb27d49a478f7f66c"
"reference": "4a37795a25c49493eccf790ad2914697d7935224"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/d74f7788d3b0783c38964cffb27d49a478f7f66c",
"reference": "d74f7788d3b0783c38964cffb27d49a478f7f66c",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/4a37795a25c49493eccf790ad2914697d7935224",
"reference": "4a37795a25c49493eccf790ad2914697d7935224",
"shasum": ""
},
"require": {
@ -1917,7 +1917,7 @@
"tomasvotruba\/unused-public": "^0.2",
"tracy\/tracy": "^2.10"
},
"time": "2023-09-30T19:52:56+00:00",
"time": "2023-10-01T11:29:05+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main a846e7f'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 850b492'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main 383d079'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main d74f778'));
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main a846e7f'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 850b492'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main 383d079'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 4a37795'));
private function __construct()
{
}

View File

@ -10,6 +10,7 @@ use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
use Rector\BetterPhpDocParser\PhpDoc\StringNode;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover;
use Rector\BetterPhpDocParser\PhpDocNodeFinder\PhpDocNodeByTypeFinder;
use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode;
use Rector\Comments\NodeDocBlock\DocBlockUpdater;
use Rector\Core\Rector\AbstractRector;
@ -40,11 +41,17 @@ final class MergeMethodAnnotationToRouteAnnotationRector extends AbstractRector
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
*/
private $phpDocInfoFactory;
public function __construct(PhpDocTagRemover $phpDocTagRemover, DocBlockUpdater $docBlockUpdater, PhpDocInfoFactory $phpDocInfoFactory)
/**
* @readonly
* @var \Rector\BetterPhpDocParser\PhpDocNodeFinder\PhpDocNodeByTypeFinder
*/
private $phpDocNodeByTypeFinder;
public function __construct(PhpDocTagRemover $phpDocTagRemover, DocBlockUpdater $docBlockUpdater, PhpDocInfoFactory $phpDocInfoFactory, PhpDocNodeByTypeFinder $phpDocNodeByTypeFinder)
{
$this->phpDocTagRemover = $phpDocTagRemover;
$this->docBlockUpdater = $docBlockUpdater;
$this->phpDocInfoFactory = $phpDocInfoFactory;
$this->phpDocNodeByTypeFinder = $phpDocNodeByTypeFinder;
}
public function getRuleDefinition() : RuleDefinition
{
@ -100,23 +107,17 @@ CODE_SAMPLE
if (!$sensioDoctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
continue;
}
$symfonyDoctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass(SymfonyAnnotation::ROUTE);
if (!$symfonyDoctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
// get all routes
$symfonyDoctrineAnnotationTagValueNodes = $this->phpDocNodeByTypeFinder->findDoctrineAnnotationsByClass($phpDocInfo->getPhpDocNode(), SymfonyAnnotation::ROUTE);
// no symfony route? skip it
if ($symfonyDoctrineAnnotationTagValueNodes === []) {
continue;
}
$sensioMethods = $this->resolveMethods($sensioDoctrineAnnotationTagValueNode);
if ($sensioMethods === null) {
$sensioMethodsCurlyListNode = $this->resolveMethodsCurlyListNode($sensioDoctrineAnnotationTagValueNode);
if (!$sensioMethodsCurlyListNode instanceof CurlyListNode) {
continue;
}
if (\is_string($sensioMethods) || $sensioMethods instanceof StringNode) {
$sensioMethods = new CurlyListNode([new ArrayItemNode($sensioMethods)]);
}
$symfonyMethodsArrayItemNode = $symfonyDoctrineAnnotationTagValueNode->getValue('methods');
// value is already filled, do not enter anything
if ($symfonyMethodsArrayItemNode instanceof ArrayItemNode) {
continue;
}
$symfonyDoctrineAnnotationTagValueNode->values[] = new ArrayItemNode($sensioMethods, 'methods');
$this->decorateRoutesWithMethods($symfonyDoctrineAnnotationTagValueNodes, $sensioMethodsCurlyListNode);
$this->phpDocTagRemover->removeTagValueFromNode($phpDocInfo, $sensioDoctrineAnnotationTagValueNode);
$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($classMethod);
$hasChanged = \true;
@ -126,19 +127,36 @@ CODE_SAMPLE
}
return null;
}
/**
* @return string|string[]|null|CurlyListNode|StringNode
*/
private function resolveMethods(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode)
private function resolveMethodsCurlyListNode(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : ?\Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode
{
$methodsParameter = $doctrineAnnotationTagValueNode->getValue('methods');
if ($methodsParameter instanceof ArrayItemNode && $methodsParameter->value instanceof CurlyListNode) {
return $methodsParameter->value;
}
$arrayItemNode = $doctrineAnnotationTagValueNode->getSilentValue();
if ($arrayItemNode instanceof ArrayItemNode) {
if (!$arrayItemNode instanceof ArrayItemNode) {
return null;
}
if ($arrayItemNode->value instanceof CurlyListNode) {
return $arrayItemNode->value;
}
if ($arrayItemNode->value instanceof StringNode) {
return new CurlyListNode([new ArrayItemNode($arrayItemNode->value)]);
}
return null;
}
/**
* @param DoctrineAnnotationTagValueNode[] $symfonyDoctrineAnnotationTagValueNodes
*/
private function decorateRoutesWithMethods(array $symfonyDoctrineAnnotationTagValueNodes, CurlyListNode $sensioMethodsCurlyListNode) : void
{
foreach ($symfonyDoctrineAnnotationTagValueNodes as $symfonyDoctrineAnnotationTagValueNode) {
$symfonyMethodsArrayItemNode = $symfonyDoctrineAnnotationTagValueNode->getValue('methods');
// value is already filled, do not enter anything
if ($symfonyMethodsArrayItemNode instanceof ArrayItemNode) {
continue;
}
$symfonyDoctrineAnnotationTagValueNode->values[] = new ArrayItemNode($sensioMethodsCurlyListNode, 'methods');
}
}
}