mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit fdf11bab10f9e7e1d63b4e0dba1325b947391e5d
fdf11bab10
Refactor PARENT_NODE from StringClassNameToClassConstantRector (#3989)
This commit is contained in:
parent
d48ca72a44
commit
0256872962
|
@ -4,19 +4,18 @@ declare (strict_types=1);
|
|||
namespace Rector\Php55\Rector\String_;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\BinaryOp\Concat;
|
||||
use PhpParser\Node\Expr\ClassConstFetch;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt\ClassConst;
|
||||
use PhpParser\NodeTraverser;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Reflection\ReflectionProvider;
|
||||
use Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface;
|
||||
use Rector\Core\Rector\AbstractScopeAwareRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
|
@ -76,13 +75,20 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [String_::class];
|
||||
return [String_::class, FuncCall::class];
|
||||
}
|
||||
/**
|
||||
* @param String_ $node
|
||||
* @param String_|FuncCall $node
|
||||
*/
|
||||
public function refactorWithScope(Node $node, Scope $scope) : ?Node
|
||||
public function refactorWithScope(Node $node, Scope $scope)
|
||||
{
|
||||
// keep allowed string as condition
|
||||
if ($node instanceof FuncCall) {
|
||||
if ($this->isName($node, 'is_a')) {
|
||||
return NodeTraverser::DONT_TRAVERSE_CHILDREN;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
$classLikeName = $node->value;
|
||||
// remove leading slash
|
||||
$classLikeName = \ltrim($classLikeName, '\\');
|
||||
|
@ -114,18 +120,6 @@ CODE_SAMPLE
|
|||
{
|
||||
return PhpVersionFeature::CLASSNAME_CONSTANT;
|
||||
}
|
||||
private function isPartOfIsAFuncCall(String_ $string) : bool
|
||||
{
|
||||
$parentNode = $string->getAttribute(AttributeKey::PARENT_NODE);
|
||||
if (!$parentNode instanceof Arg) {
|
||||
return \false;
|
||||
}
|
||||
$parentParentNode = $parentNode->getAttribute(AttributeKey::PARENT_NODE);
|
||||
if (!$parentParentNode instanceof FuncCall) {
|
||||
return \false;
|
||||
}
|
||||
return $this->nodeNameResolver->isName($parentParentNode, 'is_a');
|
||||
}
|
||||
private function shouldSkip(string $classLikeName, String_ $string) : bool
|
||||
{
|
||||
if (!$this->reflectionProvider->hasClass($classLikeName)) {
|
||||
|
@ -148,9 +142,6 @@ CODE_SAMPLE
|
|||
return \true;
|
||||
}
|
||||
}
|
||||
if ($this->isPartOfIsAFuncCall($string)) {
|
||||
return \true;
|
||||
}
|
||||
// allow class strings to be part of class const arrays, as probably on purpose
|
||||
$parentClassConst = $this->betterNodeFinder->findParentType($string, ClassConst::class);
|
||||
return $parentClassConst instanceof ClassConst;
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'd9908088500d235348a84de13f96823bc03b4706';
|
||||
public const PACKAGE_VERSION = 'fdf11bab10f9e7e1d63b4e0dba1325b947391e5d';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-05-27 10:27:42';
|
||||
public const RELEASE_DATE = '2023-05-27 10:34:59';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
|
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitb041b2008404bb96ce93c95e3bddbe5c::getLoader();
|
||||
return ComposerAutoloaderInit3e83712edbcb7a626236ec5135aec8cd::getLoader();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitb041b2008404bb96ce93c95e3bddbe5c
|
||||
class ComposerAutoloaderInit3e83712edbcb7a626236ec5135aec8cd
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,17 +22,17 @@ class ComposerAutoloaderInitb041b2008404bb96ce93c95e3bddbe5c
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitb041b2008404bb96ce93c95e3bddbe5c', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit3e83712edbcb7a626236ec5135aec8cd', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitb041b2008404bb96ce93c95e3bddbe5c', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit3e83712edbcb7a626236ec5135aec8cd', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitb041b2008404bb96ce93c95e3bddbe5c::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit3e83712edbcb7a626236ec5135aec8cd::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitb041b2008404bb96ce93c95e3bddbe5c::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit3e83712edbcb7a626236ec5135aec8cd::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitb041b2008404bb96ce93c95e3bddbe5c
|
||||
class ComposerStaticInit3e83712edbcb7a626236ec5135aec8cd
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -3089,9 +3089,9 @@ class ComposerStaticInitb041b2008404bb96ce93c95e3bddbe5c
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitb041b2008404bb96ce93c95e3bddbe5c::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitb041b2008404bb96ce93c95e3bddbe5c::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitb041b2008404bb96ce93c95e3bddbe5c::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit3e83712edbcb7a626236ec5135aec8cd::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit3e83712edbcb7a626236ec5135aec8cd::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit3e83712edbcb7a626236ec5135aec8cd::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue