mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 21:38:22 +01:00
Updated Rector to commit 26550ca939279bf296f72b2457545c1a0ade3f8e
26550ca939
[Transform] Remove DimFetchAssignToMethodCallRector as unused (#3775)
This commit is contained in:
parent
fc5810aace
commit
dffd0b0f29
@ -7907,49 +7907,6 @@ return static function (RectorConfig $rectorConfig): void {
|
||||
|
||||
<br>
|
||||
|
||||
### DimFetchAssignToMethodCallRector
|
||||
|
||||
Change magic array access add to `$list[],` to explicit `$list->addMethod(...)`
|
||||
|
||||
:wrench: **configure it!**
|
||||
|
||||
- class: [`Rector\Transform\Rector\Assign\DimFetchAssignToMethodCallRector`](../rules/Transform/Rector/Assign/DimFetchAssignToMethodCallRector.php)
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Transform\Rector\Assign\DimFetchAssignToMethodCallRector;
|
||||
use Rector\Transform\ValueObject\DimFetchAssignToMethodCall;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
$rectorConfig->ruleWithConfiguration(DimFetchAssignToMethodCallRector::class, [
|
||||
new DimFetchAssignToMethodCall('Nette\Application\Routers\RouteList', 'Nette\Application\Routers\Route', 'addRoute'),
|
||||
]);
|
||||
};
|
||||
```
|
||||
|
||||
↓
|
||||
|
||||
```diff
|
||||
-use Nette\Application\Routers\Route;
|
||||
use Nette\Application\Routers\RouteList;
|
||||
|
||||
class RouterFactory
|
||||
{
|
||||
public static function createRouter()
|
||||
{
|
||||
$routeList = new RouteList();
|
||||
- $routeList[] = new Route('...');
|
||||
+ $routeList->addRoute('...');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### FileGetContentsAndJsonDecodeToStaticCallRector
|
||||
|
||||
Merge 2 function calls to static call
|
||||
|
@ -1,107 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Transform\Rector\Assign;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\ArrayDimFetch;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Transform\ValueObject\DimFetchAssignToMethodCall;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
use RectorPrefix202305\Webmozart\Assert\Assert;
|
||||
/**
|
||||
* @see \Rector\Tests\Transform\Rector\Assign\DimFetchAssignToMethodCallRector\DimFetchAssignToMethodCallRectorTest
|
||||
*/
|
||||
final class DimFetchAssignToMethodCallRector extends AbstractRector implements ConfigurableRectorInterface
|
||||
{
|
||||
/**
|
||||
* @var DimFetchAssignToMethodCall[]
|
||||
*/
|
||||
private $dimFetchAssignToMethodCalls = [];
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Change magic array access add to $list[], to explicit $list->addMethod(...)', [new ConfiguredCodeSample(<<<'CODE_SAMPLE'
|
||||
use Nette\Application\Routers\Route;
|
||||
use Nette\Application\Routers\RouteList;
|
||||
|
||||
class RouterFactory
|
||||
{
|
||||
public static function createRouter()
|
||||
{
|
||||
$routeList = new RouteList();
|
||||
$routeList[] = new Route('...');
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
use Nette\Application\Routers\RouteList;
|
||||
|
||||
class RouterFactory
|
||||
{
|
||||
public static function createRouter()
|
||||
{
|
||||
$routeList = new RouteList();
|
||||
$routeList->addRoute('...');
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, [new DimFetchAssignToMethodCall('Nette\\Application\\Routers\\RouteList', 'Nette\\Application\\Routers\\Route', 'addRoute')])]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [Assign::class];
|
||||
}
|
||||
/**
|
||||
* @param Assign $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (!$node->var instanceof ArrayDimFetch) {
|
||||
return null;
|
||||
}
|
||||
$arrayDimFetch = $node->var;
|
||||
if (!$arrayDimFetch->var instanceof Variable) {
|
||||
return null;
|
||||
}
|
||||
if (!$node->expr instanceof New_) {
|
||||
return null;
|
||||
}
|
||||
$dimFetchAssignToMethodCall = $this->findDimFetchAssignToMethodCall($node);
|
||||
if (!$dimFetchAssignToMethodCall instanceof DimFetchAssignToMethodCall) {
|
||||
return null;
|
||||
}
|
||||
return new MethodCall($arrayDimFetch->var, $dimFetchAssignToMethodCall->getAddMethod(), $node->expr->args);
|
||||
}
|
||||
/**
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
Assert::allIsAOf($configuration, DimFetchAssignToMethodCall::class);
|
||||
$this->dimFetchAssignToMethodCalls = $configuration;
|
||||
}
|
||||
private function findDimFetchAssignToMethodCall(Assign $assign) : ?DimFetchAssignToMethodCall
|
||||
{
|
||||
/** @var ArrayDimFetch $arrayDimFetch */
|
||||
$arrayDimFetch = $assign->var;
|
||||
foreach ($this->dimFetchAssignToMethodCalls as $dimFetchAssignToMethodCall) {
|
||||
if (!$this->isObjectType($arrayDimFetch->var, $dimFetchAssignToMethodCall->getListObjectType())) {
|
||||
continue;
|
||||
}
|
||||
if (!$this->isObjectType($assign->expr, $dimFetchAssignToMethodCall->getItemObjectType())) {
|
||||
continue;
|
||||
}
|
||||
return $dimFetchAssignToMethodCall;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Transform\ValueObject;
|
||||
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Validation\RectorAssert;
|
||||
final class DimFetchAssignToMethodCall
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var string
|
||||
*/
|
||||
private $listClass;
|
||||
/**
|
||||
* @readonly
|
||||
* @var string
|
||||
*/
|
||||
private $itemClass;
|
||||
/**
|
||||
* @readonly
|
||||
* @var string
|
||||
*/
|
||||
private $addMethod;
|
||||
public function __construct(string $listClass, string $itemClass, string $addMethod)
|
||||
{
|
||||
$this->listClass = $listClass;
|
||||
$this->itemClass = $itemClass;
|
||||
$this->addMethod = $addMethod;
|
||||
RectorAssert::methodName($addMethod);
|
||||
}
|
||||
public function getListObjectType() : ObjectType
|
||||
{
|
||||
return new ObjectType($this->listClass);
|
||||
}
|
||||
public function getItemObjectType() : ObjectType
|
||||
{
|
||||
return new ObjectType($this->itemClass);
|
||||
}
|
||||
public function getAddMethod() : string
|
||||
{
|
||||
return $this->addMethod;
|
||||
}
|
||||
}
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '18770166ed5ac0c0c02a4de87d789182bbb36a76';
|
||||
public const PACKAGE_VERSION = '26550ca939279bf296f72b2457545c1a0ade3f8e';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-05-08 21:33:30';
|
||||
public const RELEASE_DATE = '2023-05-08 21:48:22';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
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 ComposerAutoloaderInit79475237490efa837c48b78044981fa4::getLoader();
|
||||
return ComposerAutoloaderInitd445e688caf886e87b208e42156171fb::getLoader();
|
||||
|
2
vendor/composer/autoload_classmap.php
vendored
2
vendor/composer/autoload_classmap.php
vendored
@ -2694,7 +2694,6 @@ return array(
|
||||
'Rector\\Transform\\NodeAnalyzer\\FuncCallStaticCallToMethodCallAnalyzer' => $baseDir . '/rules/Transform/NodeAnalyzer/FuncCallStaticCallToMethodCallAnalyzer.php',
|
||||
'Rector\\Transform\\NodeFactory\\PropertyFetchFactory' => $baseDir . '/rules/Transform/NodeFactory/PropertyFetchFactory.php',
|
||||
'Rector\\Transform\\NodeTypeAnalyzer\\TypeProvidingExprFromClassResolver' => $baseDir . '/rules/Transform/NodeTypeAnalyzer/TypeProvidingExprFromClassResolver.php',
|
||||
'Rector\\Transform\\Rector\\Assign\\DimFetchAssignToMethodCallRector' => $baseDir . '/rules/Transform/Rector/Assign/DimFetchAssignToMethodCallRector.php',
|
||||
'Rector\\Transform\\Rector\\Assign\\GetAndSetToMethodCallRector' => $baseDir . '/rules/Transform/Rector/Assign/GetAndSetToMethodCallRector.php',
|
||||
'Rector\\Transform\\Rector\\Assign\\PropertyAssignToMethodCallRector' => $baseDir . '/rules/Transform/Rector/Assign/PropertyAssignToMethodCallRector.php',
|
||||
'Rector\\Transform\\Rector\\Assign\\PropertyFetchToMethodCallRector' => $baseDir . '/rules/Transform/Rector/Assign/PropertyFetchToMethodCallRector.php',
|
||||
@ -2729,7 +2728,6 @@ return array(
|
||||
'Rector\\Transform\\Rector\\String_\\ToStringToMethodCallRector' => $baseDir . '/rules/Transform/Rector/String_/ToStringToMethodCallRector.php',
|
||||
'Rector\\Transform\\ValueObject\\AttributeKeyToClassConstFetch' => $baseDir . '/rules/Transform/ValueObject/AttributeKeyToClassConstFetch.php',
|
||||
'Rector\\Transform\\ValueObject\\ClassMethodReference' => $baseDir . '/rules/Transform/ValueObject/ClassMethodReference.php',
|
||||
'Rector\\Transform\\ValueObject\\DimFetchAssignToMethodCall' => $baseDir . '/rules/Transform/ValueObject/DimFetchAssignToMethodCall.php',
|
||||
'Rector\\Transform\\ValueObject\\FuncCallToMethodCall' => $baseDir . '/rules/Transform/ValueObject/FuncCallToMethodCall.php',
|
||||
'Rector\\Transform\\ValueObject\\FuncCallToStaticCall' => $baseDir . '/rules/Transform/ValueObject/FuncCallToStaticCall.php',
|
||||
'Rector\\Transform\\ValueObject\\GetAndSetToMethodCall' => $baseDir . '/rules/Transform/ValueObject/GetAndSetToMethodCall.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 ComposerAutoloaderInit79475237490efa837c48b78044981fa4
|
||||
class ComposerAutoloaderInitd445e688caf886e87b208e42156171fb
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInit79475237490efa837c48b78044981fa4
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit79475237490efa837c48b78044981fa4', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitd445e688caf886e87b208e42156171fb', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit79475237490efa837c48b78044981fa4', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitd445e688caf886e87b208e42156171fb', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit79475237490efa837c48b78044981fa4::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitd445e688caf886e87b208e42156171fb::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit79475237490efa837c48b78044981fa4::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitd445e688caf886e87b208e42156171fb::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
10
vendor/composer/autoload_static.php
vendored
10
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit79475237490efa837c48b78044981fa4
|
||||
class ComposerStaticInitd445e688caf886e87b208e42156171fb
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -2936,7 +2936,6 @@ class ComposerStaticInit79475237490efa837c48b78044981fa4
|
||||
'Rector\\Transform\\NodeAnalyzer\\FuncCallStaticCallToMethodCallAnalyzer' => __DIR__ . '/../..' . '/rules/Transform/NodeAnalyzer/FuncCallStaticCallToMethodCallAnalyzer.php',
|
||||
'Rector\\Transform\\NodeFactory\\PropertyFetchFactory' => __DIR__ . '/../..' . '/rules/Transform/NodeFactory/PropertyFetchFactory.php',
|
||||
'Rector\\Transform\\NodeTypeAnalyzer\\TypeProvidingExprFromClassResolver' => __DIR__ . '/../..' . '/rules/Transform/NodeTypeAnalyzer/TypeProvidingExprFromClassResolver.php',
|
||||
'Rector\\Transform\\Rector\\Assign\\DimFetchAssignToMethodCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/Assign/DimFetchAssignToMethodCallRector.php',
|
||||
'Rector\\Transform\\Rector\\Assign\\GetAndSetToMethodCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/Assign/GetAndSetToMethodCallRector.php',
|
||||
'Rector\\Transform\\Rector\\Assign\\PropertyAssignToMethodCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/Assign/PropertyAssignToMethodCallRector.php',
|
||||
'Rector\\Transform\\Rector\\Assign\\PropertyFetchToMethodCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/Assign/PropertyFetchToMethodCallRector.php',
|
||||
@ -2971,7 +2970,6 @@ class ComposerStaticInit79475237490efa837c48b78044981fa4
|
||||
'Rector\\Transform\\Rector\\String_\\ToStringToMethodCallRector' => __DIR__ . '/../..' . '/rules/Transform/Rector/String_/ToStringToMethodCallRector.php',
|
||||
'Rector\\Transform\\ValueObject\\AttributeKeyToClassConstFetch' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/AttributeKeyToClassConstFetch.php',
|
||||
'Rector\\Transform\\ValueObject\\ClassMethodReference' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/ClassMethodReference.php',
|
||||
'Rector\\Transform\\ValueObject\\DimFetchAssignToMethodCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/DimFetchAssignToMethodCall.php',
|
||||
'Rector\\Transform\\ValueObject\\FuncCallToMethodCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/FuncCallToMethodCall.php',
|
||||
'Rector\\Transform\\ValueObject\\FuncCallToStaticCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/FuncCallToStaticCall.php',
|
||||
'Rector\\Transform\\ValueObject\\GetAndSetToMethodCall' => __DIR__ . '/../..' . '/rules/Transform/ValueObject/GetAndSetToMethodCall.php',
|
||||
@ -3119,9 +3117,9 @@ class ComposerStaticInit79475237490efa837c48b78044981fa4
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit79475237490efa837c48b78044981fa4::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit79475237490efa837c48b78044981fa4::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit79475237490efa837c48b78044981fa4::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitd445e688caf886e87b208e42156171fb::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitd445e688caf886e87b208e42156171fb::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitd445e688caf886e87b208e42156171fb::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user