mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-03 09:50:49 +00:00
Updated Rector to commit 430041fd55
430041fd55
[Privatization] Skip constant exists on RepeatedLiteralToClassConstantRector (#873)
This commit is contained in:
parent
0d132812d7
commit
86f0988ac5
|
@ -9,6 +9,7 @@ use PhpParser\Node\Expr\ClassConstFetch;
|
|||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassConst;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use Rector\Core\NodeManipulator\ClassInsertManipulator;
|
||||
use Rector\Core\Php\ReservedKeywordAnalyzer;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
|
@ -143,17 +144,43 @@ CODE_SAMPLE
|
|||
*/
|
||||
private function replaceStringsWithClassConstReferences(\PhpParser\Node\Stmt\Class_ $class, array $stringsToReplace) : void
|
||||
{
|
||||
$this->traverseNodesWithCallable($class, function (\PhpParser\Node $node) use($stringsToReplace) : ?ClassConstFetch {
|
||||
$classConsts = $class->getConstants();
|
||||
$this->traverseNodesWithCallable($class, function (\PhpParser\Node $node) use($stringsToReplace, $classConsts) : ?ClassConstFetch {
|
||||
if (!$node instanceof \PhpParser\Node\Scalar\String_) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->valueResolver->isValues($node, $stringsToReplace)) {
|
||||
return null;
|
||||
}
|
||||
$isInMethod = (bool) $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\ClassMethod::class);
|
||||
if (!$isInMethod) {
|
||||
return null;
|
||||
}
|
||||
$constantName = $this->createConstName($node->value);
|
||||
if ($this->isClassConstExistsWithDifferentValue($classConsts, $constantName, $node->value)) {
|
||||
return null;
|
||||
}
|
||||
return $this->nodeFactory->createSelfFetchConstant($constantName, $node);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @param ClassConst[] $classConsts
|
||||
*/
|
||||
private function isClassConstExistsWithDifferentValue(array $classConsts, string $constantName, string $value) : bool
|
||||
{
|
||||
foreach ($classConsts as $classConst) {
|
||||
$consts = $classConst->consts;
|
||||
foreach ($consts as $const) {
|
||||
if (!$this->nodeNameResolver->isName($const->name, $constantName)) {
|
||||
continue;
|
||||
}
|
||||
if (!$this->valueResolver->isValue($const->value, $value)) {
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
/**
|
||||
* @param string[] $stringsToReplace
|
||||
*/
|
||||
|
|
|
@ -16,11 +16,11 @@ final class VersionResolver
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'fccd59222366c765096d3a382812859c171c3be3';
|
||||
public const PACKAGE_VERSION = '430041fd553aca364c8fd2379cf854ae320c247b';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2021-09-12 21:33:06';
|
||||
public const RELEASE_DATE = '2021-09-12 23:45:30';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20210912\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 ComposerAutoloaderInit88d1c7480bed88b2599cbb7fbcc55361::getLoader();
|
||||
return ComposerAutoloaderInitabd1865c73ee6d3372857de98cc7d12e::getLoader();
|
||||
|
|
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 ComposerAutoloaderInit88d1c7480bed88b2599cbb7fbcc55361
|
||||
class ComposerAutoloaderInitabd1865c73ee6d3372857de98cc7d12e
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,15 +22,15 @@ class ComposerAutoloaderInit88d1c7480bed88b2599cbb7fbcc55361
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit88d1c7480bed88b2599cbb7fbcc55361', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitabd1865c73ee6d3372857de98cc7d12e', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit88d1c7480bed88b2599cbb7fbcc55361', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitabd1865c73ee6d3372857de98cc7d12e', '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\ComposerStaticInit88d1c7480bed88b2599cbb7fbcc55361::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitabd1865c73ee6d3372857de98cc7d12e::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
|
@ -42,19 +42,19 @@ class ComposerAutoloaderInit88d1c7480bed88b2599cbb7fbcc55361
|
|||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit88d1c7480bed88b2599cbb7fbcc55361::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInitabd1865c73ee6d3372857de98cc7d12e::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire88d1c7480bed88b2599cbb7fbcc55361($fileIdentifier, $file);
|
||||
composerRequireabd1865c73ee6d3372857de98cc7d12e($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire88d1c7480bed88b2599cbb7fbcc55361($fileIdentifier, $file)
|
||||
function composerRequireabd1865c73ee6d3372857de98cc7d12e($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit88d1c7480bed88b2599cbb7fbcc55361
|
||||
class ComposerStaticInitabd1865c73ee6d3372857de98cc7d12e
|
||||
{
|
||||
public static $files = array (
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||
|
@ -3858,9 +3858,9 @@ class ComposerStaticInit88d1c7480bed88b2599cbb7fbcc55361
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit88d1c7480bed88b2599cbb7fbcc55361::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit88d1c7480bed88b2599cbb7fbcc55361::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit88d1c7480bed88b2599cbb7fbcc55361::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitabd1865c73ee6d3372857de98cc7d12e::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitabd1865c73ee6d3372857de98cc7d12e::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitabd1865c73ee6d3372857de98cc7d12e::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
|
@ -4242,12 +4242,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/symplify\/easy-testing.git",
|
||||
"reference": "f905e7ede14b439c18f1abd69cae5b0fa7ba51dd"
|
||||
"reference": "e5e12450fd1d8276cf55e7f9dc8e14a1c8e8a3af"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/symplify\/easy-testing\/zipball\/f905e7ede14b439c18f1abd69cae5b0fa7ba51dd",
|
||||
"reference": "f905e7ede14b439c18f1abd69cae5b0fa7ba51dd",
|
||||
"url": "https:\/\/api.github.com\/repos\/symplify\/easy-testing\/zipball\/e5e12450fd1d8276cf55e7f9dc8e14a1c8e8a3af",
|
||||
"reference": "e5e12450fd1d8276cf55e7f9dc8e14a1c8e8a3af",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -4291,7 +4291,7 @@
|
|||
"require-dev": {
|
||||
"phpunit\/phpunit": "^9.5"
|
||||
},
|
||||
"time": "2021-09-08T22:27:54+00:00",
|
||||
"time": "2021-09-12T15:17:26+00:00",
|
||||
"default-branch": true,
|
||||
"bin": [
|
||||
"bin\/easy-testing"
|
||||
|
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
|
@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
|
|||
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
|
||||
spl_autoload_call('RectorPrefix20210912\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit88d1c7480bed88b2599cbb7fbcc55361', false) && !interface_exists('ComposerAutoloaderInit88d1c7480bed88b2599cbb7fbcc55361', false) && !trait_exists('ComposerAutoloaderInit88d1c7480bed88b2599cbb7fbcc55361', false)) {
|
||||
spl_autoload_call('RectorPrefix20210912\ComposerAutoloaderInit88d1c7480bed88b2599cbb7fbcc55361');
|
||||
if (!class_exists('ComposerAutoloaderInitabd1865c73ee6d3372857de98cc7d12e', false) && !interface_exists('ComposerAutoloaderInitabd1865c73ee6d3372857de98cc7d12e', false) && !trait_exists('ComposerAutoloaderInitabd1865c73ee6d3372857de98cc7d12e', false)) {
|
||||
spl_autoload_call('RectorPrefix20210912\ComposerAutoloaderInitabd1865c73ee6d3372857de98cc7d12e');
|
||||
}
|
||||
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('RectorPrefix20210912\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
|
@ -3311,9 +3311,9 @@ if (!function_exists('print_node')) {
|
|||
return \RectorPrefix20210912\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire88d1c7480bed88b2599cbb7fbcc55361')) {
|
||||
function composerRequire88d1c7480bed88b2599cbb7fbcc55361() {
|
||||
return \RectorPrefix20210912\composerRequire88d1c7480bed88b2599cbb7fbcc55361(...func_get_args());
|
||||
if (!function_exists('composerRequireabd1865c73ee6d3372857de98cc7d12e')) {
|
||||
function composerRequireabd1865c73ee6d3372857de98cc7d12e() {
|
||||
return \RectorPrefix20210912\composerRequireabd1865c73ee6d3372857de98cc7d12e(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('parseArgs')) {
|
||||
|
|
|
@ -7,7 +7,10 @@ use Symplify\SmartFileSystem\SmartFileInfo;
|
|||
use RectorPrefix20210912\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
final class StaticFixtureUpdater
|
||||
{
|
||||
public static function updateFixtureContent(\Symplify\SmartFileSystem\SmartFileInfo $originalFileInfo, string $changedContent, \Symplify\SmartFileSystem\SmartFileInfo $fixtureFileInfo) : void
|
||||
/**
|
||||
* @param \Symplify\SmartFileSystem\SmartFileInfo|string $originalFileInfo
|
||||
*/
|
||||
public static function updateFixtureContent($originalFileInfo, string $changedContent, \Symplify\SmartFileSystem\SmartFileInfo $fixtureFileInfo) : void
|
||||
{
|
||||
if (!\getenv('UPDATE_TESTS') && !\getenv('UT')) {
|
||||
return;
|
||||
|
@ -26,11 +29,19 @@ final class StaticFixtureUpdater
|
|||
{
|
||||
return new \RectorPrefix20210912\Symplify\SmartFileSystem\SmartFileSystem();
|
||||
}
|
||||
private static function resolveNewFixtureContent(\Symplify\SmartFileSystem\SmartFileInfo $originalFileInfo, string $changedContent) : string
|
||||
/**
|
||||
* @param \Symplify\SmartFileSystem\SmartFileInfo|string $originalFileInfo
|
||||
*/
|
||||
private static function resolveNewFixtureContent($originalFileInfo, string $changedContent) : string
|
||||
{
|
||||
if ($originalFileInfo->getContents() === $changedContent) {
|
||||
return $originalFileInfo->getContents();
|
||||
if ($originalFileInfo instanceof \Symplify\SmartFileSystem\SmartFileInfo) {
|
||||
$originalContent = $originalFileInfo->getContents();
|
||||
} else {
|
||||
$originalContent = $originalFileInfo;
|
||||
}
|
||||
return $originalFileInfo->getContents() . '-----' . \PHP_EOL . $changedContent;
|
||||
if ($originalContent === $changedContent) {
|
||||
return $originalContent;
|
||||
}
|
||||
return $originalContent . '-----' . \PHP_EOL . $changedContent;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user