mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-29 11:33:33 +01:00
Updated Rector to commit dd842d6e60f558697d2067ff837995b23bfa9073
dd842d6e60
[TypeDeclaration] Fix parent method param override (#1945)
This commit is contained in:
parent
0c232fa881
commit
d8c1c96c86
@ -4,11 +4,13 @@ declare (strict_types=1);
|
||||
namespace Rector\TypeDeclaration\Rector\Param;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\ComplexType;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\FunctionLike;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\NullableType;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Reflection\Php\PhpPropertyReflection;
|
||||
use PHPStan\Type\MixedType;
|
||||
@ -19,6 +21,7 @@ use Rector\Core\Reflection\ReflectionResolver;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\VendorLocker\ParentClassMethodTypeOverrideGuard;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
@ -32,9 +35,15 @@ final class ParamTypeFromStrictTypedPropertyRector extends \Rector\Core\Rector\A
|
||||
* @var \Rector\Core\Reflection\ReflectionResolver
|
||||
*/
|
||||
private $reflectionResolver;
|
||||
public function __construct(\Rector\Core\Reflection\ReflectionResolver $reflectionResolver)
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\VendorLocker\ParentClassMethodTypeOverrideGuard
|
||||
*/
|
||||
private $parentClassMethodTypeOverrideGuard;
|
||||
public function __construct(\Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\VendorLocker\ParentClassMethodTypeOverrideGuard $parentClassMethodTypeOverrideGuard)
|
||||
{
|
||||
$this->reflectionResolver = $reflectionResolver;
|
||||
$this->parentClassMethodTypeOverrideGuard = $parentClassMethodTypeOverrideGuard;
|
||||
}
|
||||
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
|
||||
{
|
||||
@ -75,20 +84,23 @@ CODE_SAMPLE
|
||||
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
|
||||
{
|
||||
$parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
|
||||
if (!$parent instanceof \PhpParser\Node\FunctionLike) {
|
||||
if (!$parent instanceof \PhpParser\Node\Stmt\ClassMethod) {
|
||||
return null;
|
||||
}
|
||||
return $this->decorateParamWithType($parent, $node);
|
||||
}
|
||||
public function decorateParamWithType(\PhpParser\Node\FunctionLike $functionLike, \PhpParser\Node\Param $param) : ?\PhpParser\Node\Param
|
||||
public function decorateParamWithType(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node\Param $param) : ?\PhpParser\Node\Param
|
||||
{
|
||||
if ($param->type !== null) {
|
||||
return null;
|
||||
}
|
||||
if ($this->parentClassMethodTypeOverrideGuard->hasParentClassMethod($classMethod)) {
|
||||
return null;
|
||||
}
|
||||
$originalParamType = $this->resolveParamOriginalType($param);
|
||||
$paramName = $this->getName($param);
|
||||
/** @var Assign[] $assigns */
|
||||
$assigns = $this->betterNodeFinder->findInstanceOf((array) $functionLike->getStmts(), \PhpParser\Node\Expr\Assign::class);
|
||||
$assigns = $this->betterNodeFinder->findInstanceOf((array) $classMethod->getStmts(), \PhpParser\Node\Expr\Assign::class);
|
||||
foreach ($assigns as $assign) {
|
||||
if (!$this->nodeComparator->areNodesEqual($assign->expr, $param->var)) {
|
||||
continue;
|
||||
@ -113,7 +125,7 @@ CODE_SAMPLE
|
||||
return \Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES;
|
||||
}
|
||||
/**
|
||||
* @return Node\Name|Node\ComplexType|null
|
||||
* @return Name|ComplexType|null
|
||||
*/
|
||||
private function matchPropertySingleTypeNode(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : ?\PhpParser\Node
|
||||
{
|
||||
|
@ -16,11 +16,11 @@ final class VersionResolver
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'feae0cfa0ca0d3a867073aea0003c2287abf56e9';
|
||||
public const PACKAGE_VERSION = 'dd842d6e60f558697d2067ff837995b23bfa9073';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-03-17 08:28:36';
|
||||
public const RELEASE_DATE = '2022-03-17 09:54:51';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20220317\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -4,4 +4,4 @@
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitb808bd19b0b0f107263b33161ec38d13::getLoader();
|
||||
return ComposerAutoloaderInitccf929da2ae7d4e09965d4557539b6ba::getLoader();
|
||||
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitb808bd19b0b0f107263b33161ec38d13
|
||||
class ComposerAutoloaderInitccf929da2ae7d4e09965d4557539b6ba
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,15 +22,15 @@ class ComposerAutoloaderInitb808bd19b0b0f107263b33161ec38d13
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitb808bd19b0b0f107263b33161ec38d13', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitccf929da2ae7d4e09965d4557539b6ba', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitb808bd19b0b0f107263b33161ec38d13', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitccf929da2ae7d4e09965d4557539b6ba', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitb808bd19b0b0f107263b33161ec38d13::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitccf929da2ae7d4e09965d4557539b6ba::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
@ -42,12 +42,12 @@ class ComposerAutoloaderInitb808bd19b0b0f107263b33161ec38d13
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInitb808bd19b0b0f107263b33161ec38d13::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInitccf929da2ae7d4e09965d4557539b6ba::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequireb808bd19b0b0f107263b33161ec38d13($fileIdentifier, $file);
|
||||
composerRequireccf929da2ae7d4e09965d4557539b6ba($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
@ -59,7 +59,7 @@ class ComposerAutoloaderInitb808bd19b0b0f107263b33161ec38d13
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequireb808bd19b0b0f107263b33161ec38d13($fileIdentifier, $file)
|
||||
function composerRequireccf929da2ae7d4e09965d4557539b6ba($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 ComposerStaticInitb808bd19b0b0f107263b33161ec38d13
|
||||
class ComposerStaticInitccf929da2ae7d4e09965d4557539b6ba
|
||||
{
|
||||
public static $files = array (
|
||||
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
||||
@ -3845,9 +3845,9 @@ class ComposerStaticInitb808bd19b0b0f107263b33161ec38d13
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitb808bd19b0b0f107263b33161ec38d13::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitb808bd19b0b0f107263b33161ec38d13::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitb808bd19b0b0f107263b33161ec38d13::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitccf929da2ae7d4e09965d4557539b6ba::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitccf929da2ae7d4e09965d4557539b6ba::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitccf929da2ae7d4e09965d4557539b6ba::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
|
||||
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
|
||||
spl_autoload_call('RectorPrefix20220317\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInitb808bd19b0b0f107263b33161ec38d13', false) && !interface_exists('ComposerAutoloaderInitb808bd19b0b0f107263b33161ec38d13', false) && !trait_exists('ComposerAutoloaderInitb808bd19b0b0f107263b33161ec38d13', false)) {
|
||||
spl_autoload_call('RectorPrefix20220317\ComposerAutoloaderInitb808bd19b0b0f107263b33161ec38d13');
|
||||
if (!class_exists('ComposerAutoloaderInitccf929da2ae7d4e09965d4557539b6ba', false) && !interface_exists('ComposerAutoloaderInitccf929da2ae7d4e09965d4557539b6ba', false) && !trait_exists('ComposerAutoloaderInitccf929da2ae7d4e09965d4557539b6ba', false)) {
|
||||
spl_autoload_call('RectorPrefix20220317\ComposerAutoloaderInitccf929da2ae7d4e09965d4557539b6ba');
|
||||
}
|
||||
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
|
||||
spl_autoload_call('RectorPrefix20220317\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
@ -59,9 +59,9 @@ if (!function_exists('print_node')) {
|
||||
return \RectorPrefix20220317\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequireb808bd19b0b0f107263b33161ec38d13')) {
|
||||
function composerRequireb808bd19b0b0f107263b33161ec38d13() {
|
||||
return \RectorPrefix20220317\composerRequireb808bd19b0b0f107263b33161ec38d13(...func_get_args());
|
||||
if (!function_exists('composerRequireccf929da2ae7d4e09965d4557539b6ba')) {
|
||||
function composerRequireccf929da2ae7d4e09965d4557539b6ba() {
|
||||
return \RectorPrefix20220317\composerRequireccf929da2ae7d4e09965d4557539b6ba(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user