Updated Rector to commit dc52f2b5bfc3b31c474555ba0155b50ea6211d18

dc52f2b5bf [TypeDeclaration] Handle return from array_map() on ReturnTypeFromStrictTypedCallRector (#3471)
This commit is contained in:
Tomas Votruba 2023-03-10 15:21:11 +00:00
parent e27f3e5b0b
commit b4b2b8f25e
7 changed files with 32 additions and 31 deletions

View File

@ -70,8 +70,8 @@ CODE_SAMPLE
*/
public function refactor(Node $node) : ?Node
{
$class = $this->betterNodeFinder->findParentType($node, ClassLike::class);
if (!$class instanceof Class_) {
$classLike = $this->betterNodeFinder->findParentType($node, ClassLike::class);
if (!$classLike instanceof Class_) {
return null;
}
if (!$this->isName($node, MethodName::CONSTRUCT)) {
@ -84,7 +84,7 @@ CODE_SAMPLE
if ($this->hasParentCallOfMethod($node)) {
return null;
}
$this->dependencyClassMethodDecorator->decorateConstructorWithParentDependencies($class, $node, $scope);
$this->dependencyClassMethodDecorator->decorateConstructorWithParentDependencies($classLike, $node, $scope);
return $node;
}
/**

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\TypeDeclaration\Rector\ClassMethod;
use PhpParser\Node;
use PhpParser\Node\ComplexType;
use PhpParser\Node\Expr\ArrowFunction;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\FunctionLike;
@ -127,8 +128,8 @@ CODE_SAMPLE
if (!$currentReturn instanceof Return_) {
return \false;
}
$currentFunctionLike = $this->betterNodeFinder->findParentType($currentReturn, FunctionLike::class);
if ($currentFunctionLike !== $node) {
$currentReturnFunctionLike = $this->betterNodeFinder->findParentType($currentReturn, FunctionLike::class);
if ($currentReturnFunctionLike !== $currentFunctionLike) {
return \false;
}
return $subNode instanceof Return_;
@ -214,7 +215,7 @@ CODE_SAMPLE
return \true;
}
/**
* @param \PhpParser\Node\Identifier|\PhpParser\Node\Name|\PhpParser\Node\NullableType $returnedStrictTypeNode
* @param \PhpParser\Node\Identifier|\PhpParser\Node\Name|\PhpParser\Node\NullableType|\PhpParser\Node\ComplexType $returnedStrictTypeNode
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $functionLike
* @return \PhpParser\Node\Expr\Closure|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_
*/

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'f87827ca264302c24015bc9d2a27a4a288a05682';
public const PACKAGE_VERSION = 'dc52f2b5bfc3b31c474555ba0155b50ea6211d18';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-03-10 05:42:59';
public const RELEASE_DATE = '2023-03-10 16:14:46';
/**
* @var int
*/

View File

@ -101,9 +101,9 @@ final class DependencyClassMethodDecorator
$cleanParamsToAdd = $this->removeAlreadyPresentParams($cleanParams, $classMethod->params);
// replicate parent parameters
if ($cleanParamsToAdd !== []) {
foreach ($cleanParamsToAdd as $toAdd) {
$paramName = $this->nodeNameResolver->getName($toAdd);
$this->incrementParamIfExists($toAdd, $paramName, $cleanParamsToAdd, $classMethod->params);
foreach ($cleanParamsToAdd as $cleanParamToAdd) {
$paramName = $this->nodeNameResolver->getName($cleanParamToAdd);
$this->incrementParamIfExists($cleanParamToAdd, $paramName, $cleanParamsToAdd, $classMethod->params);
}
$classMethod->params = \array_merge($cleanParamsToAdd, $classMethod->params);
}
@ -154,32 +154,32 @@ final class DependencyClassMethodDecorator
* @param Param[] $newParams
* @param Param[] $originalParams
*/
private function incrementParamIfExists(Param $paramToAdd, string $newName, array $newParams, array $originalParams, int $count = 0) : void
private function incrementParamIfExists(Param $param, string $newName, array $newParams, array $originalParams, int $count = 0) : void
{
$name = $newName;
if ($count > 0) {
$name .= $count;
}
foreach ($newParams as $param) {
if ($paramToAdd === $param) {
foreach ($newParams as $newParam) {
if ($param === $newParam) {
continue;
}
if ($this->nodeNameResolver->isName($param, $name)) {
if ($this->nodeNameResolver->isName($newParam, $name)) {
++$count;
$this->incrementParamIfExists($paramToAdd, $newName, $newParams, $originalParams, $count);
$this->incrementParamIfExists($param, $newName, $newParams, $originalParams, $count);
return;
}
}
foreach ($originalParams as $param) {
if ($this->nodeNameResolver->isName($param, $name)) {
foreach ($originalParams as $originalParam) {
if ($this->nodeNameResolver->isName($originalParam, $name)) {
++$count;
$this->incrementParamIfExists($paramToAdd, $newName, $newParams, $originalParams, $count);
$this->incrementParamIfExists($param, $newName, $newParams, $originalParams, $count);
return;
}
}
if ($name !== $newName) {
$paramToAdd->var = clone $paramToAdd->var;
$paramToAdd->var->name = $name;
$param->var = clone $param->var;
$param->var->name = $name;
}
}
private function areMaybeTypesEqual(?Type $type1, ?Type $type2) : bool

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit3566f28bef0f2b69c6833c4925822be9::getLoader();
return ComposerAutoloaderInitd79753c8aaec47c41f454a573a097c38::getLoader();

View File

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