mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-19 06:18:07 +01:00
Updated Rector to commit 7e9ee7afbf04ede850da1639b1b234e4e86730fb
7e9ee7afbf
Refactor from PARENT_NODE in AddReturnTypeDeclarationRector (#3952)
This commit is contained in:
parent
a1e2ba76d0
commit
7dcc1f5c95
@ -14,7 +14,6 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||
use Rector\Core\Php\PhpVersionProvider;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
|
||||
use Rector\VendorLocker\ParentClassMethodTypeOverrideGuard;
|
||||
@ -75,28 +74,30 @@ CODE_SAMPLE
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [ClassMethod::class];
|
||||
return [Class_::class];
|
||||
}
|
||||
/**
|
||||
* @param ClassMethod $node
|
||||
* @param Class_ $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
$this->hasChanged = \false;
|
||||
foreach ($this->methodReturnTypes as $methodReturnType) {
|
||||
if (!$this->isName($node, $methodReturnType->getMethod())) {
|
||||
continue;
|
||||
}
|
||||
$objectType = $methodReturnType->getObjectType();
|
||||
if (!$this->isObjectType($node, $objectType)) {
|
||||
continue;
|
||||
}
|
||||
$this->processClassMethodNodeWithTypehints($node, $methodReturnType->getReturnType(), $objectType);
|
||||
if (!$this->hasChanged) {
|
||||
return null;
|
||||
foreach ($node->getMethods() as $classMethod) {
|
||||
if (!$this->isName($classMethod, $methodReturnType->getMethod())) {
|
||||
continue;
|
||||
}
|
||||
$this->processClassMethodNodeWithTypehints($classMethod, $node, $methodReturnType->getReturnType(), $objectType);
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
return null;
|
||||
if (!$this->hasChanged) {
|
||||
return null;
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param mixed[] $configuration
|
||||
@ -106,14 +107,10 @@ CODE_SAMPLE
|
||||
Assert::allIsAOf($configuration, AddReturnTypeDeclaration::class);
|
||||
$this->methodReturnTypes = $configuration;
|
||||
}
|
||||
private function processClassMethodNodeWithTypehints(ClassMethod $classMethod, Type $newType, ObjectType $objectType) : void
|
||||
private function processClassMethodNodeWithTypehints(ClassMethod $classMethod, Class_ $class, Type $newType, ObjectType $objectType) : void
|
||||
{
|
||||
if ($newType instanceof MixedType) {
|
||||
$parentNode = $classMethod->getAttribute(AttributeKey::PARENT_NODE);
|
||||
if (!$parentNode instanceof Class_) {
|
||||
return;
|
||||
}
|
||||
$className = (string) $this->nodeNameResolver->getName($parentNode);
|
||||
$className = (string) $this->nodeNameResolver->getName($class);
|
||||
$currentObjectType = new ObjectType($className);
|
||||
if (!$objectType->equals($currentObjectType) && $classMethod->returnType !== null) {
|
||||
return;
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '2e80e00913eacfcfded3af426cc7691a58d7f886';
|
||||
public const PACKAGE_VERSION = '7e9ee7afbf04ede850da1639b1b234e4e86730fb';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-05-24 14:15:17';
|
||||
public const RELEASE_DATE = '2023-05-24 14:37:47';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitab5765415f46a737a2fd8351125e4dcd::getLoader();
|
||||
return ComposerAutoloaderInit03705db7587c5d5e30870552140b01a2::getLoader();
|
||||
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitab5765415f46a737a2fd8351125e4dcd
|
||||
class ComposerAutoloaderInit03705db7587c5d5e30870552140b01a2
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInitab5765415f46a737a2fd8351125e4dcd
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitab5765415f46a737a2fd8351125e4dcd', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit03705db7587c5d5e30870552140b01a2', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitab5765415f46a737a2fd8351125e4dcd', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit03705db7587c5d5e30870552140b01a2', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitab5765415f46a737a2fd8351125e4dcd::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit03705db7587c5d5e30870552140b01a2::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitab5765415f46a737a2fd8351125e4dcd::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit03705db7587c5d5e30870552140b01a2::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitab5765415f46a737a2fd8351125e4dcd
|
||||
class ComposerStaticInit03705db7587c5d5e30870552140b01a2
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -3105,9 +3105,9 @@ class ComposerStaticInitab5765415f46a737a2fd8351125e4dcd
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitab5765415f46a737a2fd8351125e4dcd::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitab5765415f46a737a2fd8351125e4dcd::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitab5765415f46a737a2fd8351125e4dcd::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit03705db7587c5d5e30870552140b01a2::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit03705db7587c5d5e30870552140b01a2::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit03705db7587c5d5e30870552140b01a2::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user