mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-31 16:30:51 +00:00
Updated Rector to commit 27a78d96ed
27a78d96ed
[Cleanup] merge duplicated SplitStringClassConstantToClassConstFetchRector to UseClassKeywordForClassNameResolutionRector (#1401)
This commit is contained in:
parent
d66e622e1b
commit
f63516d9b4
|
@ -26,7 +26,6 @@ use Rector\CodingStyle\Rector\Plus\UseIncrementAssignRector;
|
|||
use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector;
|
||||
use Rector\CodingStyle\Rector\Property\AddFalseDefaultToBoolPropertyRector;
|
||||
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
|
||||
use Rector\CodingStyle\Rector\String_\SplitStringClassConstantToClassConstFetchRector;
|
||||
use Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector;
|
||||
use Rector\CodingStyle\Rector\Switch_\BinarySwitchToIfElseRector;
|
||||
use Rector\CodingStyle\Rector\Ternary\TernaryConditionVariableAssignmentRector;
|
||||
|
@ -43,7 +42,6 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
|
|||
$services->set(\Rector\CodingStyle\Rector\Ternary\TernaryConditionVariableAssignmentRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassConst\SplitGroupedConstantsAndPropertiesRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\String_\SplitStringClassConstantToClassConstFetchRector::class);
|
||||
$services->set(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Include_\FollowRequireByDirRector::class);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# 503 Rules Overview
|
||||
# 502 Rules Overview
|
||||
|
||||
<br>
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
|||
|
||||
- [CodeQuality](#codequality) (70)
|
||||
|
||||
- [CodingStyle](#codingstyle) (36)
|
||||
- [CodingStyle](#codingstyle) (35)
|
||||
|
||||
- [Compatibility](#compatibility) (1)
|
||||
|
||||
|
@ -2437,30 +2437,6 @@ Separate constant and properties to own lines
|
|||
|
||||
<br>
|
||||
|
||||
### SplitStringClassConstantToClassConstFetchRector
|
||||
|
||||
Separate class constant in a string to class constant fetch and string
|
||||
|
||||
- class: [`Rector\CodingStyle\Rector\String_\SplitStringClassConstantToClassConstFetchRector`](../rules/CodingStyle/Rector/String_/SplitStringClassConstantToClassConstFetchRector.php)
|
||||
|
||||
```diff
|
||||
class SomeClass
|
||||
{
|
||||
const HI = true;
|
||||
}
|
||||
|
||||
class AnotherClass
|
||||
{
|
||||
public function get()
|
||||
{
|
||||
- return 'SomeClass::HI';
|
||||
+ return SomeClass::class . '::HI';
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### StrictArraySearchRector
|
||||
|
||||
Makes array_search search for identical elements
|
||||
|
|
|
@ -1,84 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\CodingStyle\Rector\String_;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\BinaryOp\Concat;
|
||||
use PhpParser\Node\Expr\ClassConstFetch;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PHPStan\Reflection\ReflectionProvider;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Tests\CodingStyle\Rector\String_\SplitStringClassConstantToClassConstFetchRector\SplitStringClassConstantToClassConstFetchRectorTest
|
||||
*/
|
||||
final class SplitStringClassConstantToClassConstFetchRector extends \Rector\Core\Rector\AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \PHPStan\Reflection\ReflectionProvider
|
||||
*/
|
||||
private $reflectionProvider;
|
||||
public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider)
|
||||
{
|
||||
$this->reflectionProvider = $reflectionProvider;
|
||||
}
|
||||
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
|
||||
{
|
||||
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Separate class constant in a string to class constant fetch and string', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
const HI = true;
|
||||
}
|
||||
|
||||
class AnotherClass
|
||||
{
|
||||
public function get()
|
||||
{
|
||||
return 'SomeClass::HI';
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
const HI = true;
|
||||
}
|
||||
|
||||
class AnotherClass
|
||||
{
|
||||
public function get()
|
||||
{
|
||||
return SomeClass::class . '::HI';
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [\PhpParser\Node\Scalar\String_::class];
|
||||
}
|
||||
/**
|
||||
* @param String_ $node
|
||||
*/
|
||||
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
|
||||
{
|
||||
if (\substr_count($node->value, '::') !== 1) {
|
||||
return null;
|
||||
}
|
||||
// a possible constant reference
|
||||
[$possibleClass, $secondPart] = \explode('::', $node->value);
|
||||
if (!$this->reflectionProvider->hasClass($possibleClass)) {
|
||||
return null;
|
||||
}
|
||||
$classConstFetch = new \PhpParser\Node\Expr\ClassConstFetch(new \PhpParser\Node\Name\FullyQualified(\ltrim($possibleClass, '\\')), 'class');
|
||||
return new \PhpParser\Node\Expr\BinaryOp\Concat($classConstFetch, new \PhpParser\Node\Scalar\String_('::' . $secondPart));
|
||||
}
|
||||
}
|
|
@ -16,11 +16,11 @@ final class VersionResolver
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'dda87fc6d2b8632967f4907bab94918c18822807';
|
||||
public const PACKAGE_VERSION = '27a78d96ede3ec222e81ea0877e82e06b95e3c87';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2021-12-06 13:39:12';
|
||||
public const RELEASE_DATE = '2021-12-06 08:32:28';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20211206\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -4,4 +4,4 @@
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit7e9404e07f47aa734050af08097d1355::getLoader();
|
||||
return ComposerAutoloaderInit42aeb82cf85e05b426e7cb5ca8bd5e31::getLoader();
|
||||
|
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
|
@ -1582,7 +1582,6 @@ return array(
|
|||
'Rector\\CodingStyle\\Rector\\PostInc\\PostIncDecToPreIncDecRector' => $baseDir . '/rules/CodingStyle/Rector/PostInc/PostIncDecToPreIncDecRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Property\\AddFalseDefaultToBoolPropertyRector' => $baseDir . '/rules/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Stmt\\NewlineAfterStatementRector' => $baseDir . '/rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\String_\\SplitStringClassConstantToClassConstFetchRector' => $baseDir . '/rules/CodingStyle/Rector/String_/SplitStringClassConstantToClassConstFetchRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\String_\\SymplifyQuoteEscapeRector' => $baseDir . '/rules/CodingStyle/Rector/String_/SymplifyQuoteEscapeRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\String_\\UseClassKeywordForClassNameResolutionRector' => $baseDir . '/rules/CodingStyle/Rector/String_/UseClassKeywordForClassNameResolutionRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Switch_\\BinarySwitchToIfElseRector' => $baseDir . '/rules/CodingStyle/Rector/Switch_/BinarySwitchToIfElseRector.php',
|
||||
|
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit7e9404e07f47aa734050af08097d1355
|
||||
class ComposerAutoloaderInit42aeb82cf85e05b426e7cb5ca8bd5e31
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,15 +22,15 @@ class ComposerAutoloaderInit7e9404e07f47aa734050af08097d1355
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit7e9404e07f47aa734050af08097d1355', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit42aeb82cf85e05b426e7cb5ca8bd5e31', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit7e9404e07f47aa734050af08097d1355', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit42aeb82cf85e05b426e7cb5ca8bd5e31', '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\ComposerStaticInit7e9404e07f47aa734050af08097d1355::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit42aeb82cf85e05b426e7cb5ca8bd5e31::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
|
@ -42,19 +42,19 @@ class ComposerAutoloaderInit7e9404e07f47aa734050af08097d1355
|
|||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit7e9404e07f47aa734050af08097d1355::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit42aeb82cf85e05b426e7cb5ca8bd5e31::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire7e9404e07f47aa734050af08097d1355($fileIdentifier, $file);
|
||||
composerRequire42aeb82cf85e05b426e7cb5ca8bd5e31($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire7e9404e07f47aa734050af08097d1355($fileIdentifier, $file)
|
||||
function composerRequire42aeb82cf85e05b426e7cb5ca8bd5e31($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
|
9
vendor/composer/autoload_static.php
vendored
9
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit7e9404e07f47aa734050af08097d1355
|
||||
class ComposerStaticInit42aeb82cf85e05b426e7cb5ca8bd5e31
|
||||
{
|
||||
public static $files = array (
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||
|
@ -1979,7 +1979,6 @@ class ComposerStaticInit7e9404e07f47aa734050af08097d1355
|
|||
'Rector\\CodingStyle\\Rector\\PostInc\\PostIncDecToPreIncDecRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/PostInc/PostIncDecToPreIncDecRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Property\\AddFalseDefaultToBoolPropertyRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Stmt\\NewlineAfterStatementRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\String_\\SplitStringClassConstantToClassConstFetchRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/String_/SplitStringClassConstantToClassConstFetchRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\String_\\SymplifyQuoteEscapeRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/String_/SymplifyQuoteEscapeRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\String_\\UseClassKeywordForClassNameResolutionRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/String_/UseClassKeywordForClassNameResolutionRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Switch_\\BinarySwitchToIfElseRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Switch_/BinarySwitchToIfElseRector.php',
|
||||
|
@ -3789,9 +3788,9 @@ class ComposerStaticInit7e9404e07f47aa734050af08097d1355
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit7e9404e07f47aa734050af08097d1355::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit7e9404e07f47aa734050af08097d1355::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit7e9404e07f47aa734050af08097d1355::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit42aeb82cf85e05b426e7cb5ca8bd5e31::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit42aeb82cf85e05b426e7cb5ca8bd5e31::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit42aeb82cf85e05b426e7cb5ca8bd5e31::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
|
@ -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('RectorPrefix20211206\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit7e9404e07f47aa734050af08097d1355', false) && !interface_exists('ComposerAutoloaderInit7e9404e07f47aa734050af08097d1355', false) && !trait_exists('ComposerAutoloaderInit7e9404e07f47aa734050af08097d1355', false)) {
|
||||
spl_autoload_call('RectorPrefix20211206\ComposerAutoloaderInit7e9404e07f47aa734050af08097d1355');
|
||||
if (!class_exists('ComposerAutoloaderInit42aeb82cf85e05b426e7cb5ca8bd5e31', false) && !interface_exists('ComposerAutoloaderInit42aeb82cf85e05b426e7cb5ca8bd5e31', false) && !trait_exists('ComposerAutoloaderInit42aeb82cf85e05b426e7cb5ca8bd5e31', false)) {
|
||||
spl_autoload_call('RectorPrefix20211206\ComposerAutoloaderInit42aeb82cf85e05b426e7cb5ca8bd5e31');
|
||||
}
|
||||
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('RectorPrefix20211206\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
|
@ -81,9 +81,9 @@ if (!function_exists('print_node')) {
|
|||
return \RectorPrefix20211206\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire7e9404e07f47aa734050af08097d1355')) {
|
||||
function composerRequire7e9404e07f47aa734050af08097d1355() {
|
||||
return \RectorPrefix20211206\composerRequire7e9404e07f47aa734050af08097d1355(...func_get_args());
|
||||
if (!function_exists('composerRequire42aeb82cf85e05b426e7cb5ca8bd5e31')) {
|
||||
function composerRequire42aeb82cf85e05b426e7cb5ca8bd5e31() {
|
||||
return \RectorPrefix20211206\composerRequire42aeb82cf85e05b426e7cb5ca8bd5e31(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user