Updated Rector to commit 32834d053a5f5eec0f9fb9af80cad1bfce8b6c53

32834d053a [DeadCode] Handle crash on negation class const fetch with static:: and parent:: on RemoveDeadZeroAndOneOperationRector (#2714)
This commit is contained in:
Tomas Votruba 2022-07-26 14:50:37 +00:00
parent a746965f93
commit 33706ccdea
5 changed files with 35 additions and 20 deletions

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'f0df3c5101f4b9465708589a2c13027bc84f898c';
public const PACKAGE_VERSION = '32834d053a5f5eec0f9fb9af80cad1bfce8b6c53';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-07-26 14:46:50';
public const RELEASE_DATE = '2022-07-26 16:45:47';
/**
* @var int
*/

View File

@ -10,8 +10,10 @@ use PhpParser\Node\Expr;
use PhpParser\Node\Expr\BinaryOp\Concat;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Scalar\MagicConst\Dir;
use PhpParser\Node\Scalar\MagicConst\File;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassLike;
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\Type\Constant\ConstantArrayType;
@ -247,12 +249,8 @@ final class ValueResolver
if ($constant === null) {
throw new ShouldNotHappenException();
}
if ($class === ObjectReference::SELF) {
$classLike = $this->betterNodeFinder->findParentType($classConstFetch, ClassLike::class);
if (!$classLike instanceof ClassLike) {
throw new ShouldNotHappenException('Complete class parent node for to class const fetch, so "self" references is resolvable to a class name');
}
$class = (string) $this->nodeNameResolver->getName($classLike);
if (\in_array($class, [ObjectReference::SELF, ObjectReference::STATIC, ObjectReference::PARENT], \true)) {
$class = $this->resolveClassFromSelfStaticParent($classConstFetch, $class);
}
if ($constant === 'class') {
return $class;
@ -271,4 +269,21 @@ final class ValueResolver
// fallback to constant reference itself, to avoid fatal error
return $classConstantReference;
}
private function resolveClassFromSelfStaticParent(ClassConstFetch $classConstFetch, string $class) : string
{
$classLike = $this->betterNodeFinder->findParentType($classConstFetch, ClassLike::class);
if (!$classLike instanceof ClassLike) {
throw new ShouldNotHappenException('Complete class parent node for to class const fetch, so "self" or "static" references is resolvable to a class name');
}
if ($class === ObjectReference::PARENT) {
if (!$classLike instanceof Class_) {
throw new ShouldNotHappenException('Complete class parent node for to class const fetch, so "parent" references is resolvable to lookup parent class');
}
if (!$classLike->extends instanceof FullyQualified) {
throw new ShouldNotHappenException();
}
return $classLike->extends->toString();
}
return (string) $this->nodeNameResolver->getName($classLike);
}
}

2
vendor/autoload.php vendored
View File

@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit2e718407cdf3da2747ba3c260c1dd675::getLoader();
return ComposerAutoloaderInitd92267a2425c0f3fbdfd4cd5ff448fc6::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit2e718407cdf3da2747ba3c260c1dd675
class ComposerAutoloaderInitd92267a2425c0f3fbdfd4cd5ff448fc6
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit2e718407cdf3da2747ba3c260c1dd675
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit2e718407cdf3da2747ba3c260c1dd675', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitd92267a2425c0f3fbdfd4cd5ff448fc6', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit2e718407cdf3da2747ba3c260c1dd675', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitd92267a2425c0f3fbdfd4cd5ff448fc6', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit2e718407cdf3da2747ba3c260c1dd675::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitd92267a2425c0f3fbdfd4cd5ff448fc6::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit2e718407cdf3da2747ba3c260c1dd675::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInitd92267a2425c0f3fbdfd4cd5ff448fc6::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire2e718407cdf3da2747ba3c260c1dd675($fileIdentifier, $file);
composerRequired92267a2425c0f3fbdfd4cd5ff448fc6($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit2e718407cdf3da2747ba3c260c1dd675
* @param string $file
* @return void
*/
function composerRequire2e718407cdf3da2747ba3c260c1dd675($fileIdentifier, $file)
function composerRequired92267a2425c0f3fbdfd4cd5ff448fc6($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit2e718407cdf3da2747ba3c260c1dd675
class ComposerStaticInitd92267a2425c0f3fbdfd4cd5ff448fc6
{
public static $files = array (
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
@ -3406,9 +3406,9 @@ class ComposerStaticInit2e718407cdf3da2747ba3c260c1dd675
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit2e718407cdf3da2747ba3c260c1dd675::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit2e718407cdf3da2747ba3c260c1dd675::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit2e718407cdf3da2747ba3c260c1dd675::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitd92267a2425c0f3fbdfd4cd5ff448fc6::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitd92267a2425c0f3fbdfd4cd5ff448fc6::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitd92267a2425c0f3fbdfd4cd5ff448fc6::$classMap;
}, null, ClassLoader::class);
}