Updated Rector to commit 662986980adce40be299cc221b715fba883e86cd

662986980a Drop AttributeKey::SCOPE in Rector classes (#3792)
This commit is contained in:
Tomas Votruba 2023-05-11 08:30:47 +00:00
parent 8afa5f961e
commit c0d9ece267
15 changed files with 32 additions and 55 deletions

View File

@ -4,12 +4,14 @@ declare (strict_types=1);
namespace Rector\Strict\Rector;
use Rector\Core\Contract\Rector\AllowEmptyConfigurableRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\Rector\AbstractScopeAwareRector;
use RectorPrefix202305\Webmozart\Assert\Assert;
/**
* @see \Rector\Tests\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector\BooleanInBooleanNotRuleFixerRectorTest
*
* @internal
*/
abstract class AbstractFalsyScalarRuleFixerRector extends AbstractRector implements AllowEmptyConfigurableRectorInterface
abstract class AbstractFalsyScalarRuleFixerRector extends AbstractScopeAwareRector implements AllowEmptyConfigurableRectorInterface
{
/**
* @api

View File

@ -70,12 +70,8 @@ CODE_SAMPLE
/**
* @param BooleanNot $node
*/
public function refactor(Node $node) : ?Expr
public function refactorWithScope(Node $node, Scope $scope) : ?Expr
{
$scope = $node->getAttribute(AttributeKey::SCOPE);
if (!$scope instanceof Scope) {
return null;
}
$exprType = $scope->getType($node->expr);
return $this->exactCompareFactory->createIdenticalFalsyCompare($exprType, $node->expr, $this->treatAsNonEmpty);
}

View File

@ -12,6 +12,7 @@ use PHPStan\Analyser\Scope;
use Rector\Core\Enum\ObjectReference;
use Rector\Core\NodeManipulator\Dependency\DependencyClassMethodDecorator;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\Rector\AbstractScopeAwareRector;
use Rector\Core\ValueObject\MethodName;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
@ -22,7 +23,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
*
* @see \Rector\Tests\Strict\Rector\ClassMethod\AddConstructorParentCallRector\AddConstructorParentCallRectorTest
*/
final class AddConstructorParentCallRector extends AbstractRector
final class AddConstructorParentCallRector extends AbstractScopeAwareRector
{
/**
* @readonly
@ -68,17 +69,13 @@ CODE_SAMPLE
/**
* @param ClassMethod $node
*/
public function refactor(Node $node) : ?Node
public function refactorWithScope(Node $node, Scope $scope) : ?Node
{
$classLike = $this->betterNodeFinder->findParentType($node, ClassLike::class);
if (!$classLike instanceof Class_) {
return null;
}
if (!$this->isName($node, MethodName::CONSTRUCT)) {
return null;
}
$scope = $node->getAttribute(AttributeKey::SCOPE);
if (!$scope instanceof Scope) {
$classLike = $this->betterNodeFinder->findParentType($node, ClassLike::class);
if (!$classLike instanceof Class_) {
return null;
}
if ($this->hasParentCallOfMethod($node)) {

View File

@ -61,12 +61,8 @@ CODE_SAMPLE
/**
* @param Empty_|BooleanNot $node
*/
public function refactor(Node $node) : ?\PhpParser\Node\Expr
public function refactorWithScope(Node $node, Scope $scope) : ?\PhpParser\Node\Expr
{
$scope = $node->getAttribute(AttributeKey::SCOPE);
if (!$scope instanceof Scope) {
return null;
}
if ($node instanceof BooleanNot) {
return $this->refactorBooleanNot($node, $scope);
}

View File

@ -71,12 +71,8 @@ CODE_SAMPLE
/**
* @param If_ $node
*/
public function refactor(Node $node) : ?If_
public function refactorWithScope(Node $node, Scope $scope) : ?If_
{
$scope = $node->getAttribute(AttributeKey::SCOPE);
if (!$scope instanceof Scope) {
return null;
}
// 1. if
$ifCondExprType = $scope->getType($node->cond);
$notIdentical = $this->exactCompareFactory->createNotIdenticalFalsyCompare($ifCondExprType, $node->cond, $this->treatAsNonEmpty);

View File

@ -62,12 +62,8 @@ CODE_SAMPLE
/**
* @param Ternary $node
*/
public function refactor(Node $node) : ?Ternary
public function refactorWithScope(Node $node, Scope $scope) : ?Ternary
{
$scope = $node->getAttribute(AttributeKey::SCOPE);
if (!$scope instanceof Scope) {
return null;
}
// skip short ternary
if (!$node->if instanceof Expr) {
return null;

View File

@ -63,12 +63,8 @@ CODE_SAMPLE
/**
* @param Ternary $node
*/
public function refactor(Node $node) : ?Ternary
public function refactorWithScope(Node $node, Scope $scope) : ?Ternary
{
$scope = $node->getAttribute(AttributeKey::SCOPE);
if (!$scope instanceof Scope) {
return null;
}
// skip non-short ternary
if ($node->if instanceof Expr) {
return null;

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '074b1781b3fa7c7e23470c57ab85c0bd5fe0bfd2';
public const PACKAGE_VERSION = '662986980adce40be299cc221b715fba883e86cd';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-05-11 08:51:41';
public const RELEASE_DATE = '2023-05-11 09:26:43';
/**
* @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 ComposerAutoloaderInit998f735741fdf236a54d3791488b243e::getLoader();
return ComposerAutoloaderInit3369b1395c8f1be274199e367fd1a8da::getLoader();

View File

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

View File

@ -2063,12 +2063,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "f3495684f149e48ec3eaa3273513acf83f9dfdf6"
"reference": "f385be4708e6c9b2d77757ac41152b932dc3f528"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/f3495684f149e48ec3eaa3273513acf83f9dfdf6",
"reference": "f3495684f149e48ec3eaa3273513acf83f9dfdf6",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/f385be4708e6c9b2d77757ac41152b932dc3f528",
"reference": "f385be4708e6c9b2d77757ac41152b932dc3f528",
"shasum": ""
},
"require": {
@ -2098,7 +2098,7 @@
"tomasvotruba\/type-coverage": "^0.0.9",
"tomasvotruba\/unused-public": "^0.0.34"
},
"time": "2023-05-11T07:50:29+00:00",
"time": "2023-05-11T07:52:32+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 03df9e3'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 3209c44'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 63d391e'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main f349568'));
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 03df9e3'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 3209c44'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 63d391e'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main f385be4'));
private function __construct()
{
}

View File

@ -19,8 +19,6 @@ return static function (RectorConfig $rectorConfig) : void {
'*/Source*/*',
'*/tests/*/Fixture*/Expected/*',
StringClassNameToClassConstantRector::class => [__DIR__ . '/config'],
// soon to be removed
\Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector::class,
RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class => [
// "data" => "datum" false positive
__DIR__ . '/src/Rector/ClassMethod/AddRouteAnnotationRector.php',