Updated Rector to commit 2762c508eb2fb40b1ef0f7c07c9e970839e5196c

2762c508eb Handle crash on RenameFunctionRector+ForRepeatedCountToOwnVariableRector+CountOnNullRector+NullToStrictStringFuncCallArgRector (#2777)
This commit is contained in:
Tomas Votruba 2022-08-17 21:51:24 +00:00
parent fbb3acc7ba
commit a9aac8f275
5 changed files with 25 additions and 28 deletions

View File

@ -18,15 +18,13 @@ use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Stmt\Trait_;
use PHPStan\Analyser\Scope;
use PHPStan\Type\ArrayType;
use PHPStan\Type\ErrorType;
use PHPStan\Type\NullType;
use PHPStan\Type\Type;
use PHPStan\Type\UnionType;
use Rector\Core\NodeAnalyzer\VariableAnalyzer;
use Rector\Core\Php\PhpVersionProvider;
use Rector\Core\Rector\AbstractScopeAwareRector;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\NodeTypeResolver\TypeAnalyzer\CountableTypeAnalyzer;
@ -39,7 +37,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
*
* @see \Rector\Tests\Php71\Rector\FuncCall\CountOnNullRector\CountOnNullRectorTest
*/
final class CountOnNullRector extends AbstractScopeAwareRector implements MinPhpVersionInterface
final class CountOnNullRector extends AbstractRector implements MinPhpVersionInterface
{
/**
* @readonly
@ -94,9 +92,9 @@ CODE_SAMPLE
/**
* @param FuncCall $node
*/
public function refactorWithScope(Node $node, Scope $scope) : ?Node
public function refactor(Node $node) : ?Node
{
if ($this->shouldSkip($node, $scope)) {
if ($this->shouldSkip($node)) {
return null;
}
/** @var Arg $arg0 */
@ -148,7 +146,7 @@ CODE_SAMPLE
}
return \true;
}
private function shouldSkip(FuncCall $funcCall, Scope $scope) : bool
private function shouldSkip(FuncCall $funcCall) : bool
{
if (!$this->isName($funcCall, 'count')) {
return \true;
@ -174,13 +172,12 @@ CODE_SAMPLE
if (!$funcCall->args[0]->value instanceof Variable) {
return \false;
}
$variableName = (string) $this->getName($funcCall->args[0]->value);
if (!$scope->hasVariableType($variableName)->yes()) {
return \true;
}
$nativeType = $scope->getNativeType($funcCall->args[0]->value);
if ($nativeType instanceof ErrorType) {
return \true;
$parentNode = $funcCall->getAttribute(AttributeKey::PARENT_NODE);
if ($parentNode instanceof Node) {
$originalParentNode = $parentNode->getAttribute(AttributeKey::ORIGINAL_NODE);
if (!$this->nodeComparator->areNodesEqual($parentNode, $originalParentNode)) {
return \true;
}
}
return $this->variableAnalyzer->isStaticOrGlobal($funcCall->args[0]->value);
}

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '0.14.0';
public const PACKAGE_VERSION = '2762c508eb2fb40b1ef0f7c07c9e970839e5196c';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-08-17 09:41:59';
public const RELEASE_DATE = '2022-08-17 23:46:13';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitb27cbc64b21265378d188254f0a18d40
class ComposerAutoloaderInit6441c23c36c6aadc16202482012a5463
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInitb27cbc64b21265378d188254f0a18d40
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitb27cbc64b21265378d188254f0a18d40', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit6441c23c36c6aadc16202482012a5463', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitb27cbc64b21265378d188254f0a18d40', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit6441c23c36c6aadc16202482012a5463', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitb27cbc64b21265378d188254f0a18d40::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit6441c23c36c6aadc16202482012a5463::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInitb27cbc64b21265378d188254f0a18d40::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit6441c23c36c6aadc16202482012a5463::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequireb27cbc64b21265378d188254f0a18d40($fileIdentifier, $file);
composerRequire6441c23c36c6aadc16202482012a5463($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInitb27cbc64b21265378d188254f0a18d40
* @param string $file
* @return void
*/
function composerRequireb27cbc64b21265378d188254f0a18d40($fileIdentifier, $file)
function composerRequire6441c23c36c6aadc16202482012a5463($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 ComposerStaticInitb27cbc64b21265378d188254f0a18d40
class ComposerStaticInit6441c23c36c6aadc16202482012a5463
{
public static $files = array (
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
@ -3250,9 +3250,9 @@ class ComposerStaticInitb27cbc64b21265378d188254f0a18d40
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitb27cbc64b21265378d188254f0a18d40::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitb27cbc64b21265378d188254f0a18d40::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitb27cbc64b21265378d188254f0a18d40::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit6441c23c36c6aadc16202482012a5463::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit6441c23c36c6aadc16202482012a5463::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit6441c23c36c6aadc16202482012a5463::$classMap;
}, null, ClassLoader::class);
}