Updated Rector to commit a39844ee53169fb0b6d1184672eeb1869a541dd2

a39844ee53 [misc] Add Expr type to value resolver, remove RemoveFuncCallRector as niche feature, cleanup ClassManipulator from unused methods (#2900)
This commit is contained in:
Tomas Votruba 2022-09-03 08:03:15 +00:00
parent 2f2c1d1b5f
commit 62e856362b
19 changed files with 70 additions and 494 deletions

View File

@ -1,4 +1,4 @@
# 401 Rules Overview
# 394 Rules Overview
<br>
@ -12,8 +12,6 @@
- [Compatibility](#compatibility) (1)
- [Composer](#composer) (6)
- [DeadCode](#deadcode) (47)
- [DependencyInjection](#dependencyinjection) (2)
@ -54,7 +52,7 @@
- [Privatization](#privatization) (8)
- [Removing](#removing) (6)
- [Removing](#removing) (5)
- [RemovingStatic](#removingstatic) (1)
@ -2521,205 +2519,6 @@ Change annotation to attribute compatible form, see https://tomasvotruba.com/blo
<br>
## Composer
### AddPackageToRequireComposerRector
Add package to "require" in `composer.json`
:wrench: **configure it!**
- class: [`Rector\Composer\Rector\AddPackageToRequireComposerRector`](../rules/Composer/Rector/AddPackageToRequireComposerRector.php)
```php
use Rector\Composer\Rector\AddPackageToRequireComposerRector;
use Rector\Composer\ValueObject\PackageAndVersion;
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(
AddPackageToRequireComposerRector::class,
[new PackageAndVersion('symfony/console', '^3.4')]
);
};
```
```diff
{
+ "require": {
+ "symfony/console": "^3.4"
+ }
}
```
<br>
### AddPackageToRequireDevComposerRector
Add package to "require-dev" in `composer.json`
:wrench: **configure it!**
- class: [`Rector\Composer\Rector\AddPackageToRequireDevComposerRector`](../rules/Composer/Rector/AddPackageToRequireDevComposerRector.php)
```php
use Rector\Composer\Rector\AddPackageToRequireDevComposerRector;
use Rector\Composer\ValueObject\PackageAndVersion;
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(
AddPackageToRequireDevComposerRector::class,
[new PackageAndVersion('symfony/console', '^3.4')]
);
};
```
```diff
{
+ "require-dev": {
+ "symfony/console": "^3.4"
+ }
}
```
<br>
### ChangePackageVersionComposerRector
Change package version `composer.json`
:wrench: **configure it!**
- class: [`Rector\Composer\Rector\ChangePackageVersionComposerRector`](../rules/Composer/Rector/ChangePackageVersionComposerRector.php)
```php
use Rector\Composer\Rector\ChangePackageVersionComposerRector;
use Rector\Composer\ValueObject\PackageAndVersion;
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(
ChangePackageVersionComposerRector::class,
[new PackageAndVersion('symfony/console', '^4.4')]
);
};
```
```diff
{
"require": {
- "symfony/console": "^3.4"
+ "symfony/console": "^4.4"
}
}
```
<br>
### RemovePackageComposerRector
Remove package from "require" and "require-dev" in `composer.json`
:wrench: **configure it!**
- class: [`Rector\Composer\Rector\RemovePackageComposerRector`](../rules/Composer/Rector/RemovePackageComposerRector.php)
```php
use Rector\Composer\Rector\RemovePackageComposerRector;
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(RemovePackageComposerRector::class, ['symfony/console']);
};
```
```diff
{
- "require": {
- "symfony/console": "^3.4"
- }
}
```
<br>
### RenamePackageComposerRector
Change package name in `composer.json`
:wrench: **configure it!**
- class: [`Rector\Composer\Rector\RenamePackageComposerRector`](../rules/Composer/Rector/RenamePackageComposerRector.php)
```php
use Rector\Composer\Rector\RenamePackageComposerRector;
use Rector\Composer\ValueObject\RenamePackage;
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(
RenamePackageComposerRector::class,
[new RenamePackage('rector/rector', 'rector/rector-src')]
);
};
```
```diff
{
"require": {
- "rector/rector": "dev-main"
+ "rector/rector-src": "dev-main"
}
}
```
<br>
### ReplacePackageAndVersionComposerRector
Change package name and version `composer.json`
:wrench: **configure it!**
- class: [`Rector\Composer\Rector\ReplacePackageAndVersionComposerRector`](../rules/Composer/Rector/ReplacePackageAndVersionComposerRector.php)
```php
use Rector\Composer\Rector\ReplacePackageAndVersionComposerRector;
use Rector\Composer\ValueObject\ReplacePackageAndVersion;
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(
ReplacePackageAndVersionComposerRector::class,
[new ReplacePackageAndVersion('symfony/console', 'symfony/http-kernel', '^4.4')]
);
};
```
```diff
{
"require-dev": {
- "symfony/console": "^3.4"
+ "symfony/http-kernel": "^4.4"
}
}
```
<br>
## DeadCode
### RecastingRemovalRector
@ -6789,36 +6588,6 @@ return static function (RectorConfig $rectorConfig): void {
<br>
### RemoveFuncCallRector
Remove ini_get by configuration
:wrench: **configure it!**
- class: [`Rector\Removing\Rector\FuncCall\RemoveFuncCallRector`](../rules/Removing/Rector/FuncCall/RemoveFuncCallRector.php)
```php
use Rector\Config\RectorConfig;
use Rector\Removing\Rector\FuncCall\RemoveFuncCallRector;
use Rector\Removing\ValueObject\RemoveFuncCall;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(
RemoveFuncCallRector::class,
[new RemoveFuncCall('ini_get', [['y2k_compliance']])]
);
};
```
```diff
-ini_get('y2k_compliance');
ini_get('keep_me');
```
<br>
### RemoveInterfacesRector
Removes interfaces usage from class.
@ -8590,12 +8359,7 @@ use Rector\Transform\ValueObject\StaticCallToMethodCall;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(
StaticCallToMethodCallRector::class,
[new StaticCallToMethodCall(
'Nette\Utils\FileSystem',
'write',
'Symplify\SmartFileSystem\SmartFileSystem',
'dumpFile'
)]
[new StaticCallToMethodCall('Nette\Utils\FileSystem', 'write', 'App\Custom\SmartFileSystem', 'dumpFile')]
);
};
```
@ -8604,7 +8368,7 @@ return static function (RectorConfig $rectorConfig): void {
```diff
-use Nette\Utils\FileSystem;
+use Symplify\SmartFileSystem\SmartFileSystem;
+use App\Custom\SmartFileSystem;
class SomeClass
{

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\CodeQuality\Rector\Identical;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\BinaryOp\Identical;
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
use PhpParser\Node\Expr\BooleanNot;
@ -49,7 +50,7 @@ final class SimplifyArraySearchRector extends AbstractRector
}
return $this->nodeNameResolver->isName($node, 'array_search');
}, function (Node $node) : bool {
return $this->valueResolver->isFalse($node);
return $node instanceof Expr && $this->valueResolver->isFalse($node);
});
if (!$twoNodeMatch instanceof TwoNodeMatch) {
return null;

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\CodeQuality\Rector\Identical;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\BinaryOp;
use PhpParser\Node\Expr\BinaryOp\BooleanOr;
use PhpParser\Node\Expr\BinaryOp\Identical;
@ -71,7 +72,7 @@ final class SimplifyConditionsRector extends AbstractRector
$twoNodeMatch = $this->binaryOpManipulator->matchFirstAndSecondConditionNode($identical, static function (Node $node) : bool {
return $node instanceof Identical || $node instanceof NotIdentical;
}, function (Node $node) : bool {
return $this->valueResolver->isTrueOrFalse($node);
return $node instanceof Expr && $this->valueResolver->isTrueOrFalse($node);
});
if (!$twoNodeMatch instanceof TwoNodeMatch) {
return $twoNodeMatch;

View File

@ -73,8 +73,10 @@ CODE_SAMPLE
$ifInnerNode = $node->stmts[0];
/** @var Return_ $nextNode */
$nextNode = $node->getAttribute(AttributeKey::NEXT_NODE);
/** @var Node $innerIfInnerNode */
$innerIfInnerNode = $ifInnerNode->expr;
if (!$innerIfInnerNode instanceof Expr) {
return null;
}
if ($this->valueResolver->isTrue($innerIfInnerNode)) {
$newReturnNode = $this->processReturnTrue($node, $nextNode);
} elseif ($this->valueResolver->isFalse($innerIfInnerNode)) {

View File

@ -30,23 +30,23 @@ final class CountManipulator
$this->nodeNameResolver = $nodeNameResolver;
$this->nodeComparator = $nodeComparator;
}
public function isCounterHigherThanOne(Expr $node, Expr $expr) : bool
public function isCounterHigherThanOne(Expr $firstExpr, Expr $secondExpr) : bool
{
// e.g. count($values) > 0
if ($node instanceof Greater) {
return $this->isGreater($node, $expr);
if ($firstExpr instanceof Greater) {
return $this->isGreater($firstExpr, $secondExpr);
}
// e.g. count($values) >= 1
if ($node instanceof GreaterOrEqual) {
return $this->isGreaterOrEqual($node, $expr);
if ($firstExpr instanceof GreaterOrEqual) {
return $this->isGreaterOrEqual($firstExpr, $secondExpr);
}
// e.g. 0 < count($values)
if ($node instanceof Smaller) {
return $this->isSmaller($node, $expr);
if ($firstExpr instanceof Smaller) {
return $this->isSmaller($firstExpr, $secondExpr);
}
// e.g. 1 <= count($values)
if ($node instanceof SmallerOrEqual) {
return $this->isSmallerOrEqual($node, $expr);
if ($firstExpr instanceof SmallerOrEqual) {
return $this->isSmallerOrEqual($firstExpr, $secondExpr);
}
return \false;
}

View File

@ -1,106 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Removing\Rector\FuncCall;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\FuncCall;
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Rector\NodeRemoval\BreakingRemovalGuard;
use Rector\Removing\ValueObject\RemoveFuncCall;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
use RectorPrefix202209\Webmozart\Assert\Assert;
/**
* @see \Rector\Tests\Removing\Rector\FuncCall\RemoveFuncCallRector\RemoveFuncCallRectorTest
*/
final class RemoveFuncCallRector extends AbstractRector implements ConfigurableRectorInterface
{
/**
* @var RemoveFuncCall[]
*/
private $removeFuncCalls = [];
/**
* @readonly
* @var \Rector\NodeRemoval\BreakingRemovalGuard
*/
private $breakingRemovalGuard;
public function __construct(BreakingRemovalGuard $breakingRemovalGuard)
{
$this->breakingRemovalGuard = $breakingRemovalGuard;
}
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Remove ini_get by configuration', [new ConfiguredCodeSample(<<<'CODE_SAMPLE'
ini_get('y2k_compliance');
ini_get('keep_me');
CODE_SAMPLE
, <<<'CODE_SAMPLE'
ini_get('keep_me');
CODE_SAMPLE
, [new RemoveFuncCall('ini_get', [1 => ['y2k_compliance']])])]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [FuncCall::class];
}
/**
* @param FuncCall $node
*/
public function refactor(Node $node) : ?Node
{
foreach ($this->removeFuncCalls as $removeFuncCall) {
if (!$this->isName($node, $removeFuncCall->getFuncCall())) {
continue;
}
if ($removeFuncCall->getArgumentPositionAndValues() === []) {
$this->removeNode($node);
return $node;
}
$removedFuncCall = $this->refactorFuncCallsWithPositions($node, $removeFuncCall);
if ($removedFuncCall instanceof FuncCall) {
return $node;
}
}
return null;
}
/**
* @param mixed[] $configuration
*/
public function configure(array $configuration) : void
{
Assert::allIsAOf($configuration, RemoveFuncCall::class);
$this->removeFuncCalls = $configuration;
}
private function refactorFuncCallsWithPositions(FuncCall $funcCall, RemoveFuncCall $removeFuncCall) : ?FuncCall
{
foreach ($removeFuncCall->getArgumentPositionAndValues() as $argumentPosition => $values) {
if (!$this->isArgumentPositionValueMatch($funcCall, $argumentPosition, $values)) {
continue;
}
if ($this->breakingRemovalGuard->isLegalNodeRemoval($funcCall)) {
$this->removeNode($funcCall);
return $funcCall;
}
}
return null;
}
/**
* @param mixed[] $values
*/
private function isArgumentPositionValueMatch(FuncCall $funcCall, int $argumentPosition, array $values) : bool
{
if (!isset($funcCall->args[$argumentPosition])) {
return \false;
}
if (!$funcCall->args[$argumentPosition] instanceof Arg) {
return \false;
}
return $this->valueResolver->isValues($funcCall->args[$argumentPosition]->value, $values);
}
}

View File

@ -1,39 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Removing\ValueObject;
use Rector\Core\Validation\RectorAssert;
final class RemoveFuncCall
{
/**
* @readonly
* @var string
*/
private $funcCall;
/**
* @var array<int, mixed[]>
* @readonly
*/
private $argumentPositionAndValues = [];
/**
* @param array<int, mixed[]> $argumentPositionAndValues
*/
public function __construct(string $funcCall, array $argumentPositionAndValues = [])
{
$this->funcCall = $funcCall;
$this->argumentPositionAndValues = $argumentPositionAndValues;
RectorAssert::functionName($funcCall);
}
public function getFuncCall() : string
{
return $this->funcCall;
}
/**
* @return array<int, mixed[]>
*/
public function getArgumentPositionAndValues() : array
{
return $this->argumentPositionAndValues;
}
}

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '3820e0075152c72f618226ff213faf847e3d39f7';
public const PACKAGE_VERSION = 'a39844ee53169fb0b6d1184672eeb1869a541dd2';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-09-03 08:16:36';
public const RELEASE_DATE = '2022-09-03 09:59:19';
/**
* @var int
*/

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\Core\NodeAnalyzer;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\ConstFetch;
/**
* Read-only utils for ClassConstAnalyzer Node:
@ -11,24 +12,24 @@ use PhpParser\Node\Expr\ConstFetch;
*/
final class ConstFetchAnalyzer
{
public function isTrueOrFalse(Node $node) : bool
public function isTrueOrFalse(Expr $expr) : bool
{
if ($this->isTrue($node)) {
if ($this->isTrue($expr)) {
return \true;
}
return $this->isFalse($node);
return $this->isFalse($expr);
}
public function isFalse(Node $node) : bool
public function isFalse(Expr $expr) : bool
{
return $this->isConstantWithLowercasedName($node, 'false');
return $this->isConstantWithLowercasedName($expr, 'false');
}
public function isTrue(Node $node) : bool
public function isTrue(Expr $expr) : bool
{
return $this->isConstantWithLowercasedName($node, 'true');
return $this->isConstantWithLowercasedName($expr, 'true');
}
public function isNull(Node $node) : bool
public function isNull(Expr $expr) : bool
{
return $this->isConstantWithLowercasedName($node, 'null');
return $this->isConstantWithLowercasedName($expr, 'null');
}
private function isConstantWithLowercasedName(Node $node, string $name) : bool
{

View File

@ -5,13 +5,10 @@ namespace Rector\Core\NodeManipulator;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\Interface_;
use PhpParser\Node\Stmt\Property;
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\Type\ObjectType;
use Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\PostRector\Collector\NodesToRemoveCollector;
final class ClassManipulator
{
/**
@ -19,11 +16,6 @@ final class ClassManipulator
* @var \Rector\NodeNameResolver\NodeNameResolver
*/
private $nodeNameResolver;
/**
* @readonly
* @var \Rector\PostRector\Collector\NodesToRemoveCollector
*/
private $nodesToRemoveCollector;
/**
* @readonly
* @var \PHPStan\Reflection\ReflectionProvider
@ -34,10 +26,9 @@ final class ClassManipulator
* @var \Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer
*/
private $classChildAnalyzer;
public function __construct(NodeNameResolver $nodeNameResolver, NodesToRemoveCollector $nodesToRemoveCollector, ReflectionProvider $reflectionProvider, ClassChildAnalyzer $classChildAnalyzer)
public function __construct(NodeNameResolver $nodeNameResolver, ReflectionProvider $reflectionProvider, ClassChildAnalyzer $classChildAnalyzer)
{
$this->nodeNameResolver = $nodeNameResolver;
$this->nodesToRemoveCollector = $nodesToRemoveCollector;
$this->reflectionProvider = $reflectionProvider;
$this->classChildAnalyzer = $classChildAnalyzer;
}
@ -59,16 +50,6 @@ final class ClassManipulator
}
return \false;
}
/**
* @return string[]
*/
public function getPrivatePropertyNames(Class_ $class) : array
{
$privateProperties = \array_filter($class->getProperties(), static function (Property $property) : bool {
return $property->isPrivate();
});
return $this->nodeNameResolver->getNames($privateProperties);
}
public function hasTrait(Class_ $class, string $desiredTrait) : bool
{
foreach ($class->getTraitUses() as $traitUse) {
@ -93,24 +74,4 @@ final class ClassManipulator
}
}
}
/**
* @return string[]
* @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Interface_ $classLike
*/
public function getClassLikeNodeParentInterfaceNames($classLike) : array
{
if ($classLike instanceof Class_) {
return $this->nodeNameResolver->getNames($classLike->implements);
}
return $this->nodeNameResolver->getNames($classLike->extends);
}
public function removeInterface(Class_ $class, string $desiredInterface) : void
{
foreach ($class->implements as $implement) {
if (!$this->nodeNameResolver->isName($implement, $desiredInterface)) {
continue;
}
$this->nodesToRemoveCollector->addNodeToRemove($implement);
}
}
}

View File

@ -5,7 +5,6 @@ namespace Rector\Core\PhpParser\Node\Value;
use PhpParser\ConstExprEvaluationException;
use PhpParser\ConstExprEvaluator;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\BinaryOp\Concat;
use PhpParser\Node\Expr\ClassConstFetch;
@ -131,27 +130,21 @@ final class ValueResolver
}
return \false;
}
public function isFalse(Node $node) : bool
public function isFalse(Expr $expr) : bool
{
return $this->constFetchAnalyzer->isFalse($node);
return $this->constFetchAnalyzer->isFalse($expr);
}
public function isTrueOrFalse(Node $node) : bool
public function isTrueOrFalse(Expr $expr) : bool
{
return $this->constFetchAnalyzer->isTrueOrFalse($node);
return $this->constFetchAnalyzer->isTrueOrFalse($expr);
}
public function isTrue(Node $node) : bool
public function isTrue(Expr $expr) : bool
{
return $this->constFetchAnalyzer->isTrue($node);
return $this->constFetchAnalyzer->isTrue($expr);
}
public function isNull(Node $node) : bool
public function isNull(Expr $expr) : bool
{
return $this->constFetchAnalyzer->isNull($node);
}
public function isValueEqual(Expr $firstExpr, Expr $secondExpr) : bool
{
$firstValue = $this->getValue($firstExpr);
$secondValue = $this->getValue($secondExpr);
return $firstValue === $secondValue;
return $this->constFetchAnalyzer->isNull($expr);
}
/**
* @param Expr[]|null[] $nodes

2
vendor/autoload.php vendored
View File

@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit5fb610957f9d0d33e4142b638f34727c::getLoader();
return ComposerAutoloaderInit087fb1f8916d4539ff6d0400d12581e0::getLoader();

View File

@ -2393,9 +2393,7 @@ return array(
'Rector\\Removing\\Rector\\Class_\\RemoveParentRector' => $baseDir . '/rules/Removing/Rector/Class_/RemoveParentRector.php',
'Rector\\Removing\\Rector\\Class_\\RemoveTraitUseRector' => $baseDir . '/rules/Removing/Rector/Class_/RemoveTraitUseRector.php',
'Rector\\Removing\\Rector\\FuncCall\\RemoveFuncCallArgRector' => $baseDir . '/rules/Removing/Rector/FuncCall/RemoveFuncCallArgRector.php',
'Rector\\Removing\\Rector\\FuncCall\\RemoveFuncCallRector' => $baseDir . '/rules/Removing/Rector/FuncCall/RemoveFuncCallRector.php',
'Rector\\Removing\\ValueObject\\ArgumentRemover' => $baseDir . '/rules/Removing/ValueObject/ArgumentRemover.php',
'Rector\\Removing\\ValueObject\\RemoveFuncCall' => $baseDir . '/rules/Removing/ValueObject/RemoveFuncCall.php',
'Rector\\Removing\\ValueObject\\RemoveFuncCallArg' => $baseDir . '/rules/Removing/ValueObject/RemoveFuncCallArg.php',
'Rector\\Renaming\\Collector\\MethodCallRenameCollector' => $baseDir . '/rules/Renaming/Collector/MethodCallRenameCollector.php',
'Rector\\Renaming\\Contract\\MethodCallRenameInterface' => $baseDir . '/rules/Renaming/Contract/MethodCallRenameInterface.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit5fb610957f9d0d33e4142b638f34727c
class ComposerAutoloaderInit087fb1f8916d4539ff6d0400d12581e0
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit5fb610957f9d0d33e4142b638f34727c
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit5fb610957f9d0d33e4142b638f34727c', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit087fb1f8916d4539ff6d0400d12581e0', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit5fb610957f9d0d33e4142b638f34727c', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit087fb1f8916d4539ff6d0400d12581e0', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit5fb610957f9d0d33e4142b638f34727c::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit087fb1f8916d4539ff6d0400d12581e0::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit5fb610957f9d0d33e4142b638f34727c::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit087fb1f8916d4539ff6d0400d12581e0::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire5fb610957f9d0d33e4142b638f34727c($fileIdentifier, $file);
composerRequire087fb1f8916d4539ff6d0400d12581e0($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit5fb610957f9d0d33e4142b638f34727c
* @param string $file
* @return void
*/
function composerRequire5fb610957f9d0d33e4142b638f34727c($fileIdentifier, $file)
function composerRequire087fb1f8916d4539ff6d0400d12581e0($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 ComposerStaticInit5fb610957f9d0d33e4142b638f34727c
class ComposerStaticInit087fb1f8916d4539ff6d0400d12581e0
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -2648,9 +2648,7 @@ class ComposerStaticInit5fb610957f9d0d33e4142b638f34727c
'Rector\\Removing\\Rector\\Class_\\RemoveParentRector' => __DIR__ . '/../..' . '/rules/Removing/Rector/Class_/RemoveParentRector.php',
'Rector\\Removing\\Rector\\Class_\\RemoveTraitUseRector' => __DIR__ . '/../..' . '/rules/Removing/Rector/Class_/RemoveTraitUseRector.php',
'Rector\\Removing\\Rector\\FuncCall\\RemoveFuncCallArgRector' => __DIR__ . '/../..' . '/rules/Removing/Rector/FuncCall/RemoveFuncCallArgRector.php',
'Rector\\Removing\\Rector\\FuncCall\\RemoveFuncCallRector' => __DIR__ . '/../..' . '/rules/Removing/Rector/FuncCall/RemoveFuncCallRector.php',
'Rector\\Removing\\ValueObject\\ArgumentRemover' => __DIR__ . '/../..' . '/rules/Removing/ValueObject/ArgumentRemover.php',
'Rector\\Removing\\ValueObject\\RemoveFuncCall' => __DIR__ . '/../..' . '/rules/Removing/ValueObject/RemoveFuncCall.php',
'Rector\\Removing\\ValueObject\\RemoveFuncCallArg' => __DIR__ . '/../..' . '/rules/Removing/ValueObject/RemoveFuncCallArg.php',
'Rector\\Renaming\\Collector\\MethodCallRenameCollector' => __DIR__ . '/../..' . '/rules/Renaming/Collector/MethodCallRenameCollector.php',
'Rector\\Renaming\\Contract\\MethodCallRenameInterface' => __DIR__ . '/../..' . '/rules/Renaming/Contract/MethodCallRenameInterface.php',
@ -3095,9 +3093,9 @@ class ComposerStaticInit5fb610957f9d0d33e4142b638f34727c
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit5fb610957f9d0d33e4142b638f34727c::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit5fb610957f9d0d33e4142b638f34727c::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit5fb610957f9d0d33e4142b638f34727c::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit087fb1f8916d4539ff6d0400d12581e0::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit087fb1f8916d4539ff6d0400d12581e0::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit087fb1f8916d4539ff6d0400d12581e0::$classMap;
}, null, ClassLoader::class);
}

View File

@ -1853,12 +1853,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
"reference": "bdf6e7c07b91df02000fa286e30e74c7fb7e5301"
"reference": "23593a293bb05215e354a8544fd49cac5c223aac"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/bdf6e7c07b91df02000fa286e30e74c7fb7e5301",
"reference": "bdf6e7c07b91df02000fa286e30e74c7fb7e5301",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/23593a293bb05215e354a8544fd49cac5c223aac",
"reference": "23593a293bb05215e354a8544fd49cac5c223aac",
"shasum": ""
},
"require": {
@ -1884,7 +1884,7 @@
"symplify\/rule-doc-generator": "^11.1",
"symplify\/vendor-patches": "^11.1"
},
"time": "2022-09-02T10:53:49+00:00",
"time": "2022-09-03T07:45:16+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-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main a489bf0'), '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 bdf6e7c'), '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 b4b49bf'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 2decdcf'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 294de0c'), '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 3f58e44'), '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 8c0ac2e'));
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main a489bf0'), '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 23593a2'), '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 b4b49bf'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 2decdcf'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 294de0c'), '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 3f58e44'), '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 8c0ac2e'));
private function __construct()
{
}

View File

@ -11,7 +11,6 @@ use PHPStan\Type\ObjectType;
use Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\NodeManipulator\ClassInsertManipulator;
use Rector\Core\NodeManipulator\ClassManipulator;
use Rector\Core\Rector\AbstractRector;
use Rector\Doctrine\NodeAnalyzer\TranslatablePropertyCollectorAndRemover;
use Rector\Doctrine\NodeFactory\TranslationClassNodeFactory;
@ -35,11 +34,6 @@ final class TranslationBehaviorRector extends AbstractRector
* @var \Rector\Core\NodeManipulator\ClassInsertManipulator
*/
private $classInsertManipulator;
/**
* @readonly
* @var \Rector\Core\NodeManipulator\ClassManipulator
*/
private $classManipulator;
/**
* @readonly
* @var \Rector\Doctrine\NodeFactory\TranslationClassNodeFactory
@ -55,10 +49,9 @@ final class TranslationBehaviorRector extends AbstractRector
* @var \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector
*/
private $removedAndAddedFilesCollector;
public function __construct(ClassInsertManipulator $classInsertManipulator, ClassManipulator $classManipulator, TranslationClassNodeFactory $translationClassNodeFactory, TranslatablePropertyCollectorAndRemover $translatablePropertyCollectorAndRemover, RemovedAndAddedFilesCollector $removedAndAddedFilesCollector)
public function __construct(ClassInsertManipulator $classInsertManipulator, TranslationClassNodeFactory $translationClassNodeFactory, TranslatablePropertyCollectorAndRemover $translatablePropertyCollectorAndRemover, RemovedAndAddedFilesCollector $removedAndAddedFilesCollector)
{
$this->classInsertManipulator = $classInsertManipulator;
$this->classManipulator = $classManipulator;
$this->translationClassNodeFactory = $translationClassNodeFactory;
$this->translatablePropertyCollectorAndRemover = $translatablePropertyCollectorAndRemover;
$this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector;
@ -147,7 +140,7 @@ CODE_SAMPLE
if (!$this->hasImplements($node)) {
return null;
}
$this->classManipulator->removeInterface($node, 'Gedmo\\Translatable\\Translatable');
$this->removeClassInterface($node);
$this->classInsertManipulator->addAsFirstTrait($node, 'Knp\\DoctrineBehaviors\\Model\\Translatable\\TranslatableTrait');
$node->implements[] = new FullyQualified('Knp\\DoctrineBehaviors\\Contract\\Entity\\TranslatableInterface');
$propertyNamesAndPhpDocInfos = $this->translatablePropertyCollectorAndRemover->processClass($node);
@ -203,4 +196,13 @@ CODE_SAMPLE
}
return \false;
}
private function removeClassInterface(Class_ $class) : void
{
foreach ($class->implements as $key => $implement) {
if (!$this->isName($implement, 'Gedmo\\Translatable\\Translatable')) {
continue;
}
unset($class->implements[$key]);
}
}
}