Updated Rector to commit dc07c1f9a8

dc07c1f9a8 [CodingStyle] Remove PreslashSimpleFunctionRector, let php-cs-fixer doing good work handle that (#1310)
This commit is contained in:
Tomas Votruba 2021-11-25 18:41:12 +00:00
parent a4f53d3d05
commit cf2bb9a656
8 changed files with 28 additions and 158 deletions

View File

@ -1,4 +1,4 @@
# 501 Rules Overview
# 499 Rules Overview
<br>
@ -12,7 +12,7 @@
- [CodeQuality](#codequality) (69)
- [CodingStyle](#codingstyle) (38)
- [CodingStyle](#codingstyle) (37)
- [Compatibility](#compatibility) (1)
@ -20,7 +20,7 @@
- [DeadCode](#deadcode) (50)
- [DependencyInjection](#dependencyinjection) (3)
- [DependencyInjection](#dependencyinjection) (2)
- [DowngradePhp53](#downgradephp53) (1)
@ -2317,25 +2317,6 @@ return static function (ContainerConfigurator $containerConfigurator): void {
<br>
### PreslashSimpleFunctionRector
Add pre-slash to short named functions to improve performance
- class: [`Rector\CodingStyle\Rector\FuncCall\PreslashSimpleFunctionRector`](../rules/CodingStyle/Rector/FuncCall/PreslashSimpleFunctionRector.php)
```diff
class SomeClass
{
public function shorten($value)
{
- return trim($value);
+ return \trim($value);
}
}
```
<br>
### RemoveDoubleUnderscoreInMethodNameRector
Non-magic PHP object methods cannot start with "__"
@ -4001,18 +3982,14 @@ Turns action injection in Controllers to constructor injection
final class SomeController
{
- public function default(ProductRepository $productRepository)
+ /**
+ * @var ProductRepository
+ */
+ private $productRepository;
+ public function __construct(ProductRepository $productRepository)
{
- $products = $productRepository->fetchAll();
+ $this->productRepository = $productRepository;
+ public function __construct(
+ private ProductRepository $productRepository
+ ) {
+ }
+
+ public function default()
+ {
{
- $products = $productRepository->fetchAll();
+ $products = $this->productRepository->fetchAll();
}
}
@ -4060,35 +4037,6 @@ return static function (ContainerConfigurator $containerConfigurator): void {
<br>
### ReplaceVariableByPropertyFetchRector
Turns variable in controller action to property fetch, as follow up to action injection variable to property change.
- class: [`Rector\DependencyInjection\Rector\Variable\ReplaceVariableByPropertyFetchRector`](../rules/DependencyInjection/Rector/Variable/ReplaceVariableByPropertyFetchRector.php)
```diff
final class SomeController
{
/**
* @var ProductRepository
*/
private $productRepository;
public function __construct(ProductRepository $productRepository)
{
$this->productRepository = $productRepository;
}
public function default()
{
- $products = $productRepository->fetchAll();
+ $products = $this->productRepository->fetchAll();
}
}
```
<br>
## DowngradePhp53
### DirConstToFileConstRector
@ -8883,7 +8831,7 @@ Add unique use imports collected during Rector run
Change global `$variables` to private properties
- class: [`Rector\Privatization\Rector\Class_\ChangeGlobalVariablesToPropertiesRector`](../rules/Privatization/Rector/ClassMethod/ChangeGlobalVariablesToPropertiesRector.php)
- class: [`Rector\Privatization\Rector\Class_\ChangeGlobalVariablesToPropertiesRector`](../rules/Privatization/Rector/Class_/ChangeGlobalVariablesToPropertiesRector.php)
```diff
class SomeClass

View File

@ -1,76 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\CodingStyle\Rector\FuncCall;
use PhpParser\Node;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\Function_;
use Rector\Core\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @changelog https://stackoverflow.com/questions/55419673/php7-adding-a-slash-to-all-standard-php-functions-php-cs-fixer-rule
*
* @see \Rector\Tests\CodingStyle\Rector\FuncCall\PreslashSimpleFunctionRector\PreslashSimpleFunctionRectorTest
*/
final class PreslashSimpleFunctionRector extends \Rector\Core\Rector\AbstractRector
{
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Add pre-slash to short named functions to improve performance', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE'
class SomeClass
{
public function shorten($value)
{
return trim($value);
}
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
class SomeClass
{
public function shorten($value)
{
return \trim($value);
}
}
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [\PhpParser\Node\Expr\FuncCall::class];
}
/**
* @param FuncCall $node
*/
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
{
if ($node->name instanceof \PhpParser\Node\Name\FullyQualified) {
return null;
}
$functionName = $this->getName($node);
if ($functionName === null) {
return null;
}
if (\strpos($functionName, '\\') !== \false) {
return null;
}
$isDefinedPreviousCall = (bool) $this->betterNodeFinder->findFirstPreviousOfNode($node, function (\PhpParser\Node $node) use($functionName) : bool {
if (!$node instanceof \PhpParser\Node\Stmt\Function_) {
return \false;
}
return $this->isName($node->name, $functionName);
});
if ($isDefinedPreviousCall) {
return null;
}
$node->name = new \PhpParser\Node\Name\FullyQualified($functionName);
return $node;
}
}

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '2215cb23ecaa41d756b25a37cdb42ba1a19a9909';
public const PACKAGE_VERSION = 'dc07c1f9a8c03c73915fec8d9fb8ef324e9e5ed2';
/**
* @var string
*/
public const RELEASE_DATE = '2021-11-25 20:01:16';
public const RELEASE_DATE = '2021-11-25 18:26:06';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20211125\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit1c8635e3fbfc3fb7106f9de24e8c41eb::getLoader();
return ComposerAutoloaderInit99c9d5125c06e991ece166f257758bda::getLoader();

View File

@ -1560,7 +1560,6 @@ return array(
'Rector\\CodingStyle\\Rector\\FuncCall\\ConsistentImplodeRector' => $baseDir . '/rules/CodingStyle/Rector/FuncCall/ConsistentImplodeRector.php',
'Rector\\CodingStyle\\Rector\\FuncCall\\ConsistentPregDelimiterRector' => $baseDir . '/rules/CodingStyle/Rector/FuncCall/ConsistentPregDelimiterRector.php',
'Rector\\CodingStyle\\Rector\\FuncCall\\CountArrayToEmptyArrayComparisonRector' => $baseDir . '/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php',
'Rector\\CodingStyle\\Rector\\FuncCall\\PreslashSimpleFunctionRector' => $baseDir . '/rules/CodingStyle/Rector/FuncCall/PreslashSimpleFunctionRector.php',
'Rector\\CodingStyle\\Rector\\FuncCall\\StrictArraySearchRector' => $baseDir . '/rules/CodingStyle/Rector/FuncCall/StrictArraySearchRector.php',
'Rector\\CodingStyle\\Rector\\FuncCall\\VersionCompareFuncCallToConstantRector' => $baseDir . '/rules/CodingStyle/Rector/FuncCall/VersionCompareFuncCallToConstantRector.php',
'Rector\\CodingStyle\\Rector\\If_\\NullableCompareToNullRector' => $baseDir . '/rules/CodingStyle/Rector/If_/NullableCompareToNullRector.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit1c8635e3fbfc3fb7106f9de24e8c41eb
class ComposerAutoloaderInit99c9d5125c06e991ece166f257758bda
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit1c8635e3fbfc3fb7106f9de24e8c41eb
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit1c8635e3fbfc3fb7106f9de24e8c41eb', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit99c9d5125c06e991ece166f257758bda', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit1c8635e3fbfc3fb7106f9de24e8c41eb', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit99c9d5125c06e991ece166f257758bda', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit1c8635e3fbfc3fb7106f9de24e8c41eb::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit99c9d5125c06e991ece166f257758bda::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInit1c8635e3fbfc3fb7106f9de24e8c41eb
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit1c8635e3fbfc3fb7106f9de24e8c41eb::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit99c9d5125c06e991ece166f257758bda::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire1c8635e3fbfc3fb7106f9de24e8c41eb($fileIdentifier, $file);
composerRequire99c9d5125c06e991ece166f257758bda($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire1c8635e3fbfc3fb7106f9de24e8c41eb($fileIdentifier, $file)
function composerRequire99c9d5125c06e991ece166f257758bda($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit1c8635e3fbfc3fb7106f9de24e8c41eb
class ComposerStaticInit99c9d5125c06e991ece166f257758bda
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -1957,7 +1957,6 @@ class ComposerStaticInit1c8635e3fbfc3fb7106f9de24e8c41eb
'Rector\\CodingStyle\\Rector\\FuncCall\\ConsistentImplodeRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/FuncCall/ConsistentImplodeRector.php',
'Rector\\CodingStyle\\Rector\\FuncCall\\ConsistentPregDelimiterRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/FuncCall/ConsistentPregDelimiterRector.php',
'Rector\\CodingStyle\\Rector\\FuncCall\\CountArrayToEmptyArrayComparisonRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php',
'Rector\\CodingStyle\\Rector\\FuncCall\\PreslashSimpleFunctionRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/FuncCall/PreslashSimpleFunctionRector.php',
'Rector\\CodingStyle\\Rector\\FuncCall\\StrictArraySearchRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/FuncCall/StrictArraySearchRector.php',
'Rector\\CodingStyle\\Rector\\FuncCall\\VersionCompareFuncCallToConstantRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/FuncCall/VersionCompareFuncCallToConstantRector.php',
'Rector\\CodingStyle\\Rector\\If_\\NullableCompareToNullRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/If_/NullableCompareToNullRector.php',
@ -3766,9 +3765,9 @@ class ComposerStaticInit1c8635e3fbfc3fb7106f9de24e8c41eb
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit1c8635e3fbfc3fb7106f9de24e8c41eb::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit1c8635e3fbfc3fb7106f9de24e8c41eb::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit1c8635e3fbfc3fb7106f9de24e8c41eb::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit99c9d5125c06e991ece166f257758bda::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit99c9d5125c06e991ece166f257758bda::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit99c9d5125c06e991ece166f257758bda::$classMap;
}, null, ClassLoader::class);
}

View File

@ -12,8 +12,8 @@ if (!class_exists('GenerateChangelogCommand', false) && !interface_exists('Gener
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20211125\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit1c8635e3fbfc3fb7106f9de24e8c41eb', false) && !interface_exists('ComposerAutoloaderInit1c8635e3fbfc3fb7106f9de24e8c41eb', false) && !trait_exists('ComposerAutoloaderInit1c8635e3fbfc3fb7106f9de24e8c41eb', false)) {
spl_autoload_call('RectorPrefix20211125\ComposerAutoloaderInit1c8635e3fbfc3fb7106f9de24e8c41eb');
if (!class_exists('ComposerAutoloaderInit99c9d5125c06e991ece166f257758bda', false) && !interface_exists('ComposerAutoloaderInit99c9d5125c06e991ece166f257758bda', false) && !trait_exists('ComposerAutoloaderInit99c9d5125c06e991ece166f257758bda', false)) {
spl_autoload_call('RectorPrefix20211125\ComposerAutoloaderInit99c9d5125c06e991ece166f257758bda');
}
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
spl_autoload_call('RectorPrefix20211125\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -81,9 +81,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20211125\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire1c8635e3fbfc3fb7106f9de24e8c41eb')) {
function composerRequire1c8635e3fbfc3fb7106f9de24e8c41eb() {
return \RectorPrefix20211125\composerRequire1c8635e3fbfc3fb7106f9de24e8c41eb(...func_get_args());
if (!function_exists('composerRequire99c9d5125c06e991ece166f257758bda')) {
function composerRequire99c9d5125c06e991ece166f257758bda() {
return \RectorPrefix20211125\composerRequire99c9d5125c06e991ece166f257758bda(...func_get_args());
}
}
if (!function_exists('scanPath')) {