Updated Rector to commit 86394aba2afe3fbc6baa92d392e14e5dd1caeda1

86394aba2a [TypeDeclaration] Handle inner Closure on ReturnTypeFromReturnNewRector (#1467)
This commit is contained in:
Tomas Votruba 2021-12-11 16:16:09 +00:00
parent 891d788ac2
commit 82cb57bbf9
10 changed files with 61 additions and 28 deletions

View File

@ -5,6 +5,7 @@ namespace Rector\TypeDeclaration\Rector\ClassMethod;
use PhpParser\Node;
use PhpParser\Node\Expr\ArrowFunction;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt\ClassMethod;
@ -73,7 +74,7 @@ CODE_SAMPLE
*/
public function getNodeTypes() : array
{
return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\ArrowFunction::class];
return [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\Closure::class, \PhpParser\Node\Expr\ArrowFunction::class];
}
/**
* @param ClassMethod|Function_|ArrowFunction $node
@ -87,7 +88,7 @@ CODE_SAMPLE
$returns = [new \PhpParser\Node\Stmt\Return_($node->expr)];
} else {
/** @var Return_[] $returns */
$returns = $this->betterNodeFinder->findInstanceOf((array) $node->stmts, \PhpParser\Node\Stmt\Return_::class);
$returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($node, \PhpParser\Node\Stmt\Return_::class);
}
if ($returns === []) {
return null;

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = 'f36390d8df22c38f996c0da40aee8565fa33c4c3';
public const PACKAGE_VERSION = '86394aba2afe3fbc6baa92d392e14e5dd1caeda1';
/**
* @var string
*/
public const RELEASE_DATE = '2021-12-11 14:19:17';
public const RELEASE_DATE = '2021-12-11 17:02:52';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20211211\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

View File

@ -392,6 +392,38 @@ final class BetterNodeFinder
}
return \false;
}
/**
* @template T of Node
* @param array<class-string<T>>|class-string<T> $types
* @return T[]
* @param \PhpParser\Node\Expr\Closure|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike
*/
public function findInstancesOfInFunctionLikeScoped($functionLike, $types) : array
{
if (\is_string($types)) {
$types = [$types];
}
/** @var T[] $foundNodes */
$foundNodes = [];
foreach ($types as $type) {
/** @var T[] $nodes */
$nodes = $this->findInstanceOf((array) $functionLike->stmts, $type);
if ($nodes === []) {
continue;
}
foreach ($nodes as $key => $node) {
$parentFunctionLike = $this->findParentByTypes($node, [\PhpParser\Node\Stmt\ClassMethod::class, \PhpParser\Node\Stmt\Function_::class, \PhpParser\Node\Expr\Closure::class]);
if ($parentFunctionLike !== $functionLike) {
unset($nodes[$key]);
}
}
if ($nodes === []) {
continue;
}
$foundNodes = \array_merge($foundNodes, $nodes);
}
return $foundNodes;
}
/**
* @param \PhpParser\Node\Expr\Closure|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike
*/

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitdb076196ed40e547c59c17dc6e98f813::getLoader();
return ComposerAutoloaderInit4f8f0c3c3d520f589b05013b5035eb6e::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitdb076196ed40e547c59c17dc6e98f813
class ComposerAutoloaderInit4f8f0c3c3d520f589b05013b5035eb6e
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInitdb076196ed40e547c59c17dc6e98f813
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitdb076196ed40e547c59c17dc6e98f813', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit4f8f0c3c3d520f589b05013b5035eb6e', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInitdb076196ed40e547c59c17dc6e98f813', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit4f8f0c3c3d520f589b05013b5035eb6e', '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\ComposerStaticInitdb076196ed40e547c59c17dc6e98f813::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit4f8f0c3c3d520f589b05013b5035eb6e::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInitdb076196ed40e547c59c17dc6e98f813
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInitdb076196ed40e547c59c17dc6e98f813::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit4f8f0c3c3d520f589b05013b5035eb6e::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequiredb076196ed40e547c59c17dc6e98f813($fileIdentifier, $file);
composerRequire4f8f0c3c3d520f589b05013b5035eb6e($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequiredb076196ed40e547c59c17dc6e98f813($fileIdentifier, $file)
function composerRequire4f8f0c3c3d520f589b05013b5035eb6e($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInitdb076196ed40e547c59c17dc6e98f813
class ComposerStaticInit4f8f0c3c3d520f589b05013b5035eb6e
{
public static $files = array (
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
@ -3821,9 +3821,9 @@ class ComposerStaticInitdb076196ed40e547c59c17dc6e98f813
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitdb076196ed40e547c59c17dc6e98f813::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitdb076196ed40e547c59c17dc6e98f813::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitdb076196ed40e547c59c17dc6e98f813::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit4f8f0c3c3d520f589b05013b5035eb6e::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit4f8f0c3c3d520f589b05013b5035eb6e::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit4f8f0c3c3d520f589b05013b5035eb6e::$classMap;
}, null, ClassLoader::class);
}

View File

@ -2240,12 +2240,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-generator.git",
"reference": "6b8d24c5429f28d5ceecf82760d608db18ec1eab"
"reference": "b74964fa665c4438191895626562a369e629845c"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-generator\/zipball\/6b8d24c5429f28d5ceecf82760d608db18ec1eab",
"reference": "6b8d24c5429f28d5ceecf82760d608db18ec1eab",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-generator\/zipball\/b74964fa665c4438191895626562a369e629845c",
"reference": "b74964fa665c4438191895626562a369e629845c",
"shasum": ""
},
"require": {
@ -2275,7 +2275,7 @@
"symplify\/phpstan-rules": "^10.0",
"symplify\/vendor-patches": "^10.0"
},
"time": "2021-12-11T13:56:29+00:00",
"time": "2021-12-11T15:11:02+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
@ -2300,7 +2300,7 @@
"homepage": "https:\/\/getrector.org",
"support": {
"issues": "https:\/\/github.com\/rectorphp\/rector-generator\/issues",
"source": "https:\/\/github.com\/rectorphp\/rector-generator\/tree\/main"
"source": "https:\/\/github.com\/rectorphp\/rector-generator\/tree\/0.5.0"
},
"funding": [
{

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-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 584d84b'), '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 567cdd2'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 6b8d24c'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 4fb1137'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 1e3b3ab'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 47298f7'), '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 ed23e61'), '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 0a50dc4'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 7109b9b'));
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 584d84b'), '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 567cdd2'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main b74964f'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 4fb1137'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 1e3b3ab'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 47298f7'), '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 ed23e61'), '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 0a50dc4'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 7109b9b'));
private function __construct()
{
}

View File

@ -12,8 +12,8 @@ if (!class_exists('GenerateChangelogCommand', false) && !interface_exists('Gener
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20211211\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInitdb076196ed40e547c59c17dc6e98f813', false) && !interface_exists('ComposerAutoloaderInitdb076196ed40e547c59c17dc6e98f813', false) && !trait_exists('ComposerAutoloaderInitdb076196ed40e547c59c17dc6e98f813', false)) {
spl_autoload_call('RectorPrefix20211211\ComposerAutoloaderInitdb076196ed40e547c59c17dc6e98f813');
if (!class_exists('ComposerAutoloaderInit4f8f0c3c3d520f589b05013b5035eb6e', false) && !interface_exists('ComposerAutoloaderInit4f8f0c3c3d520f589b05013b5035eb6e', false) && !trait_exists('ComposerAutoloaderInit4f8f0c3c3d520f589b05013b5035eb6e', false)) {
spl_autoload_call('RectorPrefix20211211\ComposerAutoloaderInit4f8f0c3c3d520f589b05013b5035eb6e');
}
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('RectorPrefix20211211\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -81,9 +81,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20211211\print_node(...func_get_args());
}
}
if (!function_exists('composerRequiredb076196ed40e547c59c17dc6e98f813')) {
function composerRequiredb076196ed40e547c59c17dc6e98f813() {
return \RectorPrefix20211211\composerRequiredb076196ed40e547c59c17dc6e98f813(...func_get_args());
if (!function_exists('composerRequire4f8f0c3c3d520f589b05013b5035eb6e')) {
function composerRequire4f8f0c3c3d520f589b05013b5035eb6e() {
return \RectorPrefix20211211\composerRequire4f8f0c3c3d520f589b05013b5035eb6e(...func_get_args());
}
}
if (!function_exists('scanPath')) {