mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
Updated Rector to commit 07df7dc1a344c52711441149d61251a4fe10366d
07df7dc1a3
Remove collector interface and fix SpatieEnumClassToEnumRector already has underscore to double underscore (#5473)
This commit is contained in:
parent
0d611d897a
commit
bae6d284a0
5
vendor/composer/autoload_classmap.php
vendored
5
vendor/composer/autoload_classmap.php
vendored
@ -2064,6 +2064,7 @@ return array(
|
||||
'Rector\\Symfony\\Bridge\\Symfony\\ContainerServiceProvider' => $vendorDir . '/rector/rector-symfony/src/Bridge/Symfony/ContainerServiceProvider.php',
|
||||
'Rector\\Symfony\\Bridge\\Symfony\\Routing\\SymfonyRoutesProvider' => $vendorDir . '/rector/rector-symfony/src/Bridge/Symfony/Routing/SymfonyRoutesProvider.php',
|
||||
'Rector\\Symfony\\BundleClassResolver' => $vendorDir . '/rector/rector-symfony/src/BundleClassResolver.php',
|
||||
'Rector\\Symfony\\CodeQuality\\NodeFactory\\SymfonyClosureFactory' => $vendorDir . '/rector/rector-symfony/rules/CodeQuality/NodeFactory/SymfonyClosureFactory.php',
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\BinaryOp\\ResponseStatusCodeRector' => $vendorDir . '/rector/rector-symfony/rules/CodeQuality/Rector/BinaryOp/ResponseStatusCodeRector.php',
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\ClassMethod\\ActionSuffixRemoverRector' => $vendorDir . '/rector/rector-symfony/rules/CodeQuality/Rector/ClassMethod/ActionSuffixRemoverRector.php',
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\ClassMethod\\ParamTypeFromRouteRequiredRegexRector' => $vendorDir . '/rector/rector-symfony/rules/CodeQuality/Rector/ClassMethod/ParamTypeFromRouteRequiredRegexRector.php',
|
||||
@ -2076,6 +2077,9 @@ return array(
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\Closure\\StringExtensionToConfigBuilderRector' => $vendorDir . '/rector/rector-symfony/rules/CodeQuality/Rector/Closure/StringExtensionToConfigBuilderRector.php',
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\MethodCall\\AssertSameResponseCodeWithDebugContentsRector' => $vendorDir . '/rector/rector-symfony/rules/CodeQuality/Rector/MethodCall/AssertSameResponseCodeWithDebugContentsRector.php',
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\MethodCall\\LiteralGetToRequestClassConstantRector' => $vendorDir . '/rector/rector-symfony/rules/CodeQuality/Rector/MethodCall/LiteralGetToRequestClassConstantRector.php',
|
||||
'Rector\\Symfony\\Configs\\ConfigArrayHandler\\NestedConfigCallsFactory' => $vendorDir . '/rector/rector-symfony/rules/Configs/ConfigArrayHandler/NestedConfigCallsFactory.php',
|
||||
'Rector\\Symfony\\Configs\\ConfigArrayHandler\\SecurityAccessDecisionManagerConfigArrayHandler' => $vendorDir . '/rector/rector-symfony/rules/Configs/ConfigArrayHandler/SecurityAccessDecisionManagerConfigArrayHandler.php',
|
||||
'Rector\\Symfony\\Configs\\Enum\\SecurityConfigKey' => $vendorDir . '/rector/rector-symfony/rules/Configs/Enum/SecurityConfigKey.php',
|
||||
'Rector\\Symfony\\Configs\\Rector\\ClassMethod\\AddRouteAnnotationRector' => $vendorDir . '/rector/rector-symfony/rules/Configs/Rector/ClassMethod/AddRouteAnnotationRector.php',
|
||||
'Rector\\Symfony\\Configs\\Rector\\Closure\\ServiceArgsToServiceNamedArgRector' => $vendorDir . '/rector/rector-symfony/rules/Configs/Rector/Closure/ServiceArgsToServiceNamedArgRector.php',
|
||||
'Rector\\Symfony\\Configs\\Rector\\Closure\\ServiceSetStringNameToClassNameRector' => $vendorDir . '/rector/rector-symfony/rules/Configs/Rector/Closure/ServiceSetStringNameToClassNameRector.php',
|
||||
@ -2207,6 +2211,7 @@ return array(
|
||||
'Rector\\Symfony\\TypeAnalyzer\\ContainerAwareAnalyzer' => $vendorDir . '/rector/rector-symfony/src/TypeAnalyzer/ContainerAwareAnalyzer.php',
|
||||
'Rector\\Symfony\\TypeAnalyzer\\ControllerAnalyzer' => $vendorDir . '/rector/rector-symfony/src/TypeAnalyzer/ControllerAnalyzer.php',
|
||||
'Rector\\Symfony\\TypeDeclaration\\ReturnTypeDeclarationUpdater' => $vendorDir . '/rector/rector-symfony/src/TypeDeclaration/ReturnTypeDeclarationUpdater.php',
|
||||
'Rector\\Symfony\\Utils\\StringUtils' => $vendorDir . '/rector/rector-symfony/src/Utils/StringUtils.php',
|
||||
'Rector\\Symfony\\ValueObjectFactory\\ServiceMapFactory' => $vendorDir . '/rector/rector-symfony/src/ValueObjectFactory/ServiceMapFactory.php',
|
||||
'Rector\\Symfony\\ValueObject\\ClassNameAndFilePath' => $vendorDir . '/rector/rector-symfony/src/ValueObject/ClassNameAndFilePath.php',
|
||||
'Rector\\Symfony\\ValueObject\\ConstantMap\\SymfonyCommandConstantMap' => $vendorDir . '/rector/rector-symfony/src/ValueObject/ConstantMap/SymfonyCommandConstantMap.php',
|
||||
|
5
vendor/composer/autoload_static.php
vendored
5
vendor/composer/autoload_static.php
vendored
@ -2278,6 +2278,7 @@ class ComposerStaticInit3aa8fc9c37eb79c784df0b556be25aa0
|
||||
'Rector\\Symfony\\Bridge\\Symfony\\ContainerServiceProvider' => __DIR__ . '/..' . '/rector/rector-symfony/src/Bridge/Symfony/ContainerServiceProvider.php',
|
||||
'Rector\\Symfony\\Bridge\\Symfony\\Routing\\SymfonyRoutesProvider' => __DIR__ . '/..' . '/rector/rector-symfony/src/Bridge/Symfony/Routing/SymfonyRoutesProvider.php',
|
||||
'Rector\\Symfony\\BundleClassResolver' => __DIR__ . '/..' . '/rector/rector-symfony/src/BundleClassResolver.php',
|
||||
'Rector\\Symfony\\CodeQuality\\NodeFactory\\SymfonyClosureFactory' => __DIR__ . '/..' . '/rector/rector-symfony/rules/CodeQuality/NodeFactory/SymfonyClosureFactory.php',
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\BinaryOp\\ResponseStatusCodeRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/CodeQuality/Rector/BinaryOp/ResponseStatusCodeRector.php',
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\ClassMethod\\ActionSuffixRemoverRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/CodeQuality/Rector/ClassMethod/ActionSuffixRemoverRector.php',
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\ClassMethod\\ParamTypeFromRouteRequiredRegexRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/CodeQuality/Rector/ClassMethod/ParamTypeFromRouteRequiredRegexRector.php',
|
||||
@ -2290,6 +2291,9 @@ class ComposerStaticInit3aa8fc9c37eb79c784df0b556be25aa0
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\Closure\\StringExtensionToConfigBuilderRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/CodeQuality/Rector/Closure/StringExtensionToConfigBuilderRector.php',
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\MethodCall\\AssertSameResponseCodeWithDebugContentsRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/CodeQuality/Rector/MethodCall/AssertSameResponseCodeWithDebugContentsRector.php',
|
||||
'Rector\\Symfony\\CodeQuality\\Rector\\MethodCall\\LiteralGetToRequestClassConstantRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/CodeQuality/Rector/MethodCall/LiteralGetToRequestClassConstantRector.php',
|
||||
'Rector\\Symfony\\Configs\\ConfigArrayHandler\\NestedConfigCallsFactory' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Configs/ConfigArrayHandler/NestedConfigCallsFactory.php',
|
||||
'Rector\\Symfony\\Configs\\ConfigArrayHandler\\SecurityAccessDecisionManagerConfigArrayHandler' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Configs/ConfigArrayHandler/SecurityAccessDecisionManagerConfigArrayHandler.php',
|
||||
'Rector\\Symfony\\Configs\\Enum\\SecurityConfigKey' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Configs/Enum/SecurityConfigKey.php',
|
||||
'Rector\\Symfony\\Configs\\Rector\\ClassMethod\\AddRouteAnnotationRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Configs/Rector/ClassMethod/AddRouteAnnotationRector.php',
|
||||
'Rector\\Symfony\\Configs\\Rector\\Closure\\ServiceArgsToServiceNamedArgRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Configs/Rector/Closure/ServiceArgsToServiceNamedArgRector.php',
|
||||
'Rector\\Symfony\\Configs\\Rector\\Closure\\ServiceSetStringNameToClassNameRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Configs/Rector/Closure/ServiceSetStringNameToClassNameRector.php',
|
||||
@ -2421,6 +2425,7 @@ class ComposerStaticInit3aa8fc9c37eb79c784df0b556be25aa0
|
||||
'Rector\\Symfony\\TypeAnalyzer\\ContainerAwareAnalyzer' => __DIR__ . '/..' . '/rector/rector-symfony/src/TypeAnalyzer/ContainerAwareAnalyzer.php',
|
||||
'Rector\\Symfony\\TypeAnalyzer\\ControllerAnalyzer' => __DIR__ . '/..' . '/rector/rector-symfony/src/TypeAnalyzer/ControllerAnalyzer.php',
|
||||
'Rector\\Symfony\\TypeDeclaration\\ReturnTypeDeclarationUpdater' => __DIR__ . '/..' . '/rector/rector-symfony/src/TypeDeclaration/ReturnTypeDeclarationUpdater.php',
|
||||
'Rector\\Symfony\\Utils\\StringUtils' => __DIR__ . '/..' . '/rector/rector-symfony/src/Utils/StringUtils.php',
|
||||
'Rector\\Symfony\\ValueObjectFactory\\ServiceMapFactory' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObjectFactory/ServiceMapFactory.php',
|
||||
'Rector\\Symfony\\ValueObject\\ClassNameAndFilePath' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObject/ClassNameAndFilePath.php',
|
||||
'Rector\\Symfony\\ValueObject\\ConstantMap\\SymfonyCommandConstantMap' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObject/ConstantMap/SymfonyCommandConstantMap.php',
|
||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -1867,12 +1867,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
|
||||
"reference": "bd312e6d771262880d6fc573362142128bf0fce0"
|
||||
"reference": "0da1af3e69588a0993f62b49ccce4595d0cdb120"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/bd312e6d771262880d6fc573362142128bf0fce0",
|
||||
"reference": "bd312e6d771262880d6fc573362142128bf0fce0",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/0da1af3e69588a0993f62b49ccce4595d0cdb120",
|
||||
"reference": "0da1af3e69588a0993f62b49ccce4595d0cdb120",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1901,7 +1901,7 @@
|
||||
"tomasvotruba\/class-leak": "^0.2.6",
|
||||
"tracy\/tracy": "^2.10"
|
||||
},
|
||||
"time": "2024-01-16T00:17:59+00:00",
|
||||
"time": "2024-01-16T14:22:30+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 b419ce7'), '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 51ff6e7'), '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 4581a9a'), '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 bd312e6'));
|
||||
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 b419ce7'), '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 51ff6e7'), '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 4581a9a'), '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 0da1af3'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
# 83 Rules Overview
|
||||
# 84 Rules Overview
|
||||
|
||||
## ActionSuffixRemoverRector
|
||||
|
||||
@ -428,6 +428,27 @@ Migrates from deprecated `Definition/Alias->setPrivate()` to `Definition/Alias->
|
||||
|
||||
<br>
|
||||
|
||||
## DowngradeSymfonyCommandAttributeRector
|
||||
|
||||
Downgrade Symfony Command Attribute
|
||||
|
||||
- class: [`Rector\Symfony\DowngradeSymfony70\Rector\Class_\DowngradeSymfonyCommandAttributeRector`](../rules/DowngradeSymfony70/Rector/Class_/DowngradeSymfonyCommandAttributeRector.php)
|
||||
|
||||
```diff
|
||||
#[AsCommand(name: 'app:create-user', description: 'some description')]
|
||||
class CreateUserCommand extends Command
|
||||
-{}
|
||||
+{
|
||||
+ protected function configure(): void
|
||||
+ {
|
||||
+ $this->setName('app:create-user');
|
||||
+ $this->setDescription('some description');
|
||||
+ }
|
||||
+}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## ErrorNamesPropertyToConstantRector
|
||||
|
||||
Turns old Constraint::$errorNames properties to use Constraint::ERROR_NAMES instead
|
||||
@ -1632,15 +1653,14 @@ Add config builder classes
|
||||
- 'security' => false,
|
||||
- ],
|
||||
- ],
|
||||
- ]);
|
||||
+return static function (SecurityConfig $securityConfig): void {
|
||||
+ $securityConfig->provider('webservice', [
|
||||
+ 'id' => LoginServiceUserProvider::class,
|
||||
+ ]);
|
||||
+ $securityConfig->provider('webservice')
|
||||
+ ->id(LoginServiceUserProvider::class);
|
||||
+
|
||||
+ $securityConfig->firewall('dev', [
|
||||
+ 'pattern' => '^/(_(profiler|wdt)|css|images|js)/',
|
||||
+ 'security' => false,
|
||||
]);
|
||||
+ $securityConfig->firewall('dev')
|
||||
+ ->pattern('^/(_(profiler|wdt)|css|images|js)/')
|
||||
+ ->security(false);
|
||||
};
|
||||
```
|
||||
|
||||
@ -1678,7 +1698,7 @@ Changes Process string argument to an array
|
||||
|
||||
Changes `createMessage()` into a new Symfony\Component\Mime\Email
|
||||
|
||||
- class: [`Rector\Symfony\Symfony53\Rector\MethodCall\SwiftCreateMessageToNewEmailRector`](../rules/Symfony53/Rector/MethodCall/SwiftCreateMessageToNewEmailRector.php)
|
||||
- class: [`Rector\Symfony\SwiftMailer\Rector\MethodCall\SwiftCreateMessageToNewEmailRector`](../rules/SwiftMailer/Rector/MethodCall/SwiftCreateMessageToNewEmailRector.php)
|
||||
|
||||
```diff
|
||||
-$email = $this->swift->createMessage('message');
|
||||
@ -1691,7 +1711,7 @@ Changes `createMessage()` into a new Symfony\Component\Mime\Email
|
||||
|
||||
Changes `setBody()` method call on Swift_Message into a `html()` or `plain()` based on second argument
|
||||
|
||||
- class: [`Rector\Symfony\Symfony53\Rector\MethodCall\SwiftSetBodyToHtmlPlainMethodCallRector`](../rules/Symfony53/Rector/MethodCall/SwiftSetBodyToHtmlPlainMethodCallRector.php)
|
||||
- class: [`Rector\Symfony\SwiftMailer\Rector\MethodCall\SwiftSetBodyToHtmlPlainMethodCallRector`](../rules/SwiftMailer/Rector/MethodCall/SwiftSetBodyToHtmlPlainMethodCallRector.php)
|
||||
|
||||
```diff
|
||||
$message = new Swift_Message();
|
||||
|
42
vendor/rector/rector-symfony/rules/CodeQuality/NodeFactory/SymfonyClosureFactory.php
vendored
Normal file
42
vendor/rector/rector-symfony/rules/CodeQuality/NodeFactory/SymfonyClosureFactory.php
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Symfony\CodeQuality\NodeFactory;
|
||||
|
||||
use PhpParser\Node\Expr\Closure;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt;
|
||||
use Rector\Naming\Naming\PropertyNaming;
|
||||
final class SymfonyClosureFactory
|
||||
{
|
||||
/**
|
||||
* @var \Rector\Naming\Naming\PropertyNaming
|
||||
*/
|
||||
private $propertyNaming;
|
||||
public function __construct(PropertyNaming $propertyNaming)
|
||||
{
|
||||
$this->propertyNaming = $propertyNaming;
|
||||
}
|
||||
/**
|
||||
* @param Stmt[] $stmts
|
||||
*/
|
||||
public function create(string $configClass, Closure $closure, array $stmts) : Closure
|
||||
{
|
||||
$closure->params[0] = $this->createConfigParam($configClass);
|
||||
$closure->stmts = $stmts;
|
||||
return $closure;
|
||||
}
|
||||
private function createConfigParam(string $configClass) : Param
|
||||
{
|
||||
$configVariable = $this->createConfigVariable($configClass);
|
||||
$fullyQualified = new FullyQualified($configClass);
|
||||
return new Param($configVariable, null, $fullyQualified);
|
||||
}
|
||||
private function createConfigVariable(string $configClass) : Variable
|
||||
{
|
||||
$variableName = $this->propertyNaming->fqnToVariableName($configClass);
|
||||
return new Variable($variableName);
|
||||
}
|
||||
}
|
@ -8,15 +8,19 @@ use PhpParser\Node\Expr\Array_;
|
||||
use PhpParser\Node\Expr\Closure;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use Rector\Exception\NotImplementedYetException;
|
||||
use Rector\Naming\Naming\PropertyNaming;
|
||||
use Rector\PhpParser\Node\Value\ValueResolver;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Rector\Symfony\CodeQuality\NodeFactory\SymfonyClosureFactory;
|
||||
use Rector\Symfony\Configs\ConfigArrayHandler\NestedConfigCallsFactory;
|
||||
use Rector\Symfony\Configs\ConfigArrayHandler\SecurityAccessDecisionManagerConfigArrayHandler;
|
||||
use Rector\Symfony\Configs\Enum\SecurityConfigKey;
|
||||
use Rector\Symfony\NodeAnalyzer\SymfonyClosureExtensionMatcher;
|
||||
use Rector\Symfony\NodeAnalyzer\SymfonyPhpClosureDetector;
|
||||
use Rector\Symfony\Utils\StringUtils;
|
||||
use Rector\Symfony\ValueObject\ExtensionKeyAndConfiguration;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
@ -47,16 +51,34 @@ final class StringExtensionToConfigBuilderRector extends AbstractRector
|
||||
* @var \Rector\PhpParser\Node\Value\ValueResolver
|
||||
*/
|
||||
private $valueResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Symfony\Configs\ConfigArrayHandler\NestedConfigCallsFactory
|
||||
*/
|
||||
private $nestedConfigCallsFactory;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Symfony\Configs\ConfigArrayHandler\SecurityAccessDecisionManagerConfigArrayHandler
|
||||
*/
|
||||
private $securityAccessDecisionManagerConfigArrayHandler;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Symfony\CodeQuality\NodeFactory\SymfonyClosureFactory
|
||||
*/
|
||||
private $symfonyClosureFactory;
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
private const EXTENSION_KEY_TO_CLASS_MAP = ['security' => 'Symfony\\Config\\SecurityConfig', 'framework' => 'Symfony\\Config\\FrameworkConfig'];
|
||||
public function __construct(SymfonyPhpClosureDetector $symfonyPhpClosureDetector, SymfonyClosureExtensionMatcher $symfonyClosureExtensionMatcher, PropertyNaming $propertyNaming, ValueResolver $valueResolver)
|
||||
private const EXTENSION_KEY_TO_CLASS_MAP = ['security' => 'Symfony\\Config\\SecurityConfig', 'framework' => 'Symfony\\Config\\FrameworkConfig', 'monolog' => 'Symfony\\Config\\MonologConfig', 'twig' => 'Symfony\\Config\\TwigConfig', 'doctrine' => 'Symfony\\Config\\DoctrineConfig'];
|
||||
public function __construct(SymfonyPhpClosureDetector $symfonyPhpClosureDetector, SymfonyClosureExtensionMatcher $symfonyClosureExtensionMatcher, PropertyNaming $propertyNaming, ValueResolver $valueResolver, NestedConfigCallsFactory $nestedConfigCallsFactory, SecurityAccessDecisionManagerConfigArrayHandler $securityAccessDecisionManagerConfigArrayHandler, SymfonyClosureFactory $symfonyClosureFactory)
|
||||
{
|
||||
$this->symfonyPhpClosureDetector = $symfonyPhpClosureDetector;
|
||||
$this->symfonyClosureExtensionMatcher = $symfonyClosureExtensionMatcher;
|
||||
$this->propertyNaming = $propertyNaming;
|
||||
$this->valueResolver = $valueResolver;
|
||||
$this->nestedConfigCallsFactory = $nestedConfigCallsFactory;
|
||||
$this->securityAccessDecisionManagerConfigArrayHandler = $securityAccessDecisionManagerConfigArrayHandler;
|
||||
$this->symfonyClosureFactory = $symfonyClosureFactory;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
@ -83,14 +105,12 @@ CODE_SAMPLE
|
||||
use Symfony\Config\SecurityConfig;
|
||||
|
||||
return static function (SecurityConfig $securityConfig): void {
|
||||
$securityConfig->provider('webservice', [
|
||||
'id' => LoginServiceUserProvider::class,
|
||||
]);
|
||||
$securityConfig->provider('webservice')
|
||||
->id(LoginServiceUserProvider::class);
|
||||
|
||||
$securityConfig->firewall('dev', [
|
||||
'pattern' => '^/(_(profiler|wdt)|css|images|js)/',
|
||||
'security' => false,
|
||||
]);
|
||||
$securityConfig->firewall('dev')
|
||||
->pattern('^/(_(profiler|wdt)|css|images|js)/')
|
||||
->security(false);
|
||||
};
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
@ -118,15 +138,9 @@ CODE_SAMPLE
|
||||
if ($configClass === null) {
|
||||
throw new NotImplementedYetException($extensionKeyAndConfiguration->getKey());
|
||||
}
|
||||
return $this->createConfigClosureStmts($configClass, $node, $extensionKeyAndConfiguration);
|
||||
}
|
||||
private function createConfigClosureStmts(string $configClass, Closure $closure, ExtensionKeyAndConfiguration $extensionKeyAndConfiguration) : Closure
|
||||
{
|
||||
$closure->params[0] = $this->createConfigParam($configClass);
|
||||
$configuration = $extensionKeyAndConfiguration->getArray();
|
||||
$configVariable = $this->createConfigVariable($configClass);
|
||||
$closure->stmts = $this->createMethodCallStmts($configuration, $configVariable);
|
||||
return $closure;
|
||||
$stmts = $this->createMethodCallStmts($extensionKeyAndConfiguration->getArray(), $configVariable);
|
||||
return $this->symfonyClosureFactory->create($configClass, $node, $stmts);
|
||||
}
|
||||
/**
|
||||
* @return array<Expression<MethodCall>>
|
||||
@ -143,48 +157,41 @@ CODE_SAMPLE
|
||||
} elseif ($key === 'firewalls') {
|
||||
$methodCallName = 'firewall';
|
||||
$splitMany = \true;
|
||||
} elseif ($key === SecurityConfigKey::ACCESS_CONTROL) {
|
||||
$splitMany = \true;
|
||||
$methodCallName = 'accessControl';
|
||||
} else {
|
||||
$methodCallName = $this->createCamelCaseFromUnderscored($key);
|
||||
$methodCallName = StringUtils::underscoreToCamelCase($key);
|
||||
}
|
||||
if (\in_array($key, [SecurityConfigKey::ACCESS_DECISION_MANAGER, SecurityConfigKey::ENTITY])) {
|
||||
$mainMethodName = StringUtils::underscoreToCamelCase($key);
|
||||
$accessDecisionManagerMethodCalls = $this->securityAccessDecisionManagerConfigArrayHandler->handle($configurationArray, $configVariable, $mainMethodName);
|
||||
if ($accessDecisionManagerMethodCalls !== []) {
|
||||
$methodCallStmts = \array_merge($methodCallStmts, $accessDecisionManagerMethodCalls);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ($splitMany) {
|
||||
foreach ($value as $itemName => $itemConfiguration) {
|
||||
$fluentMethodCall = $this->createNextMethodCall([$itemName, $itemConfiguration], $configVariable, $methodCallName);
|
||||
$methodCallStmts[] = new Expression($fluentMethodCall);
|
||||
$nextMethodCallExpressions = $this->nestedConfigCallsFactory->create([$itemName, $itemConfiguration], $configVariable, $methodCallName);
|
||||
$methodCallStmts = \array_merge($methodCallStmts, $nextMethodCallExpressions);
|
||||
}
|
||||
} else {
|
||||
// skip empty values
|
||||
if ($value === null) {
|
||||
continue;
|
||||
}
|
||||
$fluentMethodCall = $this->createNextMethodCall([$value], $configVariable, $methodCallName);
|
||||
$methodCallStmts[] = new Expression($fluentMethodCall);
|
||||
$simpleMethodName = StringUtils::underscoreToCamelCase($key);
|
||||
$args = $this->nodeFactory->createArgs([$value]);
|
||||
$methodCall = new MethodCall($configVariable, $simpleMethodName, $args);
|
||||
$methodCallStmts[] = new Expression($methodCall);
|
||||
}
|
||||
}
|
||||
return $methodCallStmts;
|
||||
}
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
private function createNextMethodCall($value, Variable $configVariable, string $methodCallName) : MethodCall
|
||||
{
|
||||
$args = $this->nodeFactory->createArgs($value);
|
||||
return new MethodCall($configVariable, $methodCallName, $args);
|
||||
}
|
||||
private function createConfigVariable(string $configClass) : Variable
|
||||
{
|
||||
$variableName = $this->propertyNaming->fqnToVariableName($configClass);
|
||||
return new Variable($variableName);
|
||||
}
|
||||
private function createConfigParam(string $configClass) : Param
|
||||
{
|
||||
$configVariable = $this->createConfigVariable($configClass);
|
||||
$fullyQualified = new FullyQualified($configClass);
|
||||
return new Param($configVariable, null, $fullyQualified);
|
||||
}
|
||||
private function createCamelCaseFromUnderscored(string $value) : string
|
||||
{
|
||||
$uppercaseWords = \ucwords($value, '_');
|
||||
$pascalCaseName = \str_replace('_', '', $uppercaseWords);
|
||||
return \lcfirst($pascalCaseName);
|
||||
}
|
||||
}
|
||||
|
45
vendor/rector/rector-symfony/rules/Configs/ConfigArrayHandler/NestedConfigCallsFactory.php
vendored
Normal file
45
vendor/rector/rector-symfony/rules/Configs/ConfigArrayHandler/NestedConfigCallsFactory.php
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Symfony\Configs\ConfigArrayHandler;
|
||||
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use Rector\PhpParser\Node\NodeFactory;
|
||||
final class NestedConfigCallsFactory
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PhpParser\Node\NodeFactory
|
||||
*/
|
||||
private $nodeFactory;
|
||||
public function __construct(NodeFactory $nodeFactory)
|
||||
{
|
||||
$this->nodeFactory = $nodeFactory;
|
||||
}
|
||||
/**
|
||||
* @param mixed[] $values
|
||||
* @return array<Expression<MethodCall>>
|
||||
*/
|
||||
public function create(array $values, Variable $configVariable, string $mainMethodName) : array
|
||||
{
|
||||
unset($values[0]);
|
||||
$methodCallStmts = [];
|
||||
foreach ($values as $value) {
|
||||
// build accessControl() method call here
|
||||
$accessControlMethodCall = new MethodCall($configVariable, $mainMethodName);
|
||||
foreach ($value as $methodName => $parameters) {
|
||||
// method correction
|
||||
if ($methodName === 'role') {
|
||||
$methodName = 'roles';
|
||||
$parameters = [$parameters];
|
||||
}
|
||||
$args = $this->nodeFactory->createArgs([$parameters]);
|
||||
$accessControlMethodCall = new MethodCall($accessControlMethodCall, $methodName, $args);
|
||||
}
|
||||
$methodCallStmts[] = new Expression($accessControlMethodCall);
|
||||
}
|
||||
return $methodCallStmts;
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Symfony\Configs\ConfigArrayHandler;
|
||||
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\Array_;
|
||||
use PhpParser\Node\Expr\ArrayItem;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
final class SecurityAccessDecisionManagerConfigArrayHandler
|
||||
{
|
||||
/**
|
||||
* @return array<Expression<MethodCall>>
|
||||
*/
|
||||
public function handle(Array_ $array, Variable $configVariable, string $mainMethodName) : array
|
||||
{
|
||||
if (!$array->items[0] instanceof ArrayItem) {
|
||||
return [];
|
||||
}
|
||||
$configurationArrayItem = $array->items[0];
|
||||
$nestedArray = $configurationArrayItem->value;
|
||||
if (!$nestedArray instanceof Array_) {
|
||||
return [];
|
||||
}
|
||||
// build accessControl() method call here
|
||||
$accessDecisionManagerMethodCall = new MethodCall($configVariable, $mainMethodName);
|
||||
foreach ($nestedArray->items as $nestedArrayItem) {
|
||||
if (!$nestedArrayItem instanceof ArrayItem) {
|
||||
continue;
|
||||
}
|
||||
if (!$nestedArrayItem->key instanceof String_) {
|
||||
continue;
|
||||
}
|
||||
$methodNameString = $nestedArrayItem->key;
|
||||
$methodName = $methodNameString->value;
|
||||
$args = [new Arg($nestedArrayItem->value)];
|
||||
$accessDecisionManagerMethodCall = new MethodCall($accessDecisionManagerMethodCall, $methodName, $args);
|
||||
}
|
||||
return [new Expression($accessDecisionManagerMethodCall)];
|
||||
}
|
||||
}
|
20
vendor/rector/rector-symfony/rules/Configs/Enum/SecurityConfigKey.php
vendored
Normal file
20
vendor/rector/rector-symfony/rules/Configs/Enum/SecurityConfigKey.php
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Symfony\Configs\Enum;
|
||||
|
||||
final class SecurityConfigKey
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const ACCESS_CONTROL = 'access_control';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const ACCESS_DECISION_MANAGER = 'access_decision_manager';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const ENTITY = 'entity';
|
||||
}
|
14
vendor/rector/rector-symfony/src/Utils/StringUtils.php
vendored
Normal file
14
vendor/rector/rector-symfony/src/Utils/StringUtils.php
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Symfony\Utils;
|
||||
|
||||
final class StringUtils
|
||||
{
|
||||
public static function underscoreToCamelCase(string $value) : string
|
||||
{
|
||||
$value = \ucwords(\str_replace(['-', '_'], ' ', $value));
|
||||
$singleWord = \str_replace(' ', '', $value);
|
||||
return \lcfirst($singleWord);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user