Updated Rector to commit 90b832dc4f10d04b32f2c0cbc473082f6ccd11fb

90b832dc4f cleanup (#4787)
This commit is contained in:
Tomas Votruba 2023-08-14 09:58:25 +00:00
parent 34e7d4f989
commit 951076fc19
6 changed files with 35 additions and 30 deletions

View File

@ -187,18 +187,7 @@ final class PHPStanNodeScopeResolver
$this->processCallike($node, $mutatingScope);
}
if ($node instanceof Trait_) {
$traitName = $this->resolveClassName($node);
$traitClassReflection = $this->reflectionProvider->getClass($traitName);
$traitScope = clone $mutatingScope;
/** @var ScopeContext $scopeContext */
$scopeContext = $this->privatesAccessor->getPrivateProperty($traitScope, self::CONTEXT);
$traitContext = clone $scopeContext;
// before entering the class/trait again, we have to tell scope no class was set, otherwise it crashes
$this->privatesAccessor->setPrivateProperty($traitContext, 'classReflection', $traitClassReflection);
$this->privatesAccessor->setPrivateProperty($traitScope, self::CONTEXT, $traitContext);
$node->setAttribute(AttributeKey::SCOPE, $traitScope);
$this->nodeScopeResolver->processNodes($node->stmts, $traitScope, $nodeCallback);
$this->decorateTraitAttrGroups($node, $traitScope);
$this->processTrait($node, $mutatingScope, $nodeCallback);
return;
}
// the class reflection is resolved AFTER entering to class node
@ -375,4 +364,22 @@ final class PHPStanNodeScopeResolver
}
return $classLike->name->toString();
}
/**
* @param callable(Node $node, MutatingScope $scope): void $nodeCallback
*/
private function processTrait(Trait_ $node, MutatingScope $mutatingScope, callable $nodeCallback) : void
{
$traitName = $this->resolveClassName($node);
$traitClassReflection = $this->reflectionProvider->getClass($traitName);
$traitScope = clone $mutatingScope;
/** @var ScopeContext $scopeContext */
$scopeContext = $this->privatesAccessor->getPrivateProperty($traitScope, self::CONTEXT);
$traitContext = clone $scopeContext;
// before entering the class/trait again, we have to tell scope no class was set, otherwise it crashes
$this->privatesAccessor->setPrivateProperty($traitContext, 'classReflection', $traitClassReflection);
$this->privatesAccessor->setPrivateProperty($traitScope, self::CONTEXT, $traitContext);
$node->setAttribute(AttributeKey::SCOPE, $traitScope);
$this->nodeScopeResolver->processNodes($node->stmts, $traitScope, $nodeCallback);
$this->decorateTraitAttrGroups($node, $traitScope);
}
}

View File

@ -43,20 +43,18 @@ final class UnnecessaryTernaryExpressionRector extends AbstractRector
*/
public function refactor(Node $node) : ?Node
{
/** @var Ternary $ternaryExpression */
$ternaryExpression = $node;
if (!$ternaryExpression->if instanceof Expr) {
if (!$node->if instanceof Expr) {
return null;
}
$ifExpression = $ternaryExpression->if;
$ifExpression = $node->if;
if (!$this->valueResolver->isTrueOrFalse($ifExpression)) {
return null;
}
$elseExpression = $ternaryExpression->else;
$elseExpression = $node->else;
if (!$this->valueResolver->isTrueOrFalse($elseExpression)) {
return null;
}
$condition = $ternaryExpression->cond;
$condition = $node->cond;
if (!$condition instanceof BinaryOp) {
return $this->processNonBinaryCondition($ifExpression, $elseExpression, $condition);
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '29d9b7619d0d8bd68a62cc5ab3fcba5699a50558';
public const PACKAGE_VERSION = '90b832dc4f10d04b32f2c0cbc473082f6ccd11fb';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-08-14 09:20:19';
public const RELEASE_DATE = '2023-08-14 09:54:00';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInita07abf28314c7bf3002ba4f505b67fe5
class ComposerAutoloaderInit279adfe741cabe4d325728768e1fe089
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInita07abf28314c7bf3002ba4f505b67fe5
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInita07abf28314c7bf3002ba4f505b67fe5', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit279adfe741cabe4d325728768e1fe089', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInita07abf28314c7bf3002ba4f505b67fe5', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit279adfe741cabe4d325728768e1fe089', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInita07abf28314c7bf3002ba4f505b67fe5::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit279adfe741cabe4d325728768e1fe089::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInita07abf28314c7bf3002ba4f505b67fe5::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit279adfe741cabe4d325728768e1fe089::$files;
$requireFile = \Closure::bind(static function ($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 ComposerStaticInita07abf28314c7bf3002ba4f505b67fe5
class ComposerStaticInit279adfe741cabe4d325728768e1fe089
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -2958,9 +2958,9 @@ class ComposerStaticInita07abf28314c7bf3002ba4f505b67fe5
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInita07abf28314c7bf3002ba4f505b67fe5::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInita07abf28314c7bf3002ba4f505b67fe5::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInita07abf28314c7bf3002ba4f505b67fe5::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit279adfe741cabe4d325728768e1fe089::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit279adfe741cabe4d325728768e1fe089::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit279adfe741cabe4d325728768e1fe089::$classMap;
}, null, ClassLoader::class);
}