diff --git a/docs/rector_rules_overview.md b/docs/rector_rules_overview.md index 8c0913673d4..4652f74a873 100644 --- a/docs/rector_rules_overview.md +++ b/docs/rector_rules_overview.md @@ -1,4 +1,4 @@ -# 370 Rules Overview +# 369 Rules Overview
@@ -12,8 +12,6 @@ - [DeadCode](#deadcode) (43) -- [DependencyInjection](#dependencyinjection) (1) - - [EarlyReturn](#earlyreturn) (10) - [MysqlToMysqli](#mysqltomysqli) (4) @@ -3236,47 +3234,6 @@ Remove php version checks if they are passed
-## DependencyInjection - -### AddMethodParentCallRector - -Add method parent call, in case new parent method is added - -:wrench: **configure it!** - -- class: [`Rector\DependencyInjection\Rector\ClassMethod\AddMethodParentCallRector`](../rules/DependencyInjection/Rector/ClassMethod/AddMethodParentCallRector.php) - -```php -ruleWithConfiguration(AddMethodParentCallRector::class, [ - 'ParentClassWithNewConstructor' => '__construct', - ]); -}; -``` - -↓ - -```diff - class SunshineCommand extends ParentClassWithNewConstructor - { - public function __construct() - { - $value = 5; -+ -+ parent::__construct(); - } - } -``` - -
- ## EarlyReturn ### ChangeAndIfToEarlyReturnRector diff --git a/rules/DependencyInjection/Rector/ClassMethod/AddMethodParentCallRector.php b/rules/DependencyInjection/Rector/ClassMethod/AddMethodParentCallRector.php deleted file mode 100644 index dad7588e97d..00000000000 --- a/rules/DependencyInjection/Rector/ClassMethod/AddMethodParentCallRector.php +++ /dev/null @@ -1,120 +0,0 @@ - - */ - private $methodByParentTypes = []; - public function getRuleDefinition() : RuleDefinition - { - return new RuleDefinition('Add method parent call, in case new parent method is added', [new ConfiguredCodeSample(<<<'CODE_SAMPLE' -class SunshineCommand extends ParentClassWithNewConstructor -{ - public function __construct() - { - $value = 5; - } -} -CODE_SAMPLE -, <<<'CODE_SAMPLE' -class SunshineCommand extends ParentClassWithNewConstructor -{ - public function __construct() - { - $value = 5; - - parent::__construct(); - } -} -CODE_SAMPLE -, ['ParentClassWithNewConstructor' => MethodName::CONSTRUCT])]); - } - /** - * @return array> - */ - public function getNodeTypes() : array - { - return [ClassMethod::class]; - } - /** - * @param ClassMethod $node - */ - public function refactorWithScope(Node $node, Scope $scope) : ?Node - { - if (!$scope->isInClass()) { - return null; - } - $classReflection = $scope->getClassReflection(); - foreach ($this->methodByParentTypes as $type => $method) { - // not itself - if ($classReflection->getName() === $type) { - continue; - } - if ($this->shouldSkipMethod($node, $method)) { - continue; - } - if (!$classReflection->isSubclassOf($type)) { - continue; - } - $node->stmts[] = $this->createParentStaticCall($method); - return $node; - } - return null; - } - /** - * @param mixed[] $configuration - */ - public function configure(array $configuration) : void - { - Assert::allString(\array_keys($configuration)); - Assert::allString($configuration); - /** @var array $configuration */ - $this->methodByParentTypes = $configuration; - } - private function shouldSkipMethod(ClassMethod $classMethod, string $method) : bool - { - if (!$this->isName($classMethod, $method)) { - return \true; - } - return $this->hasParentCallOfMethod($classMethod, $method); - } - private function createParentStaticCall(string $method) : Expression - { - $staticCall = $this->nodeFactory->createStaticCall(ObjectReference::PARENT, $method); - return new Expression($staticCall); - } - /** - * Looks for "parent:: - */ - private function hasParentCallOfMethod(ClassMethod $classMethod, string $method) : bool - { - return (bool) $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (Node $node) use($method) : bool { - if (!$node instanceof StaticCall) { - return \false; - } - if (!$this->isName($node->class, ObjectReference::PARENT)) { - return \false; - } - return $this->isName($node->name, $method); - }); - } -} diff --git a/rules/Naming/Naming/VariableNaming.php b/rules/Naming/Naming/VariableNaming.php index 5a97c05b4e0..fcb1bf00a54 100644 --- a/rules/Naming/Naming/VariableNaming.php +++ b/rules/Naming/Naming/VariableNaming.php @@ -13,7 +13,6 @@ use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\NullsafeMethodCall; use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Expr\Ternary; -use PhpParser\Node\Name; use PhpParser\Node\Scalar\String_; use PHPStan\Analyser\MutatingScope; use PHPStan\Analyser\Scope; diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 2bf7c22338a..9bc0d1384f8 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = 'c20828965125f2afbde8367f68dab0f9ae983cf1'; + public const PACKAGE_VERSION = '57e2712bd04d491826cc60afa9e003c54e8add96'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-06-20 09:26:36'; + public const RELEASE_DATE = '2023-06-20 08:30:58'; /** * @var int */ diff --git a/src/Console/Formatter/ConsoleDiffer.php b/src/Console/Formatter/ConsoleDiffer.php index 4fb53e85b02..0b77cce6757 100644 --- a/src/Console/Formatter/ConsoleDiffer.php +++ b/src/Console/Formatter/ConsoleDiffer.php @@ -4,7 +4,6 @@ declare (strict_types=1); namespace Rector\Core\Console\Formatter; use RectorPrefix202306\SebastianBergmann\Diff\Differ; -use RectorPrefix202306\SebastianBergmann\Diff\Output\StrictUnifiedDiffOutputBuilder; use RectorPrefix202306\SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder; final class ConsoleDiffer { diff --git a/vendor/autoload.php b/vendor/autoload.php index da71a160769..51e0298c5ef 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) { require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitabca27656ffe000cef73b9542e589554::getLoader(); +return ComposerAutoloaderInite43434694c102827ca61c8b125ba1969::getLoader(); diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index ec493cacf2e..26c5fa8c7fb 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -1740,7 +1740,6 @@ return array( 'Rector\\DeadCode\\ValueObject\\BinaryToVersionCompareCondition' => $baseDir . '/rules/DeadCode/ValueObject/BinaryToVersionCompareCondition.php', 'Rector\\DeadCode\\ValueObject\\VariableAndPropertyFetchAssign' => $baseDir . '/rules/DeadCode/ValueObject/VariableAndPropertyFetchAssign.php', 'Rector\\DeadCode\\ValueObject\\VersionCompareCondition' => $baseDir . '/rules/DeadCode/ValueObject/VersionCompareCondition.php', - 'Rector\\DependencyInjection\\Rector\\ClassMethod\\AddMethodParentCallRector' => $baseDir . '/rules/DependencyInjection/Rector/ClassMethod/AddMethodParentCallRector.php', 'Rector\\Doctrine\\NodeAnalyzer\\AssignPropertyFetchAnalyzer' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/AssignPropertyFetchAnalyzer.php', 'Rector\\Doctrine\\NodeAnalyzer\\AttributeCleaner' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/AttributeCleaner.php', 'Rector\\Doctrine\\NodeAnalyzer\\AttributeFinder' => $vendorDir . '/rector/rector-doctrine/src/NodeAnalyzer/AttributeFinder.php', diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index ae11afed4e8..8b5893e007a 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitabca27656ffe000cef73b9542e589554 +class ComposerAutoloaderInite43434694c102827ca61c8b125ba1969 { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInitabca27656ffe000cef73b9542e589554 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitabca27656ffe000cef73b9542e589554', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInite43434694c102827ca61c8b125ba1969', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInitabca27656ffe000cef73b9542e589554', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInite43434694c102827ca61c8b125ba1969', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitabca27656ffe000cef73b9542e589554::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInite43434694c102827ca61c8b125ba1969::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInitabca27656ffe000cef73b9542e589554::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInite43434694c102827ca61c8b125ba1969::$files; $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index d849c9489e3..e6f27dda5d5 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitabca27656ffe000cef73b9542e589554 +class ComposerStaticInite43434694c102827ca61c8b125ba1969 { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -1991,7 +1991,6 @@ class ComposerStaticInitabca27656ffe000cef73b9542e589554 'Rector\\DeadCode\\ValueObject\\BinaryToVersionCompareCondition' => __DIR__ . '/../..' . '/rules/DeadCode/ValueObject/BinaryToVersionCompareCondition.php', 'Rector\\DeadCode\\ValueObject\\VariableAndPropertyFetchAssign' => __DIR__ . '/../..' . '/rules/DeadCode/ValueObject/VariableAndPropertyFetchAssign.php', 'Rector\\DeadCode\\ValueObject\\VersionCompareCondition' => __DIR__ . '/../..' . '/rules/DeadCode/ValueObject/VersionCompareCondition.php', - 'Rector\\DependencyInjection\\Rector\\ClassMethod\\AddMethodParentCallRector' => __DIR__ . '/../..' . '/rules/DependencyInjection/Rector/ClassMethod/AddMethodParentCallRector.php', 'Rector\\Doctrine\\NodeAnalyzer\\AssignPropertyFetchAnalyzer' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/AssignPropertyFetchAnalyzer.php', 'Rector\\Doctrine\\NodeAnalyzer\\AttributeCleaner' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/AttributeCleaner.php', 'Rector\\Doctrine\\NodeAnalyzer\\AttributeFinder' => __DIR__ . '/..' . '/rector/rector-doctrine/src/NodeAnalyzer/AttributeFinder.php', @@ -3098,9 +3097,9 @@ class ComposerStaticInitabca27656ffe000cef73b9542e589554 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitabca27656ffe000cef73b9542e589554::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitabca27656ffe000cef73b9542e589554::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitabca27656ffe000cef73b9542e589554::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInite43434694c102827ca61c8b125ba1969::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInite43434694c102827ca61c8b125ba1969::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInite43434694c102827ca61c8b125ba1969::$classMap; }, null, ClassLoader::class); }