mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-07 11:50:51 +00:00
Updated Rector to commit 15bc1157be538b34bf81428997ef2aab5b974336
15bc1157be
[phpstan] cleanup fixed errors
This commit is contained in:
parent
eb54ca1e35
commit
fd3e7ba154
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
|
@ -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": {
|
||||
|
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
|
@ -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()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user