mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-05 10:50:48 +00:00
Updated Rector to commit 1eee3a5f8727d3385d210222ab8e1f512a4fea19
1eee3a5f87
Remove RemoveParentRector as never used and only for demo purposes, handle custom way where needed (#4679)
This commit is contained in:
parent
38829f40f1
commit
e1ddea3c17
|
@ -1,4 +1,4 @@
|
||||||
# 361 Rules Overview
|
# 360 Rules Overview
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
- [Arguments](#arguments) (6)
|
- [Arguments](#arguments) (6)
|
||||||
|
|
||||||
- [CodeQuality](#codequality) (71)
|
- [CodeQuality](#codequality) (70)
|
||||||
|
|
||||||
- [CodingStyle](#codingstyle) (30)
|
- [CodingStyle](#codingstyle) (30)
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
|
|
||||||
- [Privatization](#privatization) (4)
|
- [Privatization](#privatization) (4)
|
||||||
|
|
||||||
- [Removing](#removing) (6)
|
- [Removing](#removing) (5)
|
||||||
|
|
||||||
- [Renaming](#renaming) (10)
|
- [Renaming](#renaming) (10)
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
|
|
||||||
- [Transform](#transform) (22)
|
- [Transform](#transform) (22)
|
||||||
|
|
||||||
- [TypeDeclaration](#typedeclaration) (43)
|
- [TypeDeclaration](#typedeclaration) (44)
|
||||||
|
|
||||||
- [Visibility](#visibility) (3)
|
- [Visibility](#visibility) (3)
|
||||||
|
|
||||||
|
@ -1072,29 +1072,6 @@ Replace the Double not operator (!!) by type-casting to boolean
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
### ReturnTypeFromStrictScalarReturnExprRector
|
|
||||||
|
|
||||||
Change return type based on strict scalar returns - string, int, float or bool
|
|
||||||
|
|
||||||
- class: [`Rector\CodeQuality\Rector\ClassMethod\ReturnTypeFromStrictScalarReturnExprRector`](../rules/CodeQuality/Rector/ClassMethod/ReturnTypeFromStrictScalarReturnExprRector.php)
|
|
||||||
|
|
||||||
```diff
|
|
||||||
final class SomeClass
|
|
||||||
{
|
|
||||||
- public function run($value)
|
|
||||||
+ public function run($value): string
|
|
||||||
{
|
|
||||||
if ($value) {
|
|
||||||
return 'yes';
|
|
||||||
}
|
|
||||||
|
|
||||||
return 'no';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
### SetTypeToCastRector
|
### SetTypeToCastRector
|
||||||
|
|
||||||
Changes `settype()` to (type) where possible
|
Changes `settype()` to (type) where possible
|
||||||
|
@ -5841,40 +5818,6 @@ return static function (RectorConfig $rectorConfig): void {
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
### RemoveParentRector
|
|
||||||
|
|
||||||
Removes extends class by name
|
|
||||||
|
|
||||||
:wrench: **configure it!**
|
|
||||||
|
|
||||||
- class: [`Rector\Removing\Rector\Class_\RemoveParentRector`](../rules/Removing/Rector/Class_/RemoveParentRector.php)
|
|
||||||
|
|
||||||
```php
|
|
||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
use Rector\Config\RectorConfig;
|
|
||||||
use Rector\Removing\Rector\Class_\RemoveParentRector;
|
|
||||||
|
|
||||||
return static function (RectorConfig $rectorConfig): void {
|
|
||||||
$rectorConfig->ruleWithConfiguration(RemoveParentRector::class, [
|
|
||||||
'SomeParentClass',
|
|
||||||
]);
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
↓
|
|
||||||
|
|
||||||
```diff
|
|
||||||
-final class SomeClass extends SomeParentClass
|
|
||||||
+final class SomeClass
|
|
||||||
{
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
### RemoveTraitUseRector
|
### RemoveTraitUseRector
|
||||||
|
|
||||||
Remove specific traits from code
|
Remove specific traits from code
|
||||||
|
@ -8064,6 +8007,29 @@ Add return type based on strict parameter type
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
### ReturnTypeFromStrictScalarReturnExprRector
|
||||||
|
|
||||||
|
Change return type based on strict scalar returns - string, int, float or bool
|
||||||
|
|
||||||
|
- class: [`Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictScalarReturnExprRector`](../rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictScalarReturnExprRector.php)
|
||||||
|
|
||||||
|
```diff
|
||||||
|
final class SomeClass
|
||||||
|
{
|
||||||
|
- public function run($value)
|
||||||
|
+ public function run($value): string
|
||||||
|
{
|
||||||
|
if ($value) {
|
||||||
|
return 'yes';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'no';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
### ReturnTypeFromStrictTernaryRector
|
### ReturnTypeFromStrictTernaryRector
|
||||||
|
|
||||||
Add method return type based on strict ternary values
|
Add method return type based on strict ternary values
|
||||||
|
|
|
@ -1,82 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
declare (strict_types=1);
|
|
||||||
namespace Rector\Removing\Rector\Class_;
|
|
||||||
|
|
||||||
use PhpParser\Node;
|
|
||||||
use PhpParser\Node\Stmt\Class_;
|
|
||||||
use PHPStan\Analyser\Scope;
|
|
||||||
use PHPStan\Reflection\ClassReflection;
|
|
||||||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
|
||||||
use Rector\Core\Rector\AbstractScopeAwareRector;
|
|
||||||
use Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver;
|
|
||||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
|
||||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
|
||||||
use RectorPrefix202308\Webmozart\Assert\Assert;
|
|
||||||
/**
|
|
||||||
* @see \Rector\Tests\Removing\Rector\Class_\RemoveParentRector\RemoveParentRectorTest
|
|
||||||
*/
|
|
||||||
final class RemoveParentRector extends AbstractScopeAwareRector implements ConfigurableRectorInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @readonly
|
|
||||||
* @var \Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver
|
|
||||||
*/
|
|
||||||
private $parentClassScopeResolver;
|
|
||||||
/**
|
|
||||||
* @var string[]
|
|
||||||
*/
|
|
||||||
private $parentClassesToRemove = [];
|
|
||||||
public function __construct(ParentClassScopeResolver $parentClassScopeResolver)
|
|
||||||
{
|
|
||||||
$this->parentClassScopeResolver = $parentClassScopeResolver;
|
|
||||||
}
|
|
||||||
public function getRuleDefinition() : RuleDefinition
|
|
||||||
{
|
|
||||||
return new RuleDefinition('Removes extends class by name', [new ConfiguredCodeSample(<<<'CODE_SAMPLE'
|
|
||||||
final class SomeClass extends SomeParentClass
|
|
||||||
{
|
|
||||||
}
|
|
||||||
CODE_SAMPLE
|
|
||||||
, <<<'CODE_SAMPLE'
|
|
||||||
final class SomeClass
|
|
||||||
{
|
|
||||||
}
|
|
||||||
CODE_SAMPLE
|
|
||||||
, ['SomeParentClass'])]);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @return array<class-string<Node>>
|
|
||||||
*/
|
|
||||||
public function getNodeTypes() : array
|
|
||||||
{
|
|
||||||
return [Class_::class];
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param Class_ $node
|
|
||||||
*/
|
|
||||||
public function refactorWithScope(Node $node, Scope $scope) : ?Node
|
|
||||||
{
|
|
||||||
$parentClassReflection = $this->parentClassScopeResolver->resolveParentClassReflection($scope);
|
|
||||||
if (!$parentClassReflection instanceof ClassReflection) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
foreach ($this->parentClassesToRemove as $parentClassToRemove) {
|
|
||||||
if ($parentClassReflection->getName() !== $parentClassToRemove) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// remove parent class
|
|
||||||
$node->extends = null;
|
|
||||||
return $node;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param mixed[] $configuration
|
|
||||||
*/
|
|
||||||
public function configure(array $configuration) : void
|
|
||||||
{
|
|
||||||
Assert::allString($configuration);
|
|
||||||
$this->parentClassesToRemove = $configuration;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||||
* @api
|
* @api
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public const PACKAGE_VERSION = 'a82c86347a6ceba31cdf3180284dc96820e50271';
|
public const PACKAGE_VERSION = '1eee3a5f8727d3385d210222ab8e1f512a4fea19';
|
||||||
/**
|
/**
|
||||||
* @api
|
* @api
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public const RELEASE_DATE = '2023-08-06 17:36:42';
|
public const RELEASE_DATE = '2023-08-06 16:37:21';
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @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';
|
require_once __DIR__ . '/composer/autoload_real.php';
|
||||||
|
|
||||||
return ComposerAutoloaderInit44aea186af25479658e98a5f55cf935c::getLoader();
|
return ComposerAutoloaderInitd9a50416b8211c623ad4c549795de442::getLoader();
|
||||||
|
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
|
@ -2331,7 +2331,6 @@ return array(
|
||||||
'Rector\\Removing\\NodeManipulator\\ComplexNodeRemover' => $baseDir . '/rules/Removing/NodeManipulator/ComplexNodeRemover.php',
|
'Rector\\Removing\\NodeManipulator\\ComplexNodeRemover' => $baseDir . '/rules/Removing/NodeManipulator/ComplexNodeRemover.php',
|
||||||
'Rector\\Removing\\Rector\\ClassMethod\\ArgumentRemoverRector' => $baseDir . '/rules/Removing/Rector/ClassMethod/ArgumentRemoverRector.php',
|
'Rector\\Removing\\Rector\\ClassMethod\\ArgumentRemoverRector' => $baseDir . '/rules/Removing/Rector/ClassMethod/ArgumentRemoverRector.php',
|
||||||
'Rector\\Removing\\Rector\\Class_\\RemoveInterfacesRector' => $baseDir . '/rules/Removing/Rector/Class_/RemoveInterfacesRector.php',
|
'Rector\\Removing\\Rector\\Class_\\RemoveInterfacesRector' => $baseDir . '/rules/Removing/Rector/Class_/RemoveInterfacesRector.php',
|
||||||
'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\\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\\RemoveFuncCallArgRector' => $baseDir . '/rules/Removing/Rector/FuncCall/RemoveFuncCallArgRector.php',
|
||||||
'Rector\\Removing\\Rector\\FuncCall\\RemoveFuncCallRector' => $baseDir . '/rules/Removing/Rector/FuncCall/RemoveFuncCallRector.php',
|
'Rector\\Removing\\Rector\\FuncCall\\RemoveFuncCallRector' => $baseDir . '/rules/Removing/Rector/FuncCall/RemoveFuncCallRector.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
|
// autoload_real.php @generated by Composer
|
||||||
|
|
||||||
class ComposerAutoloaderInit44aea186af25479658e98a5f55cf935c
|
class ComposerAutoloaderInitd9a50416b8211c623ad4c549795de442
|
||||||
{
|
{
|
||||||
private static $loader;
|
private static $loader;
|
||||||
|
|
||||||
|
@ -22,17 +22,17 @@ class ComposerAutoloaderInit44aea186af25479658e98a5f55cf935c
|
||||||
return self::$loader;
|
return self::$loader;
|
||||||
}
|
}
|
||||||
|
|
||||||
spl_autoload_register(array('ComposerAutoloaderInit44aea186af25479658e98a5f55cf935c', 'loadClassLoader'), true, true);
|
spl_autoload_register(array('ComposerAutoloaderInitd9a50416b8211c623ad4c549795de442', 'loadClassLoader'), true, true);
|
||||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||||
spl_autoload_unregister(array('ComposerAutoloaderInit44aea186af25479658e98a5f55cf935c', 'loadClassLoader'));
|
spl_autoload_unregister(array('ComposerAutoloaderInitd9a50416b8211c623ad4c549795de442', 'loadClassLoader'));
|
||||||
|
|
||||||
require __DIR__ . '/autoload_static.php';
|
require __DIR__ . '/autoload_static.php';
|
||||||
call_user_func(\Composer\Autoload\ComposerStaticInit44aea186af25479658e98a5f55cf935c::getInitializer($loader));
|
call_user_func(\Composer\Autoload\ComposerStaticInitd9a50416b8211c623ad4c549795de442::getInitializer($loader));
|
||||||
|
|
||||||
$loader->setClassMapAuthoritative(true);
|
$loader->setClassMapAuthoritative(true);
|
||||||
$loader->register(true);
|
$loader->register(true);
|
||||||
|
|
||||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit44aea186af25479658e98a5f55cf935c::$files;
|
$filesToLoad = \Composer\Autoload\ComposerStaticInitd9a50416b8211c623ad4c549795de442::$files;
|
||||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
$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;
|
namespace Composer\Autoload;
|
||||||
|
|
||||||
class ComposerStaticInit44aea186af25479658e98a5f55cf935c
|
class ComposerStaticInitd9a50416b8211c623ad4c549795de442
|
||||||
{
|
{
|
||||||
public static $files = array (
|
public static $files = array (
|
||||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||||
|
@ -2585,7 +2585,6 @@ class ComposerStaticInit44aea186af25479658e98a5f55cf935c
|
||||||
'Rector\\Removing\\NodeManipulator\\ComplexNodeRemover' => __DIR__ . '/../..' . '/rules/Removing/NodeManipulator/ComplexNodeRemover.php',
|
'Rector\\Removing\\NodeManipulator\\ComplexNodeRemover' => __DIR__ . '/../..' . '/rules/Removing/NodeManipulator/ComplexNodeRemover.php',
|
||||||
'Rector\\Removing\\Rector\\ClassMethod\\ArgumentRemoverRector' => __DIR__ . '/../..' . '/rules/Removing/Rector/ClassMethod/ArgumentRemoverRector.php',
|
'Rector\\Removing\\Rector\\ClassMethod\\ArgumentRemoverRector' => __DIR__ . '/../..' . '/rules/Removing/Rector/ClassMethod/ArgumentRemoverRector.php',
|
||||||
'Rector\\Removing\\Rector\\Class_\\RemoveInterfacesRector' => __DIR__ . '/../..' . '/rules/Removing/Rector/Class_/RemoveInterfacesRector.php',
|
'Rector\\Removing\\Rector\\Class_\\RemoveInterfacesRector' => __DIR__ . '/../..' . '/rules/Removing/Rector/Class_/RemoveInterfacesRector.php',
|
||||||
'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\\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\\RemoveFuncCallArgRector' => __DIR__ . '/../..' . '/rules/Removing/Rector/FuncCall/RemoveFuncCallArgRector.php',
|
||||||
'Rector\\Removing\\Rector\\FuncCall\\RemoveFuncCallRector' => __DIR__ . '/../..' . '/rules/Removing/Rector/FuncCall/RemoveFuncCallRector.php',
|
'Rector\\Removing\\Rector\\FuncCall\\RemoveFuncCallRector' => __DIR__ . '/../..' . '/rules/Removing/Rector/FuncCall/RemoveFuncCallRector.php',
|
||||||
|
@ -3011,9 +3010,9 @@ class ComposerStaticInit44aea186af25479658e98a5f55cf935c
|
||||||
public static function getInitializer(ClassLoader $loader)
|
public static function getInitializer(ClassLoader $loader)
|
||||||
{
|
{
|
||||||
return \Closure::bind(function () use ($loader) {
|
return \Closure::bind(function () use ($loader) {
|
||||||
$loader->prefixLengthsPsr4 = ComposerStaticInit44aea186af25479658e98a5f55cf935c::$prefixLengthsPsr4;
|
$loader->prefixLengthsPsr4 = ComposerStaticInitd9a50416b8211c623ad4c549795de442::$prefixLengthsPsr4;
|
||||||
$loader->prefixDirsPsr4 = ComposerStaticInit44aea186af25479658e98a5f55cf935c::$prefixDirsPsr4;
|
$loader->prefixDirsPsr4 = ComposerStaticInitd9a50416b8211c623ad4c549795de442::$prefixDirsPsr4;
|
||||||
$loader->classMap = ComposerStaticInit44aea186af25479658e98a5f55cf935c::$classMap;
|
$loader->classMap = ComposerStaticInitd9a50416b8211c623ad4c549795de442::$classMap;
|
||||||
|
|
||||||
}, null, ClassLoader::class);
|
}, null, ClassLoader::class);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user