Updated Rector to commit d4be167d7e1bc3940db01d3a2096df7aa9cebe1c

d4be167d7e Fix trait rename in Php4ConsturctorRector (#4487)
This commit is contained in:
Tomas Votruba 2023-07-12 08:11:47 +00:00
parent 100d1e2fc8
commit 7312a4cf9b
5 changed files with 32 additions and 26 deletions

View File

@ -9,9 +9,9 @@ use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Expression;
use PhpParser\NodeTraverser;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\ClassReflection;
use Rector\Core\Enum\ObjectReference;
@ -19,6 +19,7 @@ use Rector\Core\Rector\AbstractScopeAwareRector;
use Rector\Core\ValueObject\MethodName;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\Php70\NodeAnalyzer\Php4ConstructorClassMethodAnalyzer;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
@ -73,42 +74,47 @@ CODE_SAMPLE
*/
public function getNodeTypes() : array
{
return [ClassMethod::class];
return [Class_::class];
}
/**
* @param ClassMethod $node
* @return \PhpParser\Node\Stmt\ClassMethod|int|null
* @param Class_ $node
* @return \PhpParser\Node\Stmt\Class_|int|null
*/
public function refactorWithScope(Node $node, Scope $scope)
{
$className = $this->getName($node);
if (!\is_string($className)) {
return null;
}
if (!$scope->isInClass()) {
return null;
}
if (!$this->php4ConstructorClassMethodAnalyzer->detect($node, $scope)) {
$psr4ConstructorMethod = $node->getMethod(\lcfirst($className)) ?? $node->getMethod($className);
if (!$psr4ConstructorMethod instanceof ClassMethod) {
return null;
}
if (!$this->php4ConstructorClassMethodAnalyzer->detect($psr4ConstructorMethod, $scope)) {
return null;
}
$classReflection = $scope->getClassReflection();
// process parent call references first
$this->processClassMethodStatementsForParentConstructorCalls($node, $scope);
// not PSR-4 constructor
if (!$this->nodeNameResolver->isName($node, $classReflection->getName())) {
return null;
}
$this->processClassMethodStatementsForParentConstructorCalls($psr4ConstructorMethod, $scope);
// does it already have a __construct method?
if (!$classReflection->hasConstructor()) {
$node->name = new Identifier(MethodName::CONSTRUCT);
$psr4ConstructorMethod->name = new Identifier(MethodName::CONSTRUCT);
}
$classMethodStmts = $node->stmts;
$classMethodStmts = $psr4ConstructorMethod->stmts;
if ($classMethodStmts === null) {
return null;
}
if (\count($classMethodStmts) === 1) {
$stmt = $node->stmts[0];
$stmt = $psr4ConstructorMethod->stmts[0];
if (!$stmt instanceof Expression) {
return null;
}
if ($this->isLocalMethodCallNamed($stmt->expr, MethodName::CONSTRUCT)) {
return NodeTraverser::REMOVE_NODE;
$stmtKey = $psr4ConstructorMethod->getAttribute(AttributeKey::STMT_KEY);
unset($node->stmts[$stmtKey]);
}
}
return $node;

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'd4a432e7e490695a11daa32bce6bf20ab0d075f6';
public const PACKAGE_VERSION = 'd4be167d7e1bc3940db01d3a2096df7aa9cebe1c';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-07-12 14:58:44';
public const RELEASE_DATE = '2023-07-12 09:07:35';
/**
* @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 ComposerAutoloaderInita9ae46779d789283ff67d8af60043c4f::getLoader();
return ComposerAutoloaderInitf67a3417e8cc86ad5220db43191c6152::getLoader();

View File

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