mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 17:00:51 +00:00
Updated Rector to commit beb6e9127c74b5844dc6165cd60cba9c7136a411
beb6e9127c
Skip namespaced use no backslash on removeUnusedImports() (#3366)
This commit is contained in:
parent
561809dcd2
commit
dd993a84a8
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit1626bd9b98df3fc521cf79938cf0de08::getLoader();
|
||||
return ComposerAutoloaderInitbc88e1f54f086d15069e60056050418c::getLoader();
|
||||
|
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
|
@ -2555,6 +2555,7 @@ return array(
|
|||
'Rector\\Symfony\\Rector\\ClassMethod\\FormTypeGetParentRector' => $vendorDir . '/rector/rector-symfony/src/Rector/ClassMethod/FormTypeGetParentRector.php',
|
||||
'Rector\\Symfony\\Rector\\ClassMethod\\GetRequestRector' => $vendorDir . '/rector/rector-symfony/src/Rector/ClassMethod/GetRequestRector.php',
|
||||
'Rector\\Symfony\\Rector\\ClassMethod\\MergeMethodAnnotationToRouteAnnotationRector' => $vendorDir . '/rector/rector-symfony/src/Rector/ClassMethod/MergeMethodAnnotationToRouteAnnotationRector.php',
|
||||
'Rector\\Symfony\\Rector\\ClassMethod\\ParamConverterAttributeToMapEntityAttributeRector' => $vendorDir . '/rector/rector-symfony/src/Rector/ClassMethod/ParamConverterAttributeToMapEntityAttributeRector.php',
|
||||
'Rector\\Symfony\\Rector\\ClassMethod\\ParamTypeFromRouteRequiredRegexRector' => $vendorDir . '/rector/rector-symfony/src/Rector/ClassMethod/ParamTypeFromRouteRequiredRegexRector.php',
|
||||
'Rector\\Symfony\\Rector\\ClassMethod\\RemoveDefaultGetBlockPrefixRector' => $vendorDir . '/rector/rector-symfony/src/Rector/ClassMethod/RemoveDefaultGetBlockPrefixRector.php',
|
||||
'Rector\\Symfony\\Rector\\ClassMethod\\RemoveServiceFromSensioRouteRector' => $vendorDir . '/rector/rector-symfony/src/Rector/ClassMethod/RemoveServiceFromSensioRouteRector.php',
|
||||
|
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit1626bd9b98df3fc521cf79938cf0de08
|
||||
class ComposerAutoloaderInitbc88e1f54f086d15069e60056050418c
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,17 +22,17 @@ class ComposerAutoloaderInit1626bd9b98df3fc521cf79938cf0de08
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit1626bd9b98df3fc521cf79938cf0de08', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitbc88e1f54f086d15069e60056050418c', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit1626bd9b98df3fc521cf79938cf0de08', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitbc88e1f54f086d15069e60056050418c', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit1626bd9b98df3fc521cf79938cf0de08::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitbc88e1f54f086d15069e60056050418c::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit1626bd9b98df3fc521cf79938cf0de08::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitbc88e1f54f086d15069e60056050418c::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
9
vendor/composer/autoload_static.php
vendored
9
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit1626bd9b98df3fc521cf79938cf0de08
|
||||
class ComposerStaticInitbc88e1f54f086d15069e60056050418c
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -2802,6 +2802,7 @@ class ComposerStaticInit1626bd9b98df3fc521cf79938cf0de08
|
|||
'Rector\\Symfony\\Rector\\ClassMethod\\FormTypeGetParentRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/ClassMethod/FormTypeGetParentRector.php',
|
||||
'Rector\\Symfony\\Rector\\ClassMethod\\GetRequestRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/ClassMethod/GetRequestRector.php',
|
||||
'Rector\\Symfony\\Rector\\ClassMethod\\MergeMethodAnnotationToRouteAnnotationRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/ClassMethod/MergeMethodAnnotationToRouteAnnotationRector.php',
|
||||
'Rector\\Symfony\\Rector\\ClassMethod\\ParamConverterAttributeToMapEntityAttributeRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/ClassMethod/ParamConverterAttributeToMapEntityAttributeRector.php',
|
||||
'Rector\\Symfony\\Rector\\ClassMethod\\ParamTypeFromRouteRequiredRegexRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/ClassMethod/ParamTypeFromRouteRequiredRegexRector.php',
|
||||
'Rector\\Symfony\\Rector\\ClassMethod\\RemoveDefaultGetBlockPrefixRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/ClassMethod/RemoveDefaultGetBlockPrefixRector.php',
|
||||
'Rector\\Symfony\\Rector\\ClassMethod\\RemoveServiceFromSensioRouteRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/ClassMethod/RemoveServiceFromSensioRouteRector.php',
|
||||
|
@ -3097,9 +3098,9 @@ class ComposerStaticInit1626bd9b98df3fc521cf79938cf0de08
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit1626bd9b98df3fc521cf79938cf0de08::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit1626bd9b98df3fc521cf79938cf0de08::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit1626bd9b98df3fc521cf79938cf0de08::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitbc88e1f54f086d15069e60056050418c::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitbc88e1f54f086d15069e60056050418c::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitbc88e1f54f086d15069e60056050418c::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
|
@ -2054,12 +2054,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
|
||||
"reference": "236cdd6714ed8226ba5de1952fa0f962ff53945c"
|
||||
"reference": "3fdae28ba7476ede383a035b8e4af4bc18d40a38"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/236cdd6714ed8226ba5de1952fa0f962ff53945c",
|
||||
"reference": "236cdd6714ed8226ba5de1952fa0f962ff53945c",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/3fdae28ba7476ede383a035b8e4af4bc18d40a38",
|
||||
"reference": "3fdae28ba7476ede383a035b8e4af4bc18d40a38",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2089,7 +2089,7 @@
|
|||
"tomasvotruba\/type-coverage": "^0.0.9",
|
||||
"tomasvotruba\/unused-public": "^0.0.34"
|
||||
},
|
||||
"time": "2023-02-08T15:56:57+00:00",
|
||||
"time": "2023-02-08T22:40:52+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/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main ea9cf46'), '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 b9bfc78'), '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 ee461b1'), '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 236cdd6'));
|
||||
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 ea9cf46'), '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 b9bfc78'), '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 ee461b1'), '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 3fdae28'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -4,9 +4,7 @@ declare (strict_types=1);
|
|||
namespace RectorPrefix202302;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
|
||||
use Rector\Php80\ValueObject\AnnotationToAttribute;
|
||||
use Rector\Symfony\Set\SensiolabsSetList;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
// @see https://github.com/sensiolabs/SensioFrameworkExtraBundle/pull/707
|
||||
$rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [new AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Cache'), new AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Entity'), new AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\IsGranted'), new AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\ParamConverter'), new AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Security'), new AnnotationToAttribute('Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Template')]);
|
||||
$rectorConfig->sets([SensiolabsSetList::ANNOTATIONS_TO_ATTRIBUTES]);
|
||||
};
|
||||
|
|
|
@ -9,6 +9,7 @@ use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
|||
use Rector\Renaming\Rector\Name\RenameClassRector;
|
||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
use Rector\Renaming\ValueObject\RenameClassAndConstFetch;
|
||||
use Rector\Symfony\Rector\ClassMethod\ParamConverterAttributeToMapEntityAttributeRector;
|
||||
use Rector\Symfony\Rector\MethodCall\SimplifyFormRenderingRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->rule(SimplifyFormRenderingRector::class);
|
||||
|
@ -45,4 +46,5 @@ return static function (RectorConfig $rectorConfig) : void {
|
|||
// @see https://github.com/symfony/symfony/pull/46094
|
||||
// @see https://github.com/symfony/symfony/pull/48554
|
||||
$rectorConfig->ruleWithConfiguration(RenameClassConstFetchRector::class, [new RenameClassAndConstFetch('Symfony\\Component\\Security\\Core\\Security', 'ACCESS_DENIED_ERROR', 'Symfony\\Component\\Security\\Http\\SecurityRequestAttributes', 'ACCESS_DENIED_ERROR'), new RenameClassAndConstFetch('Symfony\\Component\\Security\\Core\\Security', 'AUTHENTICATION_ERROR', 'Symfony\\Component\\Security\\Http\\SecurityRequestAttributes', 'AUTHENTICATION_ERROR'), new RenameClassAndConstFetch('Symfony\\Component\\Security\\Core\\Security', 'LAST_USERNAME', 'Symfony\\Component\\Security\\Http\\SecurityRequestAttributes', 'LAST_USERNAME'), new RenameClassAndConstFetch('Symfony\\Component\\Security\\Core\\Security', 'MAX_USERNAME_LENGTH', 'Symfony\\Component\\Security\\Http\\Authenticator\\Passport\\Badge\\UserBadge', 'MAX_USERNAME_LENGTH')]);
|
||||
$rectorConfig->rule(ParamConverterAttributeToMapEntityAttributeRector::class);
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# 77 Rules Overview
|
||||
# 78 Rules Overview
|
||||
|
||||
## ActionSuffixRemoverRector
|
||||
|
||||
|
@ -1076,6 +1076,30 @@ Turns old option names to new ones in FormTypes in Form in Symfony
|
|||
|
||||
<br>
|
||||
|
||||
## ParamConverterAttributeToMapEntityAttributeRector
|
||||
|
||||
Replace ParamConverter attribute with mappings with the MapEntity attribute
|
||||
|
||||
- class: [`Rector\Symfony\Rector\ClassMethod\ParamConverterAttributeToMapEntityAttributeRector`](../src/Rector/ClassMethod/ParamConverterAttributeToMapEntityAttributeRector.php)
|
||||
|
||||
```diff
|
||||
class SomeController
|
||||
{
|
||||
#[Route('/blog/{date}/{slug}/comments/{comment_slug}')]
|
||||
- #[ParamConverter('post', options: ['mapping' => ['date' => 'date', 'slug' => 'slug']])]
|
||||
- #[ParamConverter('comment', options: ['mapping' => ['comment_slug' => 'slug']])]
|
||||
public function showComment(
|
||||
- Post $post,
|
||||
- Comment $comment
|
||||
+ #[\Symfony\Bridge\Doctrine\Attribute\MapEntity(mapping: ['date' => 'date', 'slug' => 'slug'])] Post $post,
|
||||
+ #[\Symfony\Bridge\Doctrine\Attribute\MapEntity(mapping: ['comment_slug' => 'slug'])] Comment $comment
|
||||
) {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## ParamTypeFromRouteRequiredRegexRector
|
||||
|
||||
Complete strict param type declaration based on route annotation
|
||||
|
|
|
@ -0,0 +1,145 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Symfony\Rector\ClassMethod;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Attribute;
|
||||
use PhpParser\Node\AttributeGroup;
|
||||
use PhpParser\Node\Expr\Array_;
|
||||
use PhpParser\Node\Expr\ArrayItem;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see https://symfony.com/blog/new-in-symfony-6-2-built-in-cache-security-template-and-doctrine-attributes
|
||||
*
|
||||
* @see \Rector\Symfony\Tests\Rector\ClassMethod\ParamConverterAttributeToMapEntityAttributeRector\ParamConverterAttributeToMapEntityAttributeRectorTest
|
||||
*/
|
||||
final class ParamConverterAttributeToMapEntityAttributeRector extends AbstractRector implements MinPhpVersionInterface
|
||||
{
|
||||
private const PARAM_CONVERTER_CLASS = 'Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\ParamConverter';
|
||||
private const MAP_ENTITY_CLASS = 'Symfony\\Bridge\\Doctrine\\Attribute\\MapEntity';
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer
|
||||
*/
|
||||
private $phpAttributeAnalyzer;
|
||||
public function __construct(PhpAttributeAnalyzer $phpAttributeAnalyzer)
|
||||
{
|
||||
$this->phpAttributeAnalyzer = $phpAttributeAnalyzer;
|
||||
}
|
||||
public function provideMinPhpVersion() : int
|
||||
{
|
||||
return PhpVersionFeature::ATTRIBUTES;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Replace ParamConverter attribute with mappings with the MapEntity attribute', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
class SomeController
|
||||
{
|
||||
#[Route('/blog/{date}/{slug}/comments/{comment_slug}')]
|
||||
#[ParamConverter('post', options: ['mapping' => ['date' => 'date', 'slug' => 'slug']])]
|
||||
#[ParamConverter('comment', options: ['mapping' => ['comment_slug' => 'slug']])]
|
||||
public function showComment(
|
||||
Post $post,
|
||||
Comment $comment
|
||||
) {
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
class SomeController
|
||||
{
|
||||
#[Route('/blog/{date}/{slug}/comments/{comment_slug}')]
|
||||
public function showComment(
|
||||
#[\Symfony\Bridge\Doctrine\Attribute\MapEntity(mapping: ['date' => 'date', 'slug' => 'slug'])] Post $post,
|
||||
#[\Symfony\Bridge\Doctrine\Attribute\MapEntity(mapping: ['comment_slug' => 'slug'])] Comment $comment
|
||||
) {
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [ClassMethod::class];
|
||||
}
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (!$node instanceof ClassMethod || !$node->isPublic() || !$this->phpAttributeAnalyzer->hasPhpAttribute($node, self::PARAM_CONVERTER_CLASS)) {
|
||||
return null;
|
||||
}
|
||||
$this->refactorParamConverter($node);
|
||||
return $node;
|
||||
}
|
||||
private function refactorParamConverter(ClassMethod $classMethod) : Node
|
||||
{
|
||||
foreach ($classMethod->attrGroups as $attrGroup) {
|
||||
foreach ($attrGroup->attrs as $attr) {
|
||||
if ($this->isName($attr, self::PARAM_CONVERTER_CLASS)) {
|
||||
$this->refactorAttribute($classMethod, $attr);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $classMethod;
|
||||
}
|
||||
private function refactorAttribute(ClassMethod $classMethod, Attribute $attribute) : void
|
||||
{
|
||||
if ($attribute->args === [] || !$attribute->args[1]->name instanceof Identifier || $attribute->args[1]->name->name !== 'options' || !$attribute->args[0]->value instanceof String_) {
|
||||
return;
|
||||
}
|
||||
$name = $attribute->args[0]->value->value;
|
||||
$mapping = $attribute->args[1]->value;
|
||||
if (!$mapping instanceof Array_) {
|
||||
return;
|
||||
}
|
||||
$newArguments = [];
|
||||
$probablyEntity = \false;
|
||||
foreach ($mapping->items as $item) {
|
||||
if (!$item instanceof ArrayItem || !$item->key instanceof String_) {
|
||||
continue;
|
||||
}
|
||||
if (\in_array($item->key->value, ['mapping', 'entity_manager'], \true)) {
|
||||
$probablyEntity = \true;
|
||||
}
|
||||
$newArguments[] = new Arg($item->value, \false, \false, [], new Identifier($item->key->value));
|
||||
}
|
||||
if (!$probablyEntity) {
|
||||
return;
|
||||
}
|
||||
$this->removeNode($attribute->args[0]);
|
||||
$attribute->args = $newArguments;
|
||||
$attribute->name = new FullyQualified(self::MAP_ENTITY_CLASS);
|
||||
$node = $attribute->getAttribute(AttributeKey::PARENT_NODE);
|
||||
if (!$node instanceof AttributeGroup) {
|
||||
return;
|
||||
}
|
||||
$this->addMapEntityAttribute($classMethod, $name, $node);
|
||||
}
|
||||
private function addMapEntityAttribute(ClassMethod $classMethod, string $variableName, AttributeGroup $attributeGroup) : void
|
||||
{
|
||||
foreach ($classMethod->params as $param) {
|
||||
if (!$param->var instanceof Variable) {
|
||||
continue;
|
||||
}
|
||||
if ($variableName === $param->var->name) {
|
||||
$param->attrGroups = [$attributeGroup];
|
||||
$this->removeNode($attributeGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user