Updated Rector to commit f2822532dd

f2822532dd Cleanup (#354)
This commit is contained in:
Tomas Votruba 2021-07-01 15:49:49 +00:00
parent 95050e7bf5
commit 1cea5467e7
8 changed files with 131 additions and 19 deletions

View File

@ -0,0 +1,78 @@
<?php
declare (strict_types=1);
namespace Rector\Php80\PhpDocNodeVisitor;
use PHPStan\PhpDocParser\Ast\Node;
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
use Rector\BetterPhpDocParser\PhpDocNodeFinder\DoctrineAnnotationMatcher;
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Php80\ValueObject\AnnotationToAttribute;
use Rector\Php80\ValueObject\DoctrineTagAndAnnotationToAttribute;
use RectorPrefix20210701\Symplify\SimplePhpDocParser\PhpDocNodeTraverser;
use RectorPrefix20210701\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
final class AnnotationToAttributePhpDocNodeVisitor extends \RectorPrefix20210701\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor
{
/**
* @var AnnotationToAttribute[]
*/
private $annotationsToAttributes = [];
/**
* @var DoctrineTagAndAnnotationToAttribute[]
*/
private $doctrineTagAndAnnotationToAttributes = [];
/**
* @var \Rector\BetterPhpDocParser\PhpDocNodeFinder\DoctrineAnnotationMatcher
*/
private $doctrineAnnotationMatcher;
public function __construct(\Rector\BetterPhpDocParser\PhpDocNodeFinder\DoctrineAnnotationMatcher $doctrineAnnotationMatcher)
{
$this->doctrineAnnotationMatcher = $doctrineAnnotationMatcher;
}
/**
* @param AnnotationToAttribute[] $annotationsToAttributes
*/
public function configureAnnotationsToAttributes(array $annotationsToAttributes) : void
{
$this->annotationsToAttributes = $annotationsToAttributes;
}
public function beforeTraverse(\PHPStan\PhpDocParser\Ast\Node $node) : void
{
$this->doctrineTagAndAnnotationToAttributes = [];
if ($this->annotationsToAttributes !== []) {
return;
}
throw new \Rector\Core\Exception\ShouldNotHappenException('Configure annotations to attributes via "configureAnnotationsToAttributes()" method first');
}
/**
* @return int|\PHPStan\PhpDocParser\Ast\Node|null
*/
public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node)
{
if (!$node instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
return $node;
}
foreach ($this->annotationsToAttributes as $annotationToAttribute) {
if (!$this->doctrineAnnotationMatcher->matches($node, $annotationToAttribute->getTag())) {
continue;
}
$this->doctrineTagAndAnnotationToAttributes[] = new \Rector\Php80\ValueObject\DoctrineTagAndAnnotationToAttribute($node, $annotationToAttribute);
$parentNode = $node->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::PARENT);
if ($parentNode instanceof \PHPStan\PhpDocParser\Ast\Node) {
// invoke re-print
$parentNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE, null);
}
// remove the original doctrine annotation, it becomes an attribute
return \RectorPrefix20210701\Symplify\SimplePhpDocParser\PhpDocNodeTraverser::NODE_REMOVE;
}
return $node;
}
/**
* @return DoctrineTagAndAnnotationToAttribute[]
*/
public function provideFound() : array
{
return $this->doctrineTagAndAnnotationToAttributes;
}
}

View File

@ -0,0 +1,30 @@
<?php
declare (strict_types=1);
namespace Rector\Php80\ValueObject;
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
final class DoctrineTagAndAnnotationToAttribute
{
/**
* @var \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode
*/
private $doctrineAnnotationTagValueNode;
/**
* @var \Rector\Php80\ValueObject\AnnotationToAttribute
*/
private $annotationToAttribute;
public function __construct(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, \Rector\Php80\ValueObject\AnnotationToAttribute $annotationToAttribute)
{
$this->doctrineAnnotationTagValueNode = $doctrineAnnotationTagValueNode;
$this->annotationToAttribute = $annotationToAttribute;
}
public function getDoctrineAnnotationTagValueNode() : \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode
{
return $this->doctrineAnnotationTagValueNode;
}
public function getAnnotationToAttribute() : \Rector\Php80\ValueObject\AnnotationToAttribute
{
return $this->annotationToAttribute;
}
}

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '7c88f7c814a9731b01e6ac1896daa981c50890de';
public const PACKAGE_VERSION = 'f2822532dd4ac00a7e3a9f7002107fe5353c79b7';
/**
* @var string
*/
public const RELEASE_DATE = '2021-07-01 14:33:18';
public const RELEASE_DATE = '2021-07-01 17:37:11';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20210701\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit4f55e3728435ecf404229bd8139abf22::getLoader();
return ComposerAutoloaderInit3d7f6d8a1338c503d8530ac877d072f4::getLoader();

View File

@ -2733,6 +2733,7 @@ return array(
'Rector\\Php80\\NodeResolver\\ArgumentSorter' => $baseDir . '/rules/Php80/NodeResolver/ArgumentSorter.php',
'Rector\\Php80\\NodeResolver\\RequireOptionalParamResolver' => $baseDir . '/rules/Php80/NodeResolver/RequireOptionalParamResolver.php',
'Rector\\Php80\\NodeResolver\\SwitchExprsResolver' => $baseDir . '/rules/Php80/NodeResolver/SwitchExprsResolver.php',
'Rector\\Php80\\PhpDocNodeVisitor\\AnnotationToAttributePhpDocNodeVisitor' => $baseDir . '/rules/Php80/PhpDocNodeVisitor/AnnotationToAttributePhpDocNodeVisitor.php',
'Rector\\Php80\\Rector\\Catch_\\RemoveUnusedVariableInCatchRector' => $baseDir . '/rules/Php80/Rector/Catch_/RemoveUnusedVariableInCatchRector.php',
'Rector\\Php80\\Rector\\ClassMethod\\FinalPrivateToPrivateVisibilityRector' => $baseDir . '/rules/Php80/Rector/ClassMethod/FinalPrivateToPrivateVisibilityRector.php',
'Rector\\Php80\\Rector\\ClassMethod\\OptionalParametersAfterRequiredRector' => $baseDir . '/rules/Php80/Rector/ClassMethod/OptionalParametersAfterRequiredRector.php',
@ -2754,6 +2755,7 @@ return array(
'Rector\\Php80\\ValueObject\\AnnotationToAttribute' => $baseDir . '/rules/Php80/ValueObject/AnnotationToAttribute.php',
'Rector\\Php80\\ValueObject\\ArrayDimFetchAndConstFetch' => $baseDir . '/rules/Php80/ValueObject/ArrayDimFetchAndConstFetch.php',
'Rector\\Php80\\ValueObject\\CondAndExpr' => $baseDir . '/rules/Php80/ValueObject/CondAndExpr.php',
'Rector\\Php80\\ValueObject\\DoctrineTagAndAnnotationToAttribute' => $baseDir . '/rules/Php80/ValueObject/DoctrineTagAndAnnotationToAttribute.php',
'Rector\\Php80\\ValueObject\\PropertyPromotionCandidate' => $baseDir . '/rules/Php80/ValueObject/PropertyPromotionCandidate.php',
'Rector\\Php80\\ValueObject\\StrStartsWith' => $baseDir . '/rules/Php80/ValueObject/StrStartsWith.php',
'Rector\\Php81\\NodeFactory\\EnumFactory' => $baseDir . '/rules/Php81/NodeFactory/EnumFactory.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit4f55e3728435ecf404229bd8139abf22
class ComposerAutoloaderInit3d7f6d8a1338c503d8530ac877d072f4
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit4f55e3728435ecf404229bd8139abf22
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit4f55e3728435ecf404229bd8139abf22', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit3d7f6d8a1338c503d8530ac877d072f4', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit4f55e3728435ecf404229bd8139abf22', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit3d7f6d8a1338c503d8530ac877d072f4', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit4f55e3728435ecf404229bd8139abf22::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit3d7f6d8a1338c503d8530ac877d072f4::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInit4f55e3728435ecf404229bd8139abf22
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit4f55e3728435ecf404229bd8139abf22::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit3d7f6d8a1338c503d8530ac877d072f4::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire4f55e3728435ecf404229bd8139abf22($fileIdentifier, $file);
composerRequire3d7f6d8a1338c503d8530ac877d072f4($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire4f55e3728435ecf404229bd8139abf22($fileIdentifier, $file)
function composerRequire3d7f6d8a1338c503d8530ac877d072f4($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit4f55e3728435ecf404229bd8139abf22
class ComposerStaticInit3d7f6d8a1338c503d8530ac877d072f4
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -3088,6 +3088,7 @@ class ComposerStaticInit4f55e3728435ecf404229bd8139abf22
'Rector\\Php80\\NodeResolver\\ArgumentSorter' => __DIR__ . '/../..' . '/rules/Php80/NodeResolver/ArgumentSorter.php',
'Rector\\Php80\\NodeResolver\\RequireOptionalParamResolver' => __DIR__ . '/../..' . '/rules/Php80/NodeResolver/RequireOptionalParamResolver.php',
'Rector\\Php80\\NodeResolver\\SwitchExprsResolver' => __DIR__ . '/../..' . '/rules/Php80/NodeResolver/SwitchExprsResolver.php',
'Rector\\Php80\\PhpDocNodeVisitor\\AnnotationToAttributePhpDocNodeVisitor' => __DIR__ . '/../..' . '/rules/Php80/PhpDocNodeVisitor/AnnotationToAttributePhpDocNodeVisitor.php',
'Rector\\Php80\\Rector\\Catch_\\RemoveUnusedVariableInCatchRector' => __DIR__ . '/../..' . '/rules/Php80/Rector/Catch_/RemoveUnusedVariableInCatchRector.php',
'Rector\\Php80\\Rector\\ClassMethod\\FinalPrivateToPrivateVisibilityRector' => __DIR__ . '/../..' . '/rules/Php80/Rector/ClassMethod/FinalPrivateToPrivateVisibilityRector.php',
'Rector\\Php80\\Rector\\ClassMethod\\OptionalParametersAfterRequiredRector' => __DIR__ . '/../..' . '/rules/Php80/Rector/ClassMethod/OptionalParametersAfterRequiredRector.php',
@ -3109,6 +3110,7 @@ class ComposerStaticInit4f55e3728435ecf404229bd8139abf22
'Rector\\Php80\\ValueObject\\AnnotationToAttribute' => __DIR__ . '/../..' . '/rules/Php80/ValueObject/AnnotationToAttribute.php',
'Rector\\Php80\\ValueObject\\ArrayDimFetchAndConstFetch' => __DIR__ . '/../..' . '/rules/Php80/ValueObject/ArrayDimFetchAndConstFetch.php',
'Rector\\Php80\\ValueObject\\CondAndExpr' => __DIR__ . '/../..' . '/rules/Php80/ValueObject/CondAndExpr.php',
'Rector\\Php80\\ValueObject\\DoctrineTagAndAnnotationToAttribute' => __DIR__ . '/../..' . '/rules/Php80/ValueObject/DoctrineTagAndAnnotationToAttribute.php',
'Rector\\Php80\\ValueObject\\PropertyPromotionCandidate' => __DIR__ . '/../..' . '/rules/Php80/ValueObject/PropertyPromotionCandidate.php',
'Rector\\Php80\\ValueObject\\StrStartsWith' => __DIR__ . '/../..' . '/rules/Php80/ValueObject/StrStartsWith.php',
'Rector\\Php81\\NodeFactory\\EnumFactory' => __DIR__ . '/../..' . '/rules/Php81/NodeFactory/EnumFactory.php',
@ -3843,9 +3845,9 @@ class ComposerStaticInit4f55e3728435ecf404229bd8139abf22
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit4f55e3728435ecf404229bd8139abf22::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit4f55e3728435ecf404229bd8139abf22::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit4f55e3728435ecf404229bd8139abf22::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit3d7f6d8a1338c503d8530ac877d072f4::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit3d7f6d8a1338c503d8530ac877d072f4::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit3d7f6d8a1338c503d8530ac877d072f4::$classMap;
}, null, ClassLoader::class);
}

View File

@ -21,8 +21,8 @@ if (!class_exists('SomeTestCase', false) && !interface_exists('SomeTestCase', fa
if (!class_exists('CheckoutEntityFactory', false) && !interface_exists('CheckoutEntityFactory', false) && !trait_exists('CheckoutEntityFactory', false)) {
spl_autoload_call('RectorPrefix20210701\CheckoutEntityFactory');
}
if (!class_exists('ComposerAutoloaderInit4f55e3728435ecf404229bd8139abf22', false) && !interface_exists('ComposerAutoloaderInit4f55e3728435ecf404229bd8139abf22', false) && !trait_exists('ComposerAutoloaderInit4f55e3728435ecf404229bd8139abf22', false)) {
spl_autoload_call('RectorPrefix20210701\ComposerAutoloaderInit4f55e3728435ecf404229bd8139abf22');
if (!class_exists('ComposerAutoloaderInit3d7f6d8a1338c503d8530ac877d072f4', false) && !interface_exists('ComposerAutoloaderInit3d7f6d8a1338c503d8530ac877d072f4', false) && !trait_exists('ComposerAutoloaderInit3d7f6d8a1338c503d8530ac877d072f4', false)) {
spl_autoload_call('RectorPrefix20210701\ComposerAutoloaderInit3d7f6d8a1338c503d8530ac877d072f4');
}
if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) {
spl_autoload_call('RectorPrefix20210701\Doctrine\Inflector\Inflector');
@ -3320,9 +3320,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20210701\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire4f55e3728435ecf404229bd8139abf22')) {
function composerRequire4f55e3728435ecf404229bd8139abf22() {
return \RectorPrefix20210701\composerRequire4f55e3728435ecf404229bd8139abf22(...func_get_args());
if (!function_exists('composerRequire3d7f6d8a1338c503d8530ac877d072f4')) {
function composerRequire3d7f6d8a1338c503d8530ac877d072f4() {
return \RectorPrefix20210701\composerRequire3d7f6d8a1338c503d8530ac877d072f4(...func_get_args());
}
}
if (!function_exists('parseArgs')) {