Updated Rector to commit f4f758c7431f66bc97a019eb53055d05c15705c6

f4f758c743 Fix missing extra import on NestedAnnotationToAttributeRector (#2989)
This commit is contained in:
Tomas Votruba 2022-10-15 22:31:48 +00:00
parent 2c34505711
commit ee8ab57a67
17 changed files with 151 additions and 53 deletions

View File

@ -5897,16 +5897,21 @@ Changed nested annotations to attributes
```php
use Rector\Config\RectorConfig;
use Rector\Php80\Rector\Property\NestedAnnotationToAttributeRector;
use Rector\Php80\ValueObject\AnnotationPropertyToAttributeClass;
use Rector\Php80\ValueObject\NestedAnnotationToAttribute;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(
NestedAnnotationToAttributeRector::class,
[[
new NestedAnnotationToAttribute('Doctrine\ORM\Mapping\JoinTable', [
'Doctrine\ORM\Mapping\JoinColumn',
'Doctrine\ORM\Mapping\InverseJoinColumn',
], false),
new NestedAnnotationToAttribute([
new AnnotationPropertyToAttributeClass('Doctrine\ORM\Mapping\JoinColumn', 'joinColumns', false),
new AnnotationPropertyToAttributeClass(
'Doctrine\ORM\Mapping\InverseJoinColumn',
'inverseJoinColumns',
false
),
], 'Doctrine\ORM\Mapping\JoinTable', false),
]]
);
};

View File

@ -139,4 +139,8 @@ final class AttributeKey
* @var string
*/
public const REPRINT_RAW_VALUE = 'reprint_raw_value';
/**
* @var string
*/
public const EXTRA_USE_IMPORT = 'extra_use_import';
}

View File

@ -45,7 +45,7 @@ final class AttributeNameFactory
}
return new Name($useAliasMetadata->getShortAttributeName());
}
// 3. the class is not aliased and is compeltelly new... return the FQN version
// 3. the class is not aliased and is completely new... return the FQN version
return new FullyQualified($annotationToAttribute->getAttributeClass());
}
}

View File

@ -15,6 +15,8 @@ use Rector\BetterPhpDocParser\PhpDoc\ArrayItemNode;
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\Php80\ValueObject\AnnotationPropertyToAttributeClass;
use Rector\Php80\ValueObject\NestedAnnotationToAttribute;
use Rector\PhpAttribute\AnnotationToAttributeMapper;
use Rector\PhpAttribute\AttributeArrayNameInliner;
@ -81,7 +83,7 @@ final class PhpNestedAttributeGroupFactory
if ($nestedAnnotationToAttribute->hasExplicitParameters()) {
return $this->createFromExplicitProperties($nestedAnnotationToAttribute, $doctrineAnnotationTagValueNode);
}
$nestedAttributeClass = $nestedAnnotationToAttribute->getAnnotationPropertiesToAttributeClasses()[0];
$nestedAnnotationPropertyToAttributeClass = $nestedAnnotationToAttribute->getAnnotationPropertiesToAttributeClasses()[0];
foreach ($doctrineAnnotationTagValueNode->values as $arrayItemNode) {
$nestedDoctrineAnnotationTagValueNode = $arrayItemNode->value;
if (!$nestedDoctrineAnnotationTagValueNode instanceof CurlyListNode) {
@ -93,7 +95,7 @@ final class PhpNestedAttributeGroupFactory
}
$attributeArgs = $this->createAttributeArgs($nestedArrayItemNode->value, $nestedAnnotationToAttribute);
$originalIdentifier = $doctrineAnnotationTagValueNode->identifierTypeNode->name;
$attributeName = $this->resolveAliasedAttributeName($originalIdentifier, $nestedAttributeClass);
$attributeName = $this->resolveAliasedAttributeName($originalIdentifier, $nestedAnnotationPropertyToAttributeClass);
$attribute = new Attribute($attributeName, $attributeArgs);
$attributeGroups[] = new AttributeGroup([$attribute]);
}
@ -123,10 +125,10 @@ final class PhpNestedAttributeGroupFactory
* @todo improve this hardcoded approach later
* @return \PhpParser\Node\Name\FullyQualified|\PhpParser\Node\Name
*/
private function resolveAliasedAttributeName(string $originalIdentifier, string $nestedAttributeClass)
private function resolveAliasedAttributeName(string $originalIdentifier, AnnotationPropertyToAttributeClass $annotationPropertyToAttributeClass)
{
/** @var string $shortDoctrineAttributeName */
$shortDoctrineAttributeName = Strings::after($nestedAttributeClass, '\\', -1);
$shortDoctrineAttributeName = Strings::after($annotationPropertyToAttributeClass->getAttributeClass(), '\\', -1);
$matches = Strings::match($originalIdentifier, self::SHORT_ORM_ALIAS_REGEX);
if ($matches !== null) {
// or alias
@ -136,7 +138,7 @@ final class PhpNestedAttributeGroupFactory
if (\strpos($originalIdentifier, '\\') === \false) {
return new Name($shortDoctrineAttributeName);
}
return new FullyQualified($nestedAttributeClass);
return new FullyQualified($annotationPropertyToAttributeClass->getAttributeClass());
}
/**
* @param ArrayItemNode[] $arrayItemNodes
@ -144,9 +146,9 @@ final class PhpNestedAttributeGroupFactory
*/
private function removeItems(array $arrayItemNodes, NestedAnnotationToAttribute $nestedAnnotationToAttribute) : array
{
foreach (\array_keys($nestedAnnotationToAttribute->getAnnotationPropertiesToAttributeClasses()) as $itemToRemoveName) {
foreach ($nestedAnnotationToAttribute->getAnnotationPropertiesToAttributeClasses() as $annotationPropertyToAttributeClass) {
foreach ($arrayItemNodes as $key => $arrayItemNode) {
if ($arrayItemNode->key !== $itemToRemoveName) {
if ($arrayItemNode->key !== $annotationPropertyToAttributeClass->getAnnotationProperty()) {
continue;
}
unset($arrayItemNodes[$key]);
@ -160,8 +162,10 @@ final class PhpNestedAttributeGroupFactory
private function createFromExplicitProperties(NestedAnnotationToAttribute $nestedAnnotationToAttribute, DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : array
{
$attributeGroups = [];
foreach ($nestedAnnotationToAttribute->getAnnotationPropertiesToAttributeClasses() as $itemName => $nestedAttributeClass) {
$nestedArrayItemNode = $doctrineAnnotationTagValueNode->getValue($itemName);
foreach ($nestedAnnotationToAttribute->getAnnotationPropertiesToAttributeClasses() as $annotationPropertyToAttributeClass) {
/** @var string $annotationProperty */
$annotationProperty = $annotationPropertyToAttributeClass->getAnnotationProperty();
$nestedArrayItemNode = $doctrineAnnotationTagValueNode->getValue($annotationProperty);
if (!$nestedArrayItemNode instanceof ArrayItemNode) {
continue;
}
@ -175,7 +179,10 @@ final class PhpNestedAttributeGroupFactory
}
$attributeArgs = $this->createAttributeArgs($nestedDoctrineAnnotationTagValueNode, $nestedAnnotationToAttribute);
$originalIdentifier = $nestedDoctrineAnnotationTagValueNode->identifierTypeNode->name;
$attributeName = $this->resolveAliasedAttributeName($originalIdentifier, $nestedAttributeClass);
$attributeName = $this->resolveAliasedAttributeName($originalIdentifier, $annotationPropertyToAttributeClass);
if ($annotationPropertyToAttributeClass->doesNeedNewImport() && \count($attributeName->parts) === 1) {
$attributeName->setAttribute(AttributeKey::EXTRA_USE_IMPORT, $annotationPropertyToAttributeClass->getAttributeClass());
}
$attribute = new Attribute($attributeName, $attributeArgs);
$attributeGroups[] = new AttributeGroup([$attribute]);
}

View File

@ -16,9 +16,13 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Naming\Naming\UseImportsResolver;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\Php80\NodeFactory\NestedAttrGroupsFactory;
use Rector\Php80\ValueObject\AnnotationPropertyToAttributeClass;
use Rector\Php80\ValueObject\NestedAnnotationToAttribute;
use Rector\Php80\ValueObject\NestedDoctrineTagAndAnnotationToAttribute;
use Rector\PostRector\Collector\UseNodesToAddCollector;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@ -49,11 +53,17 @@ final class NestedAnnotationToAttributeRector extends AbstractRector implements
* @var \Rector\Php80\NodeFactory\NestedAttrGroupsFactory
*/
private $nestedAttrGroupsFactory;
public function __construct(UseImportsResolver $useImportsResolver, PhpDocTagRemover $phpDocTagRemover, NestedAttrGroupsFactory $nestedAttrGroupsFactory)
/**
* @readonly
* @var \Rector\PostRector\Collector\UseNodesToAddCollector
*/
private $useNodesToAddCollector;
public function __construct(UseImportsResolver $useImportsResolver, PhpDocTagRemover $phpDocTagRemover, NestedAttrGroupsFactory $nestedAttrGroupsFactory, UseNodesToAddCollector $useNodesToAddCollector)
{
$this->useImportsResolver = $useImportsResolver;
$this->phpDocTagRemover = $phpDocTagRemover;
$this->nestedAttrGroupsFactory = $nestedAttrGroupsFactory;
$this->useNodesToAddCollector = $useNodesToAddCollector;
}
public function getRuleDefinition() : RuleDefinition
{
@ -82,7 +92,7 @@ class SomeEntity
private $collection;
}
CODE_SAMPLE
, [[new NestedAnnotationToAttribute('Doctrine\\ORM\\Mapping\\JoinTable', ['joinColumns' => 'Doctrine\\ORM\\Mapping\\JoinColumn', 'inverseJoinColumns' => 'Doctrine\\ORM\\Mapping\\InverseJoinColumn'])]])]);
, [[new NestedAnnotationToAttribute('Doctrine\\ORM\\Mapping\\JoinTable', [new AnnotationPropertyToAttributeClass('Doctrine\\ORM\\Mapping\\JoinColumn', 'joinColumns'), new AnnotationPropertyToAttributeClass('Doctrine\\ORM\\Mapping\\InverseJoinColumn', 'inverseJoinColumns')])]])]);
}
/**
* @return array<class-string<Node>>
@ -106,6 +116,7 @@ CODE_SAMPLE
return null;
}
$node->attrGroups = $attributeGroups;
$this->completeExtraUseImports($attributeGroups);
return $node;
}
/**
@ -158,4 +169,19 @@ CODE_SAMPLE
}
return null;
}
/**
* @param AttributeGroup[] $attributeGroups
*/
private function completeExtraUseImports(array $attributeGroups) : void
{
foreach ($attributeGroups as $attributeGroup) {
foreach ($attributeGroup->attrs as $attr) {
$namespacedAttrName = $attr->name->getAttribute(AttributeKey::EXTRA_USE_IMPORT);
if (!\is_string($namespacedAttrName)) {
continue;
}
$this->useNodesToAddCollector->addUseImport(new FullyQualifiedObjectType($namespacedAttrName));
}
}
}
}

View File

@ -0,0 +1,49 @@
<?php
declare (strict_types=1);
namespace Rector\Php80\ValueObject;
use Rector\Core\Validation\RectorAssert;
final class AnnotationPropertyToAttributeClass
{
/**
* @readonly
* @var string
*/
private $attributeClass;
/**
* @readonly
* @var string|int|null
*/
private $annotationProperty = null;
/**
* @readonly
* @var bool
*/
private $doesNeedNewImport = \false;
/**
* @param string|int|null $annotationProperty
*/
public function __construct(string $attributeClass, $annotationProperty = null, bool $doesNeedNewImport = \false)
{
$this->attributeClass = $attributeClass;
$this->annotationProperty = $annotationProperty;
$this->doesNeedNewImport = $doesNeedNewImport;
RectorAssert::className($attributeClass);
}
/**
* @return string|int|null
*/
public function getAnnotationProperty()
{
return $this->annotationProperty;
}
public function getAttributeClass() : string
{
return $this->attributeClass;
}
public function doesNeedNewImport() : bool
{
return $this->doesNeedNewImport;
}
}

View File

@ -5,41 +5,45 @@ namespace Rector\Php80\ValueObject;
use Rector\Core\Validation\RectorAssert;
use Rector\Php80\Contract\ValueObject\AnnotationToAttributeInterface;
use RectorPrefix202210\Webmozart\Assert\Assert;
final class NestedAnnotationToAttribute implements AnnotationToAttributeInterface
{
/**
* @var AnnotationPropertyToAttributeClass[]
*/
private $annotationPropertiesToAttributeClasses = [];
/**
* @readonly
* @var string
*/
private $tag;
/**
* @var array<string, string>|string[]
* @readonly
*/
private $annotationPropertiesToAttributeClasses;
/**
* @readonly
* @var bool
*/
private $removeOriginal = \false;
/**
* @param array<string, string>|string[] $annotationPropertiesToAttributeClasses
* @param array<string, string>|string[]|AnnotationPropertyToAttributeClass[] $annotationPropertiesToAttributeClasses
*/
public function __construct(string $tag, array $annotationPropertiesToAttributeClasses, bool $removeOriginal = \false)
{
$this->tag = $tag;
$this->annotationPropertiesToAttributeClasses = $annotationPropertiesToAttributeClasses;
$this->removeOriginal = $removeOriginal;
RectorAssert::className($tag);
Assert::allString($annotationPropertiesToAttributeClasses);
// back compatibility for raw scalar values
foreach ($annotationPropertiesToAttributeClasses as $annotationProperty => $attributeClass) {
if ($attributeClass instanceof \Rector\Php80\ValueObject\AnnotationPropertyToAttributeClass) {
$this->annotationPropertiesToAttributeClasses[] = $attributeClass;
} else {
$this->annotationPropertiesToAttributeClasses[] = new \Rector\Php80\ValueObject\AnnotationPropertyToAttributeClass($attributeClass, $annotationProperty);
}
}
}
public function getTag() : string
{
return $this->tag;
}
/**
* @return array<string, string>|string[]
* @return AnnotationPropertyToAttributeClass[]
*/
public function getAnnotationPropertiesToAttributeClasses() : array
{
@ -55,8 +59,8 @@ final class NestedAnnotationToAttribute implements AnnotationToAttributeInterfac
}
public function hasExplicitParameters() : bool
{
foreach (\array_keys($this->annotationPropertiesToAttributeClasses) as $itemName) {
if (\is_string($itemName)) {
foreach ($this->annotationPropertiesToAttributeClasses as $annotationPropertyToAttributeClass) {
if (\is_string($annotationPropertyToAttributeClass->getAnnotationProperty())) {
return \true;
}
}

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'ea25cb04aa92e0961a120347daaf7590e8c83782';
public const PACKAGE_VERSION = 'f4f758c7431f66bc97a019eb53055d05c15705c6';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-10-15 23:12:02';
public const RELEASE_DATE = '2022-10-15 21:33:59';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

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

View File

@ -2255,6 +2255,7 @@ return array(
'Rector\\Php80\\Rector\\Switch_\\ChangeSwitchToMatchRector' => $baseDir . '/rules/Php80/Rector/Switch_/ChangeSwitchToMatchRector.php',
'Rector\\Php80\\Rector\\Ternary\\GetDebugTypeRector' => $baseDir . '/rules/Php80/Rector/Ternary/GetDebugTypeRector.php',
'Rector\\Php80\\ValueObjectFactory\\StrStartsWithFactory' => $baseDir . '/rules/Php80/ValueObjectFactory/StrStartsWithFactory.php',
'Rector\\Php80\\ValueObject\\AnnotationPropertyToAttributeClass' => $baseDir . '/rules/Php80/ValueObject/AnnotationPropertyToAttributeClass.php',
'Rector\\Php80\\ValueObject\\AnnotationToAttribute' => $baseDir . '/rules/Php80/ValueObject/AnnotationToAttribute.php',
'Rector\\Php80\\ValueObject\\ArrayDimFetchAndConstFetch' => $baseDir . '/rules/Php80/ValueObject/ArrayDimFetchAndConstFetch.php',
'Rector\\Php80\\ValueObject\\ClassNameAndTagValueNode' => $baseDir . '/rules/Php80/ValueObject/ClassNameAndTagValueNode.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit62214c77dd6874e6adce0386304736d3
class ComposerAutoloaderInited76a38418d21b5da5d2d31d91b77c37
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit62214c77dd6874e6adce0386304736d3
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit62214c77dd6874e6adce0386304736d3', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInited76a38418d21b5da5d2d31d91b77c37', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit62214c77dd6874e6adce0386304736d3', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInited76a38418d21b5da5d2d31d91b77c37', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit62214c77dd6874e6adce0386304736d3::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInited76a38418d21b5da5d2d31d91b77c37::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit62214c77dd6874e6adce0386304736d3::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInited76a38418d21b5da5d2d31d91b77c37::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire62214c77dd6874e6adce0386304736d3($fileIdentifier, $file);
composerRequireed76a38418d21b5da5d2d31d91b77c37($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit62214c77dd6874e6adce0386304736d3
* @param string $file
* @return void
*/
function composerRequire62214c77dd6874e6adce0386304736d3($fileIdentifier, $file)
function composerRequireed76a38418d21b5da5d2d31d91b77c37($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 ComposerStaticInit62214c77dd6874e6adce0386304736d3
class ComposerStaticInited76a38418d21b5da5d2d31d91b77c37
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -2510,6 +2510,7 @@ class ComposerStaticInit62214c77dd6874e6adce0386304736d3
'Rector\\Php80\\Rector\\Switch_\\ChangeSwitchToMatchRector' => __DIR__ . '/../..' . '/rules/Php80/Rector/Switch_/ChangeSwitchToMatchRector.php',
'Rector\\Php80\\Rector\\Ternary\\GetDebugTypeRector' => __DIR__ . '/../..' . '/rules/Php80/Rector/Ternary/GetDebugTypeRector.php',
'Rector\\Php80\\ValueObjectFactory\\StrStartsWithFactory' => __DIR__ . '/../..' . '/rules/Php80/ValueObjectFactory/StrStartsWithFactory.php',
'Rector\\Php80\\ValueObject\\AnnotationPropertyToAttributeClass' => __DIR__ . '/../..' . '/rules/Php80/ValueObject/AnnotationPropertyToAttributeClass.php',
'Rector\\Php80\\ValueObject\\AnnotationToAttribute' => __DIR__ . '/../..' . '/rules/Php80/ValueObject/AnnotationToAttribute.php',
'Rector\\Php80\\ValueObject\\ArrayDimFetchAndConstFetch' => __DIR__ . '/../..' . '/rules/Php80/ValueObject/ArrayDimFetchAndConstFetch.php',
'Rector\\Php80\\ValueObject\\ClassNameAndTagValueNode' => __DIR__ . '/../..' . '/rules/Php80/ValueObject/ClassNameAndTagValueNode.php',
@ -3092,9 +3093,9 @@ class ComposerStaticInit62214c77dd6874e6adce0386304736d3
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit62214c77dd6874e6adce0386304736d3::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit62214c77dd6874e6adce0386304736d3::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit62214c77dd6874e6adce0386304736d3::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInited76a38418d21b5da5d2d31d91b77c37::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInited76a38418d21b5da5d2d31d91b77c37::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInited76a38418d21b5da5d2d31d91b77c37::$classMap;
}, null, ClassLoader::class);
}

View File

@ -1784,12 +1784,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
"reference": "c56069f7665bfd544506aadf77b67464ce043f5c"
"reference": "8fbe21e49ca599905dc7d72febfa1252207dde47"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/c56069f7665bfd544506aadf77b67464ce043f5c",
"reference": "c56069f7665bfd544506aadf77b67464ce043f5c",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/8fbe21e49ca599905dc7d72febfa1252207dde47",
"reference": "8fbe21e49ca599905dc7d72febfa1252207dde47",
"shasum": ""
},
"require": {
@ -1815,7 +1815,7 @@
"symplify\/rule-doc-generator": "^11.1",
"symplify\/vendor-patches": "^11.1"
},
"time": "2022-09-06T03:08:37+00:00",
"time": "2022-10-15T21:38:10+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/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main c56069f'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main d75c674'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 2decdcf'), 'rector/rector-php-parser' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-php-parser', 'relative_install_path' => '../../rector-php-parser', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 9c21f5f'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 294de0c'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5568eda'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main ff28f33'));
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 8fbe21e'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main d75c674'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 2decdcf'), 'rector/rector-php-parser' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-php-parser', 'relative_install_path' => '../../rector-php-parser', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 9c21f5f'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 294de0c'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5568eda'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main ff28f33'));
private function __construct()
{
}

View File

@ -6,15 +6,16 @@ namespace RectorPrefix202210;
use Rector\Config\RectorConfig;
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
use Rector\Php80\Rector\Property\NestedAnnotationToAttributeRector;
use Rector\Php80\ValueObject\AnnotationPropertyToAttributeClass;
use Rector\Php80\ValueObject\AnnotationToAttribute;
use Rector\Php80\ValueObject\NestedAnnotationToAttribute;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->ruleWithConfiguration(NestedAnnotationToAttributeRector::class, [
/** @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.13/reference/attributes-reference.html#joincolumn-inversejoincolumn */
new NestedAnnotationToAttribute('Doctrine\\ORM\\Mapping\\JoinTable', ['joinColumns' => 'Doctrine\\ORM\\Mapping\\JoinColumn', 'inverseJoinColumns' => 'Doctrine\\ORM\\Mapping\\InverseJoinColumn']),
new NestedAnnotationToAttribute('Doctrine\\ORM\\Mapping\\JoinTable', [new AnnotationPropertyToAttributeClass('Doctrine\\ORM\\Mapping\\JoinColumn', 'joinColumns'), new AnnotationPropertyToAttributeClass('Doctrine\\ORM\\Mapping\\InverseJoinColumn', 'inverseJoinColumns', \true)]),
/** @see https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/annotations-reference.html#joincolumns */
new NestedAnnotationToAttribute('Doctrine\\ORM\\Mapping\\JoinColumns', ['Doctrine\\ORM\\Mapping\\JoinColumn'], \true),
new NestedAnnotationToAttribute('Doctrine\\ORM\\Mapping\\Table', ['indexes' => 'Doctrine\\ORM\\Mapping\\Index', 'uniqueConstraints' => 'Doctrine\\ORM\\Mapping\\UniqueConstraint']),
new NestedAnnotationToAttribute('Doctrine\\ORM\\Mapping\\JoinColumns', [new AnnotationPropertyToAttributeClass('Doctrine\\ORM\\Mapping\\JoinColumn')], \true),
new NestedAnnotationToAttribute('Doctrine\\ORM\\Mapping\\Table', [new AnnotationPropertyToAttributeClass('Doctrine\\ORM\\Mapping\\Index', 'indexes', \true), new AnnotationPropertyToAttributeClass('Doctrine\\ORM\\Mapping\\UniqueConstraint', 'uniqueConstraints', \true)]),
]);
$rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [
// class

View File

@ -99,7 +99,7 @@ CODE_SAMPLE
}
$defaultExpr = $propertyProperty->default;
if ($defaultExpr instanceof String_) {
$propertyProperty->default = \boolval($defaultExpr->value) ? $this->nodeFactory->createTrue() : $this->nodeFactory->createFalse();
$propertyProperty->default = (bool) $defaultExpr->value ? $this->nodeFactory->createTrue() : $this->nodeFactory->createFalse();
return $property;
}
if ($defaultExpr instanceof ConstFetch || $defaultExpr instanceof ClassConstFetch) {