mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-03 18:00:50 +00:00
Updated Rector to commit 30afbb8da236ab0935851b91a7fb4b5cf26aa2e8
30afbb8da2
Fix StrContainsRector when strpos offset is set (#3086)
This commit is contained in:
parent
8a05dae6dd
commit
fde9488adf
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 ComposerAutoloaderInit13712cf436d21e014b674acb29e2cadc::getLoader();
|
||||
return ComposerAutoloaderInitd2fde544af9359dafa338eef6a489356::getLoader();
|
||||
|
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
|
@ -2530,6 +2530,7 @@ return array(
|
|||
'Rector\\Symfony\\Rector\\MethodCall\\ReadOnlyOptionToAttributeRector' => $vendorDir . '/rector/rector-symfony/src/Rector/MethodCall/ReadOnlyOptionToAttributeRector.php',
|
||||
'Rector\\Symfony\\Rector\\MethodCall\\RedirectToRouteRector' => $vendorDir . '/rector/rector-symfony/src/Rector/MethodCall/RedirectToRouteRector.php',
|
||||
'Rector\\Symfony\\Rector\\MethodCall\\ReflectionExtractorEnableMagicCallExtractorRector' => $vendorDir . '/rector/rector-symfony/src/Rector/MethodCall/ReflectionExtractorEnableMagicCallExtractorRector.php',
|
||||
'Rector\\Symfony\\Rector\\MethodCall\\SimplifyFormRenderingRector' => $vendorDir . '/rector/rector-symfony/src/Rector/MethodCall/SimplifyFormRenderingRector.php',
|
||||
'Rector\\Symfony\\Rector\\MethodCall\\StringFormTypeToClassRector' => $vendorDir . '/rector/rector-symfony/src/Rector/MethodCall/StringFormTypeToClassRector.php',
|
||||
'Rector\\Symfony\\Rector\\MethodCall\\SwiftCreateMessageToNewEmailRector' => $vendorDir . '/rector/rector-symfony/src/Rector/MethodCall/SwiftCreateMessageToNewEmailRector.php',
|
||||
'Rector\\Symfony\\Rector\\MethodCall\\SwiftSetBodyToHtmlPlainMethodCallRector' => $vendorDir . '/rector/rector-symfony/src/Rector/MethodCall/SwiftSetBodyToHtmlPlainMethodCallRector.php',
|
||||
|
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit13712cf436d21e014b674acb29e2cadc
|
||||
class ComposerAutoloaderInitd2fde544af9359dafa338eef6a489356
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,19 +22,19 @@ class ComposerAutoloaderInit13712cf436d21e014b674acb29e2cadc
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit13712cf436d21e014b674acb29e2cadc', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitd2fde544af9359dafa338eef6a489356', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit13712cf436d21e014b674acb29e2cadc', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitd2fde544af9359dafa338eef6a489356', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit13712cf436d21e014b674acb29e2cadc::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitd2fde544af9359dafa338eef6a489356::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit13712cf436d21e014b674acb29e2cadc::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInitd2fde544af9359dafa338eef6a489356::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire13712cf436d21e014b674acb29e2cadc($fileIdentifier, $file);
|
||||
composerRequired2fde544af9359dafa338eef6a489356($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
|
@ -46,7 +46,7 @@ class ComposerAutoloaderInit13712cf436d21e014b674acb29e2cadc
|
|||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire13712cf436d21e014b674acb29e2cadc($fileIdentifier, $file)
|
||||
function composerRequired2fde544af9359dafa338eef6a489356($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 ComposerStaticInit13712cf436d21e014b674acb29e2cadc
|
||||
class ComposerStaticInitd2fde544af9359dafa338eef6a489356
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -2775,6 +2775,7 @@ class ComposerStaticInit13712cf436d21e014b674acb29e2cadc
|
|||
'Rector\\Symfony\\Rector\\MethodCall\\ReadOnlyOptionToAttributeRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/MethodCall/ReadOnlyOptionToAttributeRector.php',
|
||||
'Rector\\Symfony\\Rector\\MethodCall\\RedirectToRouteRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/MethodCall/RedirectToRouteRector.php',
|
||||
'Rector\\Symfony\\Rector\\MethodCall\\ReflectionExtractorEnableMagicCallExtractorRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/MethodCall/ReflectionExtractorEnableMagicCallExtractorRector.php',
|
||||
'Rector\\Symfony\\Rector\\MethodCall\\SimplifyFormRenderingRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/MethodCall/SimplifyFormRenderingRector.php',
|
||||
'Rector\\Symfony\\Rector\\MethodCall\\StringFormTypeToClassRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/MethodCall/StringFormTypeToClassRector.php',
|
||||
'Rector\\Symfony\\Rector\\MethodCall\\SwiftCreateMessageToNewEmailRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/MethodCall/SwiftCreateMessageToNewEmailRector.php',
|
||||
'Rector\\Symfony\\Rector\\MethodCall\\SwiftSetBodyToHtmlPlainMethodCallRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/MethodCall/SwiftSetBodyToHtmlPlainMethodCallRector.php',
|
||||
|
@ -3035,9 +3036,9 @@ class ComposerStaticInit13712cf436d21e014b674acb29e2cadc
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit13712cf436d21e014b674acb29e2cadc::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit13712cf436d21e014b674acb29e2cadc::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit13712cf436d21e014b674acb29e2cadc::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitd2fde544af9359dafa338eef6a489356::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitd2fde544af9359dafa338eef6a489356::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitd2fde544af9359dafa338eef6a489356::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
|
@ -2061,12 +2061,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
|
||||
"reference": "3192dc8e398fc33feb4d6b8366cb5d434e8444d1"
|
||||
"reference": "c9f5808676cfb5e92c775a8db424f5593f853298"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/3192dc8e398fc33feb4d6b8366cb5d434e8444d1",
|
||||
"reference": "3192dc8e398fc33feb4d6b8366cb5d434e8444d1",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/c9f5808676cfb5e92c775a8db424f5593f853298",
|
||||
"reference": "c9f5808676cfb5e92c775a8db424f5593f853298",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2097,7 +2097,7 @@
|
|||
"symplify\/rule-doc-generator": "^11.1",
|
||||
"symplify\/vendor-patches": "^11.1"
|
||||
},
|
||||
"time": "2022-11-21T16:08:59+00:00",
|
||||
"time": "2022-11-22T20:01:10+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 bf394ee'), '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 d5a52d6'), '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 9ea5f62'), '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 769064f'), '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 3192dc8'));
|
||||
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 bf394ee'), '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 d5a52d6'), '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 9ea5f62'), '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 769064f'), '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 c9f5808'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ return static function (RectorConfig $rectorConfig) : void {
|
|||
// @see https://symfony.com/blog/new-in-symfony-5-2-php-8-attributes
|
||||
new AnnotationToAttribute('required', 'Symfony\\Contracts\\Service\\Attribute\\Required'),
|
||||
new AnnotationToAttribute('Symfony\\Component\\Routing\\Annotation\\Route'),
|
||||
// see Symfony 5.2+ https://github.com/symfony/doctrine-bridge/commit/02d2cf4743331e6b69ffd1d68e09b7e2dc417201#diff-1a16e2739e51eab000116d0542bd0226cea59a6d64711740ed7ce14769f95d1b
|
||||
// @see Symfony 5.2+ https://github.com/symfony/doctrine-bridge/commit/02d2cf4743331e6b69ffd1d68e09b7e2dc417201#diff-1a16e2739e51eab000116d0542bd0226cea59a6d64711740ed7ce14769f95d1b
|
||||
new AnnotationToAttribute('Symfony\\Bridge\\Doctrine\\Validator\\Constraints\\UniqueEntity'),
|
||||
]);
|
||||
};
|
||||
|
|
|
@ -10,7 +10,7 @@ use Rector\Symfony\Rector\StaticCall\ParseFileRector;
|
|||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->rule(ParseFileRector::class);
|
||||
$rectorConfig->ruleWithConfiguration(ReplaceArgumentDefaultValueRector::class, [
|
||||
// https://github.com/symfony/symfony/commit/912fc4de8fd6de1e5397be4a94d39091423e5188
|
||||
// @see https://github.com/symfony/symfony/commit/912fc4de8fd6de1e5397be4a94d39091423e5188
|
||||
new ReplaceArgumentDefaultValue('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface', 'generate', 2, \true, 'Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface::ABSOLUTE_URL'),
|
||||
new ReplaceArgumentDefaultValue('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface', 'generate', 2, \false, 'Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface::ABSOLUTE_PATH'),
|
||||
new ReplaceArgumentDefaultValue('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface', 'generate', 2, 'relative', 'Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface::RELATIVE_PATH'),
|
||||
|
|
|
@ -39,7 +39,7 @@ return static function (RectorConfig $rectorConfig) : void {
|
|||
'Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerAwareCommand' => 'Symfony\\Component\\Console\\Command\\Command',
|
||||
'Symfony\\Component\\Translation\\TranslatorInterface' => 'Symfony\\Contracts\\Translation\\TranslatorInterface',
|
||||
]);
|
||||
# related to "Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand" deprecation, see https://github.com/rectorphp/rector/issues/1629
|
||||
# related to "Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand" deprecation, @see https://github.com/rectorphp/rector/issues/1629
|
||||
$rectorConfig->rule(ContainerGetToConstructorInjectionRector::class);
|
||||
# https://symfony.com/blog/new-in-symfony-4-2-important-deprecations
|
||||
$rectorConfig->rule(StringToArrayArgumentProcessRector::class);
|
||||
|
|
|
@ -16,13 +16,13 @@ use PHPStan\Type\UnionType;
|
|||
use Rector\Config\RectorConfig;
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector;
|
||||
use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration;
|
||||
# see https://symfony.com/blog/symfony-type-declarations-return-types-and-phpunit-compatibility
|
||||
# @see https://symfony.com/blog/symfony-type-declarations-return-types-and-phpunit-compatibility
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$arrayType = new ArrayType(new MixedType(), new MixedType());
|
||||
$iterableType = new IterableType(new MixedType(), new MixedType());
|
||||
$nullableStringType = new UnionType([new StringType(), new NullType()]);
|
||||
$rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [
|
||||
// see https://github.com/symfony/symfony/issues/32179
|
||||
// @see https://github.com/symfony/symfony/issues/32179
|
||||
new AddParamTypeDeclaration('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', 'addListener', 0, new StringType()),
|
||||
new AddParamTypeDeclaration('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', 'addListener', 2, new IntegerType()),
|
||||
new AddParamTypeDeclaration('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', 'removeListener', 0, new StringType()),
|
||||
|
|
|
@ -24,23 +24,29 @@ use Rector\Transform\ValueObject\StaticCallToNew;
|
|||
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector;
|
||||
use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
// see https://github.com/symfony/symfony/pull/36243
|
||||
// @see https://github.com/symfony/symfony/pull/36243
|
||||
$rectorConfig->rule(LogoutHandlerToLogoutEventSubscriberRector::class);
|
||||
$rectorConfig->rule(LogoutSuccessHandlerToLogoutEventSubscriberRector::class);
|
||||
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, [
|
||||
'Symfony\\Component\\EventDispatcher\\LegacyEventDispatcherProxy' => 'Symfony\\Component\\EventDispatcher\\EventDispatcherInterface',
|
||||
'Symfony\\Component\\Form\\Extension\\Validator\\Util\\ServerParams' => 'Symfony\\Component\\Form\\Util\\ServerParams',
|
||||
// see https://github.com/symfony/symfony/pull/35092
|
||||
// @see https://github.com/symfony/symfony/pull/35092
|
||||
'Symfony\\Component\\Inflector' => 'Symfony\\Component\\String\\Inflector\\InflectorInterface',
|
||||
]);
|
||||
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Symfony\\Component\\Config\\Definition\\BaseNode', 'getDeprecationMessage', 'getDeprecation'), new MethodCallRename('Symfony\\Component\\DependencyInjection\\Definition', 'getDeprecationMessage', 'getDeprecation'), new MethodCallRename('Symfony\\Component\\DependencyInjection\\Alias', 'getDeprecationMessage', 'getDeprecation')]);
|
||||
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
|
||||
new MethodCallRename('Symfony\\Component\\Config\\Definition\\BaseNode', 'getDeprecationMessage', 'getDeprecation'),
|
||||
new MethodCallRename('Symfony\\Component\\DependencyInjection\\Definition', 'getDeprecationMessage', 'getDeprecation'),
|
||||
new MethodCallRename('Symfony\\Component\\DependencyInjection\\Alias', 'getDeprecationMessage', 'getDeprecation'),
|
||||
// @see https://github.com/symfony/symfony/pull/35828
|
||||
new MethodCallRename('Symfony\\Component\\Notifier\\Bridge\\Slack\\Slack', 'channel', 'recipient'),
|
||||
]);
|
||||
$rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, ['Symfony\\Component\\DependencyInjection\\Loader\\Configuraton\\inline' => 'Symfony\\Component\\DependencyInjection\\Loader\\Configuraton\\inline_service', 'Symfony\\Component\\DependencyInjection\\Loader\\Configuraton\\ref' => 'Symfony\\Component\\DependencyInjection\\Loader\\Configuraton\\service']);
|
||||
// see https://symfony.com/blog/new-in-symfony-5-1-misc-improvements-part-1#added-constants-for-command-exit-codes
|
||||
// @see https://symfony.com/blog/new-in-symfony-5-1-misc-improvements-part-1#added-constants-for-command-exit-codes
|
||||
$rectorConfig->rule(CommandConstantReturnCodeRector::class);
|
||||
// https://github.com/symfony/symfony/pull/35308
|
||||
// @see https://github.com/symfony/symfony/pull/35308
|
||||
$rectorConfig->ruleWithConfiguration(NewArgToMethodCallRector::class, [new NewArgToMethodCall('Symfony\\Component\\Dotenv\\Dotenv', \true, 'usePutenv')]);
|
||||
$rectorConfig->ruleWithConfiguration(RenameClassConstFetchRector::class, [new RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_FLOOR', 'NumberFormatter', 'ROUND_FLOOR'), new RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_DOWN', 'NumberFormatter', 'ROUND_DOWN'), new RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_HALF_DOWN', 'NumberFormatter', 'ROUND_HALFDOWN'), new RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_HALF_EVEN', 'NumberFormatter', 'ROUND_HALFEVEN'), new RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_HALFUP', 'NumberFormatter', 'ROUND_HALFUP'), new RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_UP', 'NumberFormatter', 'ROUND_UP'), new RenameClassAndConstFetch('Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer', 'ROUND_CEILING', 'NumberFormatter', 'ROUND_CEILING')]);
|
||||
// see https://github.com/symfony/symfony/pull/36943
|
||||
// @see https://github.com/symfony/symfony/pull/36943
|
||||
$rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [new AddParamTypeDeclaration('Symfony\\Bundle\\FrameworkBundle\\Kernel\\MicroKernelTrait', 'configureRoutes', 0, new ObjectType('Symfony\\Component\\Routing\\Loader\\Configurator\\RoutingConfigurator'))]);
|
||||
$rectorConfig->ruleWithConfiguration(StaticCallToNewRector::class, [new StaticCallToNew('Symfony\\Component\\HttpFoundation\\Response', 'create'), new StaticCallToNew('Symfony\\Component\\HttpFoundation\\JsonResponse', 'create'), new StaticCallToNew('Symfony\\Component\\HttpFoundation\\RedirectResponse', 'create'), new StaticCallToNew('Symfony\\Component\\HttpFoundation\\StreamedResponse', 'create')]);
|
||||
$rectorConfig->ruleWithConfiguration(RenameStringRector::class, [
|
||||
|
|
|
@ -4,8 +4,14 @@ declare (strict_types=1);
|
|||
namespace RectorPrefix202211;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector;
|
||||
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\MethodCall\SimplifyFormRenderingRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->rule(SimplifyFormRenderingRector::class);
|
||||
// https://symfony.com/blog/new-in-symfony-6-2-built-in-cache-security-template-and-doctrine-attributes
|
||||
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, [
|
||||
// @see https://github.com/symfony/symfony/pull/46907
|
||||
|
@ -14,5 +20,30 @@ return static function (RectorConfig $rectorConfig) : void {
|
|||
'Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Cache' => 'Symfony\\Component\\HttpKernel\\Attribute\\Cache',
|
||||
// @see https://github.com/symfony/symfony/pull/46906
|
||||
'Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Template' => 'Symfony\\Bridge\\Twig\\Attribute\\Template',
|
||||
// @see https://github.com/symfony/symfony/pull/46714
|
||||
'Symfony\\Component\\Mailer\\Bridge\\OhMySmtp\\Transport\\OhMySmtpApiTransport' => 'Symfony\\Component\\Mailer\\Bridge\\MailPace\\Transport\\MailPaceApiTransport',
|
||||
'Symfony\\Component\\Mailer\\Bridge\\OhMySmtp\\Transport\\OhMySmtpSmtpTransport' => 'Symfony\\Component\\Mailer\\Bridge\\MailPace\\Transport\\MailPaceSmtpTransport',
|
||||
'Symfony\\Component\\Mailer\\Bridge\\OhMySmtp\\Transport\\OhMySmtpTransportFactory' => 'Symfony\\Component\\Mailer\\Bridge\\MailPace\\Transport\\MailPaceTransportFactory',
|
||||
// @see https://github.com/symfony/symfony/pull/47363
|
||||
'Symfony\\Component\\HttpKernel\\Controller\\ArgumentValueResolverInterface' => 'Symfony\\Component\\HttpKernel\\Controller\\ValueResolverInterface',
|
||||
// @see https://github.com/symfony/symfony/pull/46094
|
||||
'Symfony\\Component\\Security\\Core\\Security' => 'Symfony\\Bundle\\SecurityBundle\\Security\\Security',
|
||||
// @see https://github.com/symfony/symfony/pull/46161
|
||||
'Symfony\\Component\\Translation\\Extractor\\PhpAstExtractor' => 'Symfony\\Component\\Translation\\Extractor\\PhpAstExtractor',
|
||||
// @see https://github.com/symfony/symfony/pull/47595
|
||||
'Symfony\\Component\\HttpFoundation\\ExpressionRequestMatcher' => 'Symfony\\Component\\HttpFoundation\\RequestMatcher\\ExpressionRequestMatcher',
|
||||
'Symfony\\Component\\HttpFoundation\\RequestMatcher' => 'Symfony\\Component\\HttpFoundation\\RequestMatcher\\ChainRequestMatcher',
|
||||
]);
|
||||
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
|
||||
// @see https://github.com/symfony/symfony/pull/46854
|
||||
new MethodCallRename('Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController', 'renderForm', 'render'),
|
||||
// @see https://github.com/symfony/symfony/pull/45034
|
||||
new MethodCallRename('Symfony\\Component\\HttpFoundation\\Request', 'getContentType', 'getContentTypeFormat'),
|
||||
// @see https://github.com/symfony/symfony/pull/47711
|
||||
new MethodCallRename('Symfony\\Component\\Mime\\Email', 'attachPart', 'addPart'),
|
||||
// @see https://github.com/symfony/symfony/pull/47363
|
||||
new MethodCallRename('Symfony\\Component\\HttpFoundation\\Request', 'supports', 'resolve'),
|
||||
]);
|
||||
// @see https://github.com/symfony/symfony/pull/46094
|
||||
$rectorConfig->ruleWithConfiguration(RenameClassConstFetchRector::class, [new RenameClassAndConstFetch('Symfony\\Component\\Security\\Core\\Security', 'ACCESS_DENIED_ERROR', 'Symfony\\Bundle\\SecurityBundle\\Security', 'ACCESS_DENIED_ERROR'), new RenameClassAndConstFetch('Symfony\\Component\\Security\\Core\\Security', 'AUTHENTICATION_ERROR', 'Symfony\\Bundle\\SecurityBundle\\Security', 'AUTHENTICATION_ERROR'), new RenameClassAndConstFetch('Symfony\\Component\\Security\\Core\\Security', 'LAST_USERNAME', 'Symfony\\Bundle\\SecurityBundle\\Security', 'LAST_USERNAME'), new RenameClassAndConstFetch('Symfony\\Component\\Security\\Core\\Security', 'MAX_USERNAME_LENGTH', 'Symfony\\Component\\Security\\Http\\Authenticator\\Passport\\Badge\\UserBadge', 'MAX_USERNAME_LENGTH')]);
|
||||
};
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace RectorPrefix202211;
|
|||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Renaming\Rector\Name\RenameClassRector;
|
||||
# see https://stackoverflow.com/a/43495506/1348344
|
||||
# @see https://stackoverflow.com/a/43495506/1348344
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['Twig_Function_Node' => 'Twig_SimpleFunction', 'Twig_Function' => 'Twig_SimpleFunction', 'Twig_Filter' => 'Twig_SimpleFilter', 'Twig_Test' => 'Twig_SimpleTest']);
|
||||
};
|
||||
|
|
|
@ -8,12 +8,12 @@ use Rector\Renaming\Rector\Name\RenameClassRector;
|
|||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, [
|
||||
#filters
|
||||
# see https://twig.symfony.com/doc/1.x/deprecated.html
|
||||
# @see https://twig.symfony.com/doc/1.x/deprecated.html
|
||||
'Twig_SimpleFilter' => 'Twig_Filter',
|
||||
#functions
|
||||
# see https://twig.symfony.com/doc/1.x/deprecated.html
|
||||
# @see https://twig.symfony.com/doc/1.x/deprecated.html
|
||||
'Twig_SimpleFunction' => 'Twig_Function',
|
||||
# see https://github.com/bolt/bolt/pull/6596
|
||||
# @see https://github.com/bolt/bolt/pull/6596
|
||||
'Twig_SimpleTest' => 'Twig_Test',
|
||||
]);
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# 72 Rules Overview
|
||||
# 74 Rules Overview
|
||||
|
||||
## ActionSuffixRemoverRector
|
||||
|
||||
|
@ -255,19 +255,17 @@ Change type in CollectionType from alias string to class reference
|
|||
|
||||
Changes int return from execute to use Symfony Command constants.
|
||||
|
||||
-
|
||||
class: [`Rector\Symfony\Rector\ClassMethod\CommandConstantReturnCodeRector`](../src/Rector/ClassMethod/CommandConstantReturnCodeRector.php)
|
||||
- class: [`Rector\Symfony\Rector\ClassMethod\CommandConstantReturnCodeRector`](../src/Rector/ClassMethod/CommandConstantReturnCodeRector.php)
|
||||
|
||||
```diff
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class SomeCommand extends Command
|
||||
{
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
- return 0;
|
||||
+ return Command::SUCCESS;
|
||||
- return 0;
|
||||
+ return Command::SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -275,22 +273,21 @@ class: [`Rector\Symfony\Rector\ClassMethod\CommandConstantReturnCodeRector`](../
|
|||
|
||||
## CommandDescriptionToPropertyRector
|
||||
|
||||
Moves Command description setter to defaultDescription property
|
||||
Symfony Command description setters are moved to properties
|
||||
|
||||
-
|
||||
class: [`Rector\Symfony\Rector\Class_\CommandDescriptionToPropertyRector`](../src/Rector/Class_/CommandDescriptionToPropertyRector.php)
|
||||
- class: [`Rector\Symfony\Rector\Class_\CommandDescriptionToPropertyRector`](../src/Rector/Class_/CommandDescriptionToPropertyRector.php)
|
||||
|
||||
```diff
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Command\Command
|
||||
|
||||
final class SunshineCommand extends Command
|
||||
{
|
||||
protected static $defaultName = 'sunshine';
|
||||
+ protected static $defaultDescription = 'sunshine description';
|
||||
public function configure()
|
||||
{
|
||||
protected static $defaultName = 'sunshine';
|
||||
+ protected static $defaultDescription = 'sunshine description';
|
||||
public function configure()
|
||||
{
|
||||
- $this->setDescription('sunshine description');
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -1259,21 +1256,21 @@ Remove service from Sensio `@Route`
|
|||
|
||||
## RemoveUnusedRequestParamRector
|
||||
|
||||
Remove unused $request parameter from controller action
|
||||
Remove unused `$request` parameter from controller action
|
||||
|
||||
- class: [`Rector\Symfony\Rector\ClassMethod\RemoveUnusedRequestParamRector`](../src/Rector/ClassMethod/RemoveUnusedRequestParamRector.php)
|
||||
|
||||
```diff
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
|
||||
final class SomeController extends Controller
|
||||
{
|
||||
final class SomeController extends Controller
|
||||
{
|
||||
- public function run(Request $request, int $id)
|
||||
+ public function run(int $id)
|
||||
{
|
||||
echo $id;
|
||||
}
|
||||
{
|
||||
echo $id;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -1505,6 +1502,27 @@ Changes Twig_Function_Method to Twig_SimpleFunction calls in Twig_Extension.
|
|||
|
||||
<br>
|
||||
|
||||
## SimplifyFormRenderingRector
|
||||
|
||||
Symplify form rendering by not calling `->createView()` on `render` function
|
||||
|
||||
- class: [`Rector\Symfony\Rector\MethodCall\SimplifyFormRenderingRector`](../src/Rector/MethodCall/SimplifyFormRenderingRector.php)
|
||||
|
||||
```diff
|
||||
class ReplaceFormCreateViewFunctionCall extends AbstractController
|
||||
{
|
||||
public function form(): Response
|
||||
{
|
||||
return $this->render('form.html.twig', [
|
||||
- 'form' => $form->createView(),
|
||||
+ 'form' => $form,
|
||||
]);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## StringFormTypeToClassRector
|
||||
|
||||
Turns string Form Type references to their CONSTANT alternatives in FormTypes in Form in Symfony. To enable custom types, add link to your container XML dump in "$rectorConfig->symfonyContainerXml(...)"
|
||||
|
|
108
vendor/rector/rector-symfony/src/Rector/MethodCall/SimplifyFormRenderingRector.php
vendored
Normal file
108
vendor/rector/rector-symfony/src/Rector/MethodCall/SimplifyFormRenderingRector.php
vendored
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Symfony\Rector\MethodCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\Array_;
|
||||
use PhpParser\Node\Expr\ArrayItem;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Symfony\Tests\Rector\MethodCall\SimplifyFormRenderingRector\SimplifyFormRenderingRectorTest
|
||||
*/
|
||||
final class SimplifyFormRenderingRector extends AbstractRector
|
||||
{
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Symplify form rendering by not calling `->createView()` on `render` function', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
class ReplaceFormCreateViewFunctionCall extends AbstractController
|
||||
{
|
||||
public function form(): Response
|
||||
{
|
||||
return $this->render('form.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
class ReplaceFormCreateViewFunctionCall extends AbstractController
|
||||
{
|
||||
public function form(): Response
|
||||
{
|
||||
return $this->render('form.html.twig', [
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [MethodCall::class];
|
||||
}
|
||||
/**
|
||||
* @param MethodCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (!$this->isObjectType($node->var, new ObjectType('Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController'))) {
|
||||
return null;
|
||||
}
|
||||
if ($node->isFirstClassCallable()) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isName($node->name, 'render')) {
|
||||
return null;
|
||||
}
|
||||
if (!isset($node->args[1])) {
|
||||
return null;
|
||||
}
|
||||
/** @var Arg $arg */
|
||||
$arg = $node->args[1];
|
||||
if (!$arg->value instanceof Array_) {
|
||||
return null;
|
||||
}
|
||||
$methodCallOrNull = $this->processRemoveCreateView($arg->value->items);
|
||||
if ($methodCallOrNull === null) {
|
||||
return null;
|
||||
}
|
||||
$arg->value->items = $methodCallOrNull;
|
||||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param ArrayItem[]|null[] $arrayItems
|
||||
*
|
||||
* @return array<ArrayItem|null>|null
|
||||
*/
|
||||
private function processRemoveCreateView(array $arrayItems) : ?array
|
||||
{
|
||||
$replaced = \false;
|
||||
foreach ($arrayItems as $arrayItem) {
|
||||
if (!$arrayItem instanceof ArrayItem) {
|
||||
continue;
|
||||
}
|
||||
if (!$arrayItem->value instanceof MethodCall) {
|
||||
continue;
|
||||
}
|
||||
if (!$this->isObjectType($arrayItem->value->var, new ObjectType('Symfony\\Component\\Form\\FormInterface'))) {
|
||||
continue;
|
||||
}
|
||||
$replaced = \true;
|
||||
$arrayItem->value = $arrayItem->value->var;
|
||||
}
|
||||
if (!$replaced) {
|
||||
return null;
|
||||
}
|
||||
return $arrayItems;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user