Updated Rector to commit 76dc886f7a7f13fbed51e102ce4b616106f42702

76dc886f7a Cleanup, re-use AttributeName enums (#2792)
This commit is contained in:
Tomas Votruba 2022-08-19 07:49:30 +00:00
parent 5150f80d61
commit f177e0c3dd
11 changed files with 36 additions and 55 deletions

View File

@ -40,18 +40,6 @@ final class DoctrineAnnotationTagValueNode extends AbstractValuesAwareNode
$itemContents = $this->printValuesContent($this->values);
return \sprintf('(%s)', $itemContents);
}
/**
* @param string[] $classNames
*/
public function hasClassNames(array $classNames) : bool
{
foreach ($classNames as $className) {
if ($this->hasClassName($className)) {
return \true;
}
}
return \false;
}
public function hasClassName(string $className) : bool
{
$annotationName = \trim($this->identifierTypeNode->name, '@');

View File

@ -17,6 +17,7 @@ use Rector\Compatibility\NodeFactory\ConstructorClassMethodFactory;
use Rector\Compatibility\ValueObject\PropertyWithPhpDocInfo;
use Rector\Core\Rector\AbstractRector;
use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer;
use Rector\Php81\Enum\AttributeName;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -24,10 +25,6 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
*/
final class AttributeCompatibleAnnotationRector extends AbstractRector
{
/**
* @var string
*/
private const ATTRIBUTE = 'Attribute';
/**
* @readonly
* @var \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer
@ -140,7 +137,7 @@ CODE_SAMPLE
return \true;
}
// has attribute? skip it
return $this->phpAttributeAnalyzer->hasPhpAttribute($class, self::ATTRIBUTE);
return $this->phpAttributeAnalyzer->hasPhpAttribute($class, AttributeName::ATTRIBUTE);
}
/**
* @param PropertyWithPhpDocInfo[] $requiredPropertiesWithPhpDocInfos

View File

@ -18,6 +18,7 @@ use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\Php80\NodeAnalyzer\AnnotationTargetResolver;
use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer;
use Rector\Php80\NodeFactory\AttributeFlagFactory;
use Rector\Php81\Enum\AttributeName;
use Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory;
use Rector\PostRector\Collector\PropertyToAddCollector;
use Rector\PostRector\ValueObject\PropertyMetadata;
@ -40,10 +41,6 @@ final class DoctrineAnnotationClassToAttributeRector extends AbstractRector impl
* @var string
*/
public const REMOVE_ANNOTATIONS = 'remove_annotations';
/**
* @var string
*/
private const ATTRIBUTE = 'Attribute';
/**
* @var bool
*/
@ -137,7 +134,7 @@ CODE_SAMPLE
$this->phpDocTagRemover->removeByName($phpDocInfo, 'annotation');
$this->phpDocTagRemover->removeByName($phpDocInfo, 'Annotation');
}
$attributeGroup = $this->phpAttributeGroupFactory->createFromClass(self::ATTRIBUTE);
$attributeGroup = $this->phpAttributeGroupFactory->createFromClass(AttributeName::ATTRIBUTE);
$this->decorateTarget($phpDocInfo, $attributeGroup);
foreach ($node->getProperties() as $property) {
$propertyPhpDocInfo = $this->phpDocInfoFactory->createFromNode($property);
@ -201,6 +198,6 @@ CODE_SAMPLE
return \true;
}
// has attribute? skip it
return $this->phpAttributeAnalyzer->hasPhpAttribute($class, self::ATTRIBUTE);
return $this->phpAttributeAnalyzer->hasPhpAttribute($class, AttributeName::ATTRIBUTE);
}
}

View File

@ -11,4 +11,12 @@ final class AttributeName
* @var string
*/
public const RETURN_TYPE_WILL_CHANGE = 'ReturnTypeWillChange';
/**
* @var string
*/
public const ATTRIBUTE = 'Attribute';
/**
* @var string
*/
public const ALLOW_DYNAMIC_PROPERTIES = 'AllowDynamicProperties';
}

View File

@ -14,6 +14,7 @@ use Rector\Core\ValueObject\MethodName;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\Core\ValueObject\Visibility;
use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer;
use Rector\Php81\Enum\AttributeName;
use Rector\Privatization\NodeManipulator\VisibilityManipulator;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
@ -25,10 +26,6 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
*/
final class ReadOnlyClassRector extends AbstractRector implements MinPhpVersionInterface
{
/**
* @var string
*/
private const ATTRIBUTE = 'AllowDynamicProperties';
/**
* @readonly
* @var \Rector\Core\NodeAnalyzer\ClassAnalyzer
@ -154,7 +151,7 @@ CODE_SAMPLE
if (!$class->isFinal()) {
return \true;
}
return $this->phpAttributeAnalyzer->hasPhpAttribute($class, self::ATTRIBUTE);
return $this->phpAttributeAnalyzer->hasPhpAttribute($class, AttributeName::ALLOW_DYNAMIC_PROPERTIES);
}
/**
* @param Param[] $params

View File

@ -13,6 +13,7 @@ use Rector\Core\ValueObject\MethodName;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer;
use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer;
use Rector\Php81\Enum\AttributeName;
use Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
@ -25,10 +26,6 @@ use RectorPrefix202208\Webmozart\Assert\Assert;
*/
final class AddAllowDynamicPropertiesAttributeRector extends AbstractRector implements AllowEmptyConfigurableRectorInterface, MinPhpVersionInterface
{
/**
* @var string
*/
private const ATTRIBUTE = 'AllowDynamicProperties';
/**
* @var array<array-key, string>
*/
@ -116,18 +113,18 @@ CODE_SAMPLE
}
private function hasNeededAttributeAlready(Class_ $class) : bool
{
$nodeHasAttribute = $this->phpAttributeAnalyzer->hasPhpAttribute($class, self::ATTRIBUTE);
$nodeHasAttribute = $this->phpAttributeAnalyzer->hasPhpAttribute($class, AttributeName::ALLOW_DYNAMIC_PROPERTIES);
if ($nodeHasAttribute) {
return \true;
}
if (!$class->extends instanceof FullyQualified) {
return \false;
}
return $this->phpAttributeAnalyzer->hasInheritedPhpAttribute($class, self::ATTRIBUTE);
return $this->phpAttributeAnalyzer->hasInheritedPhpAttribute($class, AttributeName::ALLOW_DYNAMIC_PROPERTIES);
}
private function addAllowDynamicPropertiesAttribute(Class_ $class) : Class_
{
$class->attrGroups[] = $this->phpAttributeGroupFactory->createFromClass(self::ATTRIBUTE);
$class->attrGroups[] = $this->phpAttributeGroupFactory->createFromClass(AttributeName::ALLOW_DYNAMIC_PROPERTIES);
return $class;
}
private function shouldSkip(Class_ $class) : bool

View File

@ -8,6 +8,7 @@ use PhpParser\Node\Stmt\Class_;
use Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer;
use Rector\Php81\Enum\AttributeName;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
use RectorPrefix202208\Webmozart\Assert\Assert;
@ -18,10 +19,6 @@ use RectorPrefix202208\Webmozart\Assert\Assert;
*/
final class RemoveAllowDynamicPropertiesAttributeRector extends AbstractRector implements AllowEmptyConfigurableRectorInterface
{
/**
* @var string
*/
private const ATTRIBUTE = 'AllowDynamicProperties';
/**
* @var array<array-key, string>
*/
@ -83,7 +80,7 @@ CODE_SAMPLE
foreach ($class->attrGroups as $attrGroup) {
$newAttrs = [];
foreach ($attrGroup->attrs as $attribute) {
if (!$this->nodeNameResolver->isName($attribute, self::ATTRIBUTE)) {
if (!$this->nodeNameResolver->isName($attribute, AttributeName::ALLOW_DYNAMIC_PROPERTIES)) {
$newAttrs[] = $attribute;
}
}
@ -105,6 +102,6 @@ CODE_SAMPLE
}
}
}
return $this->phpAttributeAnalyzer->hasPhpAttribute($class, self::ATTRIBUTE);
return $this->phpAttributeAnalyzer->hasPhpAttribute($class, AttributeName::ALLOW_DYNAMIC_PROPERTIES);
}
}

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'fc8efa0fe446dd648d5d4d393e32ee06a8876837';
public const PACKAGE_VERSION = '76dc886f7a7f13fbed51e102ce4b616106f42702';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-08-19 09:18:16';
public const RELEASE_DATE = '2022-08-19 07:45:32';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit9b88e2fade2c989a43020703f0872c92::getLoader();
return ComposerAutoloaderInitd09c83098b54286960e859382fa042bb::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit9b88e2fade2c989a43020703f0872c92
class ComposerAutoloaderInitd09c83098b54286960e859382fa042bb
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit9b88e2fade2c989a43020703f0872c92
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit9b88e2fade2c989a43020703f0872c92', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitd09c83098b54286960e859382fa042bb', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit9b88e2fade2c989a43020703f0872c92', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitd09c83098b54286960e859382fa042bb', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit9b88e2fade2c989a43020703f0872c92::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitd09c83098b54286960e859382fa042bb::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit9b88e2fade2c989a43020703f0872c92::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInitd09c83098b54286960e859382fa042bb::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire9b88e2fade2c989a43020703f0872c92($fileIdentifier, $file);
composerRequired09c83098b54286960e859382fa042bb($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit9b88e2fade2c989a43020703f0872c92
* @param string $file
* @return void
*/
function composerRequire9b88e2fade2c989a43020703f0872c92($fileIdentifier, $file)
function composerRequired09c83098b54286960e859382fa042bb($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit9b88e2fade2c989a43020703f0872c92
class ComposerStaticInitd09c83098b54286960e859382fa042bb
{
public static $files = array (
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
@ -3252,9 +3252,9 @@ class ComposerStaticInit9b88e2fade2c989a43020703f0872c92
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit9b88e2fade2c989a43020703f0872c92::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit9b88e2fade2c989a43020703f0872c92::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit9b88e2fade2c989a43020703f0872c92::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitd09c83098b54286960e859382fa042bb::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitd09c83098b54286960e859382fa042bb::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitd09c83098b54286960e859382fa042bb::$classMap;
}, null, ClassLoader::class);
}