mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit 0e4a46d75ac336dfdfc268bf8c2019121593a7b2
0e4a46d75a
Drop AttributeKey::SCOPE in CountableAnalyzer (#3804)
This commit is contained in:
parent
55e711a3e6
commit
2b9f121320
|
@ -66,7 +66,7 @@ final class CountableAnalyzer
|
|||
$this->propertyFetchAnalyzer = $propertyFetchAnalyzer;
|
||||
$this->constructorAssignDetector = $constructorAssignDetector;
|
||||
}
|
||||
public function isCastableArrayType(Expr $expr, ArrayType $arrayType) : bool
|
||||
public function isCastableArrayType(Expr $expr, ArrayType $arrayType, Scope $scope) : bool
|
||||
{
|
||||
if (!$this->propertyFetchAnalyzer->isPropertyFetch($expr)) {
|
||||
return \false;
|
||||
|
@ -96,7 +96,7 @@ final class CountableAnalyzer
|
|||
if (!\array_key_exists($propertyName, $propertiesDefaults)) {
|
||||
return \false;
|
||||
}
|
||||
$phpPropertyReflection = $this->resolveProperty($expr, $classReflection, $propertyName);
|
||||
$phpPropertyReflection = $classReflection->getProperty($propertyName, $scope);
|
||||
if (!$phpPropertyReflection instanceof PhpPropertyReflection) {
|
||||
return \false;
|
||||
}
|
||||
|
@ -132,15 +132,4 @@ final class CountableAnalyzer
|
|||
$propertyName = (string) $this->nodeNameResolver->getName($propertyFetch->name);
|
||||
return $this->constructorAssignDetector->isPropertyAssigned($classLike, $propertyName);
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Expr\StaticPropertyFetch|\PhpParser\Node\Expr\PropertyFetch $propertyFetch
|
||||
*/
|
||||
private function resolveProperty($propertyFetch, ClassReflection $classReflection, string $propertyName) : ?PropertyReflection
|
||||
{
|
||||
$scope = $propertyFetch->getAttribute(AttributeKey::SCOPE);
|
||||
if (!$scope instanceof Scope) {
|
||||
return null;
|
||||
}
|
||||
return $classReflection->getProperty($propertyName, $scope);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ 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\NullType;
|
||||
use PHPStan\Type\Type;
|
||||
|
@ -25,6 +26,7 @@ use PHPStan\Type\UnionType;
|
|||
use Rector\Core\NodeAnalyzer\VariableAnalyzer;
|
||||
use Rector\Core\Php\PhpVersionProvider;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Rector\AbstractScopeAwareRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\NodeTypeResolver\TypeAnalyzer\CountableTypeAnalyzer;
|
||||
|
@ -37,7 +39,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
|||
*
|
||||
* @see \Rector\Tests\Php71\Rector\FuncCall\CountOnNullRector\CountOnNullRectorTest
|
||||
*/
|
||||
final class CountOnNullRector extends AbstractRector implements MinPhpVersionInterface
|
||||
final class CountOnNullRector extends AbstractScopeAwareRector implements MinPhpVersionInterface
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
|
@ -92,7 +94,7 @@ CODE_SAMPLE
|
|||
/**
|
||||
* @param FuncCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
public function refactorWithScope(Node $node, Scope $scope) : ?Node
|
||||
{
|
||||
if ($this->shouldSkip($node)) {
|
||||
return null;
|
||||
|
@ -106,7 +108,7 @@ CODE_SAMPLE
|
|||
// this can lead to false positive by phpstan, but that's best we can do
|
||||
$onlyValueType = $this->getType($countedNode);
|
||||
if ($onlyValueType instanceof ArrayType) {
|
||||
if (!$this->countableAnalyzer->isCastableArrayType($countedNode, $onlyValueType)) {
|
||||
if (!$this->countableAnalyzer->isCastableArrayType($countedNode, $onlyValueType, $scope)) {
|
||||
return null;
|
||||
}
|
||||
return $this->castToArray($countedNode, $node);
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'f4ecf4a033e45042e659440e81281895cb343555';
|
||||
public const PACKAGE_VERSION = '0e4a46d75ac336dfdfc268bf8c2019121593a7b2';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-05-11 19:07:28';
|
||||
public const RELEASE_DATE = '2023-05-11 19:22:49';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
|
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit1489bfa8e42ee0e5f31439d663356be7::getLoader();
|
||||
return ComposerAutoloaderInit1541611493e8c1217ebb7b54ee102dba::getLoader();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit1489bfa8e42ee0e5f31439d663356be7
|
||||
class ComposerAutoloaderInit1541611493e8c1217ebb7b54ee102dba
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,17 +22,17 @@ class ComposerAutoloaderInit1489bfa8e42ee0e5f31439d663356be7
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit1489bfa8e42ee0e5f31439d663356be7', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit1541611493e8c1217ebb7b54ee102dba', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit1489bfa8e42ee0e5f31439d663356be7', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit1541611493e8c1217ebb7b54ee102dba', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit1489bfa8e42ee0e5f31439d663356be7::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit1541611493e8c1217ebb7b54ee102dba::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit1489bfa8e42ee0e5f31439d663356be7::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit1541611493e8c1217ebb7b54ee102dba::$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 ComposerStaticInit1489bfa8e42ee0e5f31439d663356be7
|
||||
class ComposerStaticInit1541611493e8c1217ebb7b54ee102dba
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -3109,9 +3109,9 @@ class ComposerStaticInit1489bfa8e42ee0e5f31439d663356be7
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit1489bfa8e42ee0e5f31439d663356be7::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit1489bfa8e42ee0e5f31439d663356be7::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit1489bfa8e42ee0e5f31439d663356be7::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit1541611493e8c1217ebb7b54ee102dba::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit1541611493e8c1217ebb7b54ee102dba::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit1541611493e8c1217ebb7b54ee102dba::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue