Updated Rector to commit 2d13bc9773c3b7b91598312087c236c14b002d28

2d13bc9773 Remove NewArgToMethodCallRector as unused (#4130)
This commit is contained in:
Tomas Votruba 2023-06-08 23:27:12 +00:00
parent 2c295def16
commit c0ebeabf68
12 changed files with 21 additions and 211 deletions

View File

@ -1,4 +1,4 @@
# 372 Rules Overview
# 371 Rules Overview
<br>
@ -56,7 +56,7 @@
- [Strict](#strict) (5)
- [Transform](#transform) (23)
- [Transform](#transform) (22)
- [TypeDeclaration](#typedeclaration) (40)
@ -950,7 +950,7 @@ Change unsafe new `static()` to new `self()`
- class: [`Rector\CodeQuality\Rector\New_\NewStaticToNewSelfRector`](../rules/CodeQuality/Rector/New_/NewStaticToNewSelfRector.php)
```diff
class SomeClass
final class SomeClass
{
public function build()
{
@ -7201,46 +7201,6 @@ return static function (RectorConfig $rectorConfig): void {
<br>
### NewArgToMethodCallRector
Change new with specific argument to method call
:wrench: **configure it!**
- class: [`Rector\Transform\Rector\New_\NewArgToMethodCallRector`](../rules/Transform/Rector/New_/NewArgToMethodCallRector.php)
```php
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\Transform\Rector\New_\NewArgToMethodCallRector;
use Rector\Transform\ValueObject\NewArgToMethodCall;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(NewArgToMethodCallRector::class, [
new NewArgToMethodCall('Dotenv', true, 'usePutenv'),
]);
};
```
```diff
class SomeClass
{
public function run()
{
- $dotenv = new Dotenv(true);
+ $dotenv = new Dotenv();
+ $dotenv->usePutenv();
}
}
```
<br>
### NewToStaticCallRector
Change new Object to static call

View File

@ -1,92 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Transform\Rector\New_;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\New_;
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Rector\Transform\ValueObject\NewArgToMethodCall;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
use RectorPrefix202306\Webmozart\Assert\Assert;
/**
* @changelog https://github.com/symfony/symfony/pull/35308
*
* @see \Rector\Tests\Transform\Rector\New_\NewArgToMethodCallRector\NewArgToMethodCallRectorTest
*/
final class NewArgToMethodCallRector extends AbstractRector implements ConfigurableRectorInterface
{
/**
* @var NewArgToMethodCall[]
*/
private $newArgsToMethodCalls = [];
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Change new with specific argument to method call', [new ConfiguredCodeSample(<<<'CODE_SAMPLE'
class SomeClass
{
public function run()
{
$dotenv = new Dotenv(true);
}
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
class SomeClass
{
public function run()
{
$dotenv = new Dotenv();
$dotenv->usePutenv();
}
}
CODE_SAMPLE
, [new NewArgToMethodCall('Dotenv', \true, 'usePutenv')])]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [New_::class];
}
/**
* @param New_ $node
*/
public function refactor(Node $node) : ?Node
{
if ($node->isFirstClassCallable()) {
return null;
}
foreach ($this->newArgsToMethodCalls as $newArgToMethodCall) {
if (!$this->isObjectType($node->class, $newArgToMethodCall->getObjectType())) {
continue;
}
if (!isset($node->getArgs()[0])) {
return null;
}
if (!$node->args[0] instanceof Arg) {
return null;
}
$firstArgValue = $node->args[0]->value;
if (!$this->valueResolver->isValue($firstArgValue, $newArgToMethodCall->getValue())) {
continue;
}
unset($node->args[0]);
return new MethodCall($node, $newArgToMethodCall->getMethodCall());
}
return null;
}
/**
* @param mixed[] $configuration
*/
public function configure(array $configuration) : void
{
Assert::allIsAOf($configuration, NewArgToMethodCall::class);
$this->newArgsToMethodCalls = $configuration;
}
}

View File

@ -1,51 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Transform\ValueObject;
use PHPStan\Type\ObjectType;
use Rector\Core\Validation\RectorAssert;
final class NewArgToMethodCall
{
/**
* @readonly
* @var string
*/
private $type;
/**
* @readonly
* @var mixed
*/
private $value;
/**
* @readonly
* @var string
*/
private $methodCall;
/**
* @param mixed $value
*/
public function __construct(string $type, $value, string $methodCall)
{
$this->type = $type;
$this->value = $value;
$this->methodCall = $methodCall;
RectorAssert::className($type);
RectorAssert::className($methodCall);
}
public function getObjectType() : ObjectType
{
return new ObjectType($this->type);
}
/**
* @return mixed
*/
public function getValue()
{
return $this->value;
}
public function getMethodCall() : string
{
return $this->methodCall;
}
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '82687502deb9d41ed79ed832baa09fe23f90d3f8';
public const PACKAGE_VERSION = '2d13bc9773c3b7b91598312087c236c14b002d28';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-06-08 23:01:25';
public const RELEASE_DATE = '2023-06-08 23:22:53';
/**
* @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 ComposerAutoloaderInitfdefce455bec7307ff935b4e2645f2c4::getLoader();
return ComposerAutoloaderInitb5c263e2bdede23be55119fc17d4c292::getLoader();

View File

@ -2740,7 +2740,6 @@ return array(
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToPropertyFetchRector' => $baseDir . '/rules/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector.php',
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToStaticCallRector' => $baseDir . '/rules/Transform/Rector/MethodCall/MethodCallToStaticCallRector.php',
'Rector\\Transform\\Rector\\MethodCall\\ReplaceParentCallByPropertyCallRector' => $baseDir . '/rules/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector.php',
'Rector\\Transform\\Rector\\New_\\NewArgToMethodCallRector' => $baseDir . '/rules/Transform/Rector/New_/NewArgToMethodCallRector.php',
'Rector\\Transform\\Rector\\New_\\NewToStaticCallRector' => $baseDir . '/rules/Transform/Rector/New_/NewToStaticCallRector.php',
'Rector\\Transform\\Rector\\StaticCall\\StaticCallToFuncCallRector' => $baseDir . '/rules/Transform/Rector/StaticCall/StaticCallToFuncCallRector.php',
'Rector\\Transform\\Rector\\StaticCall\\StaticCallToMethodCallRector' => $baseDir . '/rules/Transform/Rector/StaticCall/StaticCallToMethodCallRector.php',
@ -2753,7 +2752,6 @@ return array(
'Rector\\Transform\\ValueObject\\MethodCallToFuncCall' => $baseDir . '/rules/Transform/ValueObject/MethodCallToFuncCall.php',
'Rector\\Transform\\ValueObject\\MethodCallToPropertyFetch' => $baseDir . '/rules/Transform/ValueObject/MethodCallToPropertyFetch.php',
'Rector\\Transform\\ValueObject\\MethodCallToStaticCall' => $baseDir . '/rules/Transform/ValueObject/MethodCallToStaticCall.php',
'Rector\\Transform\\ValueObject\\NewArgToMethodCall' => $baseDir . '/rules/Transform/ValueObject/NewArgToMethodCall.php',
'Rector\\Transform\\ValueObject\\NewToStaticCall' => $baseDir . '/rules/Transform/ValueObject/NewToStaticCall.php',
'Rector\\Transform\\ValueObject\\ParentClassToTraits' => $baseDir . '/rules/Transform/ValueObject/ParentClassToTraits.php',
'Rector\\Transform\\ValueObject\\PropertyAssignToMethodCall' => $baseDir . '/rules/Transform/ValueObject/PropertyAssignToMethodCall.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitfdefce455bec7307ff935b4e2645f2c4
class ComposerAutoloaderInitb5c263e2bdede23be55119fc17d4c292
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInitfdefce455bec7307ff935b4e2645f2c4
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitfdefce455bec7307ff935b4e2645f2c4', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitb5c263e2bdede23be55119fc17d4c292', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitfdefce455bec7307ff935b4e2645f2c4', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitb5c263e2bdede23be55119fc17d4c292', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitfdefce455bec7307ff935b4e2645f2c4::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitb5c263e2bdede23be55119fc17d4c292::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInitfdefce455bec7307ff935b4e2645f2c4::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInitb5c263e2bdede23be55119fc17d4c292::$files;
$requireFile = \Closure::bind(static function ($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 ComposerStaticInitfdefce455bec7307ff935b4e2645f2c4
class ComposerStaticInitb5c263e2bdede23be55119fc17d4c292
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -2991,7 +2991,6 @@ class ComposerStaticInitfdefce455bec7307ff935b4e2645f2c4
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToPropertyFetchRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/MethodCall/MethodCallToPropertyFetchRector.php',
'Rector\\Transform\\Rector\\MethodCall\\MethodCallToStaticCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/MethodCall/MethodCallToStaticCallRector.php',
'Rector\\Transform\\Rector\\MethodCall\\ReplaceParentCallByPropertyCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/MethodCall/ReplaceParentCallByPropertyCallRector.php',
'Rector\\Transform\\Rector\\New_\\NewArgToMethodCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/New_/NewArgToMethodCallRector.php',
'Rector\\Transform\\Rector\\New_\\NewToStaticCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/New_/NewToStaticCallRector.php',
'Rector\\Transform\\Rector\\StaticCall\\StaticCallToFuncCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/StaticCall/StaticCallToFuncCallRector.php',
'Rector\\Transform\\Rector\\StaticCall\\StaticCallToMethodCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/StaticCall/StaticCallToMethodCallRector.php',
@ -3004,7 +3003,6 @@ class ComposerStaticInitfdefce455bec7307ff935b4e2645f2c4
'Rector\\Transform\\ValueObject\\MethodCallToFuncCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/MethodCallToFuncCall.php',
'Rector\\Transform\\ValueObject\\MethodCallToPropertyFetch' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/MethodCallToPropertyFetch.php',
'Rector\\Transform\\ValueObject\\MethodCallToStaticCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/MethodCallToStaticCall.php',
'Rector\\Transform\\ValueObject\\NewArgToMethodCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/NewArgToMethodCall.php',
'Rector\\Transform\\ValueObject\\NewToStaticCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/NewToStaticCall.php',
'Rector\\Transform\\ValueObject\\ParentClassToTraits' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/ParentClassToTraits.php',
'Rector\\Transform\\ValueObject\\PropertyAssignToMethodCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/PropertyAssignToMethodCall.php',
@ -3138,9 +3136,9 @@ class ComposerStaticInitfdefce455bec7307ff935b4e2645f2c4
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitfdefce455bec7307ff935b4e2645f2c4::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitfdefce455bec7307ff935b4e2645f2c4::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitfdefce455bec7307ff935b4e2645f2c4::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitb5c263e2bdede23be55119fc17d4c292::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitb5c263e2bdede23be55119fc17d4c292::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitb5c263e2bdede23be55119fc17d4c292::$classMap;
}, null, ClassLoader::class);
}

View File

@ -2125,12 +2125,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "24ff836bf6469a9afed88f5e9c745e04764d570f"
"reference": "59b8f1ede5dfa2f78617328cf18ee8374a5e2980"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/24ff836bf6469a9afed88f5e9c745e04764d570f",
"reference": "24ff836bf6469a9afed88f5e9c745e04764d570f",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/59b8f1ede5dfa2f78617328cf18ee8374a5e2980",
"reference": "59b8f1ede5dfa2f78617328cf18ee8374a5e2980",
"shasum": ""
},
"require": {
@ -2160,7 +2160,7 @@
"tomasvotruba\/type-coverage": "^0.2",
"tomasvotruba\/unused-public": "^0.1"
},
"time": "2023-06-08T16:37:42+00:00",
"time": "2023-06-08T23:14:37+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 08503e7'), '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 762ba3b'), '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 a842ca4'), '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 24ff836'));
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 08503e7'), '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 762ba3b'), '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 a842ca4'), '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 59b8f1e'));
private function __construct()
{
}

View File

@ -17,7 +17,6 @@ use Rector\Symfony\Rector\Class_\LogoutHandlerToLogoutEventSubscriberRector;
use Rector\Symfony\Rector\Class_\LogoutSuccessHandlerToLogoutEventSubscriberRector;
use Rector\Symfony\Rector\ClassMethod\CommandConstantReturnCodeRector;
use Rector\Symfony\Rector\ClassMethod\RouteCollectionBuilderToRoutingConfiguratorRector;
use Rector\Transform\Rector\New_\NewArgToMethodCallRector;
use Rector\Transform\Rector\StaticCall\StaticCallToNewRector;
use Rector\Transform\ValueObject\NewArgToMethodCall;
use Rector\Transform\ValueObject\StaticCallToNew;
@ -43,8 +42,6 @@ return static function (RectorConfig $rectorConfig) : void {
$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
$rectorConfig->rule(CommandConstantReturnCodeRector::class);
// @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
$rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, [new AddParamTypeDeclaration('Symfony\\Bundle\\FrameworkBundle\\Kernel\\MicroKernelTrait', 'configureRoutes', 0, new ObjectType('Symfony\\Component\\Routing\\Loader\\Configurator\\RoutingConfigurator'))]);