mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-02 17:30:50 +00:00
Updated Rector to commit 10c6a3047fde6a6a2f94c9260dc3482de6e7f5c0
10c6a3047f
[Php80] Add ::class support on GetDebugTypeRector (#3039)
This commit is contained in:
parent
bba6495f7d
commit
329458c65d
|
@ -5,8 +5,10 @@ namespace Rector\Php80\Rector\Ternary;
|
|||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\ClassConstFetch;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Expr\Ternary;
|
||||
use PhpParser\Node\Identifier;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
|
@ -63,15 +65,9 @@ CODE_SAMPLE
|
|||
if (!$this->areValuesIdentical($node)) {
|
||||
return null;
|
||||
}
|
||||
/** @var FuncCall $funcCall */
|
||||
$funcCall = $node->if;
|
||||
if (!isset($funcCall->args[0])) {
|
||||
return null;
|
||||
}
|
||||
if (!$funcCall->args[0] instanceof Arg) {
|
||||
return null;
|
||||
}
|
||||
$firstExpr = $funcCall->args[0]->value;
|
||||
/** @var FuncCall|ClassConstFetch $getClassFuncCallOrClassConstFetchClass */
|
||||
$getClassFuncCallOrClassConstFetchClass = $node->if;
|
||||
$firstExpr = $getClassFuncCallOrClassConstFetchClass instanceof FuncCall ? $getClassFuncCallOrClassConstFetchClass->args[0]->value : $getClassFuncCallOrClassConstFetchClass->class;
|
||||
return $this->nodeFactory->createFuncCall('get_debug_type', [$firstExpr]);
|
||||
}
|
||||
private function shouldSkip(Ternary $ternary) : bool
|
||||
|
@ -79,11 +75,20 @@ CODE_SAMPLE
|
|||
if (!$ternary->cond instanceof FuncCall) {
|
||||
return \true;
|
||||
}
|
||||
if ($ternary->cond->isFirstClassCallable()) {
|
||||
return \true;
|
||||
}
|
||||
if (!isset($ternary->cond->args[0])) {
|
||||
return \true;
|
||||
}
|
||||
if (!$this->nodeNameResolver->isName($ternary->cond, 'is_object')) {
|
||||
return \true;
|
||||
}
|
||||
if (!$ternary->if instanceof FuncCall) {
|
||||
return \true;
|
||||
if (!$ternary->if instanceof ClassConstFetch) {
|
||||
return \true;
|
||||
}
|
||||
return $this->shouldSkipClassConstFetch($ternary->if);
|
||||
}
|
||||
if (!$this->nodeNameResolver->isName($ternary->if, 'get_class')) {
|
||||
return \true;
|
||||
|
@ -91,22 +96,29 @@ CODE_SAMPLE
|
|||
if (!$ternary->else instanceof FuncCall) {
|
||||
return \true;
|
||||
}
|
||||
if ($ternary->else->isFirstClassCallable()) {
|
||||
return \true;
|
||||
}
|
||||
return !$this->nodeNameResolver->isName($ternary->else, 'gettype');
|
||||
}
|
||||
private function shouldSkipClassConstFetch(ClassConstFetch $classConstFetch) : bool
|
||||
{
|
||||
if (!$classConstFetch->name instanceof Identifier) {
|
||||
return \true;
|
||||
}
|
||||
return $classConstFetch->name->toString() !== 'class';
|
||||
}
|
||||
private function areValuesIdentical(Ternary $ternary) : bool
|
||||
{
|
||||
/** @var FuncCall $isObjectFuncCall */
|
||||
$isObjectFuncCall = $ternary->cond;
|
||||
if (!$isObjectFuncCall->args[0] instanceof Arg) {
|
||||
return \false;
|
||||
}
|
||||
$firstExpr = $isObjectFuncCall->args[0]->value;
|
||||
/** @var FuncCall $getClassFuncCall */
|
||||
$getClassFuncCall = $ternary->if;
|
||||
if (!$getClassFuncCall->args[0] instanceof Arg) {
|
||||
/** @var FuncCall|ClassConstFetch $getClassFuncCallOrClassConstFetchClass */
|
||||
$getClassFuncCallOrClassConstFetchClass = $ternary->if;
|
||||
if ($getClassFuncCallOrClassConstFetchClass instanceof FuncCall && !$getClassFuncCallOrClassConstFetchClass->args[0] instanceof Arg) {
|
||||
return \false;
|
||||
}
|
||||
$secondExpr = $getClassFuncCall->args[0]->value;
|
||||
$secondExpr = $getClassFuncCallOrClassConstFetchClass instanceof FuncCall ? $getClassFuncCallOrClassConstFetchClass->args[0]->value : $getClassFuncCallOrClassConstFetchClass->class;
|
||||
/** @var FuncCall $gettypeFuncCall */
|
||||
$gettypeFuncCall = $ternary->else;
|
||||
if (!$gettypeFuncCall->args[0] instanceof Arg) {
|
||||
|
|
|
@ -17,12 +17,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '10346eea20d2222819f59b2ae994acc0948352e4';
|
||||
public const PACKAGE_VERSION = '10c6a3047fde6a6a2f94c9260dc3482de6e7f5c0';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-11-07 18:22:38';
|
||||
public const RELEASE_DATE = '2022-11-08 14:32:39';
|
||||
/**
|
||||
* @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';
|
||||
|
||||
return ComposerAutoloaderInite40be044087bafda59efd8531e8e88af::getLoader();
|
||||
return ComposerAutoloaderInit1c3cbccfa64a5d167f095ce822ca30fd::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 ComposerAutoloaderInite40be044087bafda59efd8531e8e88af
|
||||
class ComposerAutoloaderInit1c3cbccfa64a5d167f095ce822ca30fd
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,19 +22,19 @@ class ComposerAutoloaderInite40be044087bafda59efd8531e8e88af
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInite40be044087bafda59efd8531e8e88af', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit1c3cbccfa64a5d167f095ce822ca30fd', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInite40be044087bafda59efd8531e8e88af', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit1c3cbccfa64a5d167f095ce822ca30fd', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInite40be044087bafda59efd8531e8e88af::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit1c3cbccfa64a5d167f095ce822ca30fd::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInite40be044087bafda59efd8531e8e88af::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit1c3cbccfa64a5d167f095ce822ca30fd::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequiree40be044087bafda59efd8531e8e88af($fileIdentifier, $file);
|
||||
composerRequire1c3cbccfa64a5d167f095ce822ca30fd($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
|
@ -46,7 +46,7 @@ class ComposerAutoloaderInite40be044087bafda59efd8531e8e88af
|
|||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequiree40be044087bafda59efd8531e8e88af($fileIdentifier, $file)
|
||||
function composerRequire1c3cbccfa64a5d167f095ce822ca30fd($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInite40be044087bafda59efd8531e8e88af
|
||||
class ComposerStaticInit1c3cbccfa64a5d167f095ce822ca30fd
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -3053,9 +3053,9 @@ class ComposerStaticInite40be044087bafda59efd8531e8e88af
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInite40be044087bafda59efd8531e8e88af::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInite40be044087bafda59efd8531e8e88af::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInite40be044087bafda59efd8531e8e88af::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit1c3cbccfa64a5d167f095ce822ca30fd::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit1c3cbccfa64a5d167f095ce822ca30fd::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit1c3cbccfa64a5d167f095ce822ca30fd::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user