Updated Rector to commit f35326d7010fa42458b44d3896b4791dcc22f78a

f35326d701 [TypeDeclaration] Remove PhpDocTypeChanger->changeVarType() on TypedPropertyFromAssignsRector (#3163)
This commit is contained in:
Tomas Votruba 2022-12-06 18:18:33 +00:00
parent bd0997346d
commit 3748da8b80
9 changed files with 68 additions and 115 deletions

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit63a3d5779d4242043c03ebfbc1e9811d
class ComposerAutoloaderInitb2cdc69f66b2f10abd9807968fecf076
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit63a3d5779d4242043c03ebfbc1e9811d
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit63a3d5779d4242043c03ebfbc1e9811d', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitb2cdc69f66b2f10abd9807968fecf076', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit63a3d5779d4242043c03ebfbc1e9811d', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitb2cdc69f66b2f10abd9807968fecf076', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit63a3d5779d4242043c03ebfbc1e9811d::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitb2cdc69f66b2f10abd9807968fecf076::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit63a3d5779d4242043c03ebfbc1e9811d::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInitb2cdc69f66b2f10abd9807968fecf076::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire63a3d5779d4242043c03ebfbc1e9811d($fileIdentifier, $file);
composerRequireb2cdc69f66b2f10abd9807968fecf076($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit63a3d5779d4242043c03ebfbc1e9811d
* @param string $file
* @return void
*/
function composerRequire63a3d5779d4242043c03ebfbc1e9811d($fileIdentifier, $file)
function composerRequireb2cdc69f66b2f10abd9807968fecf076($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 ComposerStaticInit63a3d5779d4242043c03ebfbc1e9811d
class ComposerStaticInitb2cdc69f66b2f10abd9807968fecf076
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3020,9 +3020,9 @@ class ComposerStaticInit63a3d5779d4242043c03ebfbc1e9811d
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit63a3d5779d4242043c03ebfbc1e9811d::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit63a3d5779d4242043c03ebfbc1e9811d::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit63a3d5779d4242043c03ebfbc1e9811d::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitb2cdc69f66b2f10abd9807968fecf076::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitb2cdc69f66b2f10abd9807968fecf076::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitb2cdc69f66b2f10abd9807968fecf076::$classMap;
}, null, ClassLoader::class);
}

View File

@ -2058,12 +2058,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "ca2fcbf938e83ce3ace482de6c3043782cbdedf1"
"reference": "ed4578530ae47d4227e6abdc824ecac434dfc633"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/ca2fcbf938e83ce3ace482de6c3043782cbdedf1",
"reference": "ca2fcbf938e83ce3ace482de6c3043782cbdedf1",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/ed4578530ae47d4227e6abdc824ecac434dfc633",
"reference": "ed4578530ae47d4227e6abdc824ecac434dfc633",
"shasum": ""
},
"require": {
@ -2093,7 +2093,7 @@
"symplify\/rule-doc-generator": "^11.1",
"symplify\/vendor-patches": "^11.1"
},
"time": "2022-12-05T14:58:24+00:00",
"time": "2022-12-06T18:09:04+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
@ -2275,17 +2275,17 @@
},
{
"name": "symfony\/console",
"version": "v6.2.0",
"version_normalized": "6.2.0.0",
"version": "v6.2.1",
"version_normalized": "6.2.1.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/symfony\/console.git",
"reference": "75d4749d9620a8fa21a2d2847800a84b5c4e7682"
"reference": "58f6cef5dc5f641b7bbdbf8b32b44cc926c35f3f"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symfony\/console\/zipball\/75d4749d9620a8fa21a2d2847800a84b5c4e7682",
"reference": "75d4749d9620a8fa21a2d2847800a84b5c4e7682",
"url": "https:\/\/api.github.com\/repos\/symfony\/console\/zipball\/58f6cef5dc5f641b7bbdbf8b32b44cc926c35f3f",
"reference": "58f6cef5dc5f641b7bbdbf8b32b44cc926c35f3f",
"shasum": ""
},
"require": {
@ -2320,7 +2320,7 @@
"symfony\/lock": "",
"symfony\/process": ""
},
"time": "2022-11-29T16:44:51+00:00",
"time": "2022-12-01T13:44:20+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -2354,7 +2354,7 @@
"terminal"
],
"support": {
"source": "https:\/\/github.com\/symfony\/console\/tree\/v6.2.0"
"source": "https:\/\/github.com\/symfony\/console\/tree\/v6.2.1"
},
"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-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 bf394ee'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main b1ca6d7'), 'rector/rector-php-parser' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-php-parser', 'relative_install_path' => '../../rector-php-parser', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 9ea5f62'), '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 3d0d84d'), '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 ca2fcbf'));
public const EXTENSIONS = array('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 bf394ee'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main b1ca6d7'), 'rector/rector-php-parser' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-php-parser', 'relative_install_path' => '../../rector-php-parser', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 9ea5f62'), '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 3d0d84d'), '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 ed45785'));
private function __construct()
{
}

View File

@ -13,4 +13,12 @@ final class SymfonyAnnotation
* @var string
*/
public const SENSIO_METHOD = 'Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Method';
/**
* @var string
*/
public const SENSIO_TEMPLATE = 'Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Template';
/**
* @var string
*/
public const TWIG_TEMPLATE = 'Symfony\\Bridge\\Twig\\Attribute\\Template';
}

View File

@ -6,7 +6,9 @@ namespace Rector\Symfony\Rector\ClassMethod;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\NullableType;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Return_;
use Rector\Core\Rector\AbstractRector;
@ -94,29 +96,16 @@ CODE_SAMPLE
if (!$this->hasReturn($node)) {
return null;
}
if ($this->isRedirectResponseReturn($node)) {
$node->returnType = new FullyQualified('Symfony\\Component\\HttpFoundation\\RedirectResponse');
if ($this->attrinationFinder->hasByOne($node, SymfonyAnnotation::SENSIO_TEMPLATE) || $this->attrinationFinder->hasByOne($node, SymfonyAnnotation::TWIG_TEMPLATE)) {
$node->returnType = new NullableType(new Identifier('array'));
return $node;
}
if ($this->isBinaryFileResponseReturn($node)) {
$node->returnType = new FullyQualified('Symfony\\Component\\HttpFoundation\\BinaryFileResponse');
return $node;
}
if ($this->isJsonResponseReturn($node)) {
$node->returnType = new FullyQualified('Symfony\\Component\\HttpFoundation\\JsonResponse');
return $node;
}
if ($this->isStreamedResponseReturn($node)) {
$node->returnType = new FullyQualified('Symfony\\Component\\HttpFoundation\\StreamedResponse');
return $node;
}
if ($this->isResponseReturn($node)) {
$node->returnType = new FullyQualified('Symfony\\Component\\HttpFoundation\\Response');
return $node;
}
return $node;
return $this->refactorResponse($node);
}
private function isResponseReturn(ClassMethod $classMethod) : bool
/**
* @param array<string> $methods
*/
private function isResponseReturnMethod(ClassMethod $classMethod, array $methods) : bool
{
$returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($classMethod, Return_::class);
foreach ($returns as $return) {
@ -128,76 +117,7 @@ CODE_SAMPLE
return \false;
}
$functionName = $this->getName($methodCall->name);
if (!\in_array($functionName, ['render', 'forward', 'renderForm'], \true)) {
return \false;
}
}
return \true;
}
private function isRedirectResponseReturn(ClassMethod $classMethod) : bool
{
$returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($classMethod, Return_::class);
foreach ($returns as $return) {
if (!$return->expr instanceof MethodCall) {
return \false;
}
$methodCall = $return->expr;
if (!$methodCall->var instanceof Variable || $methodCall->var->name !== 'this') {
return \false;
}
$functionName = $this->getName($methodCall->name);
if (!\in_array($functionName, ['redirectToRoute', 'redirect'], \true)) {
return \false;
}
}
return \true;
}
private function isBinaryFileResponseReturn(ClassMethod $classMethod) : bool
{
$returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($classMethod, Return_::class);
foreach ($returns as $return) {
if (!$return->expr instanceof MethodCall) {
return \false;
}
$methodCall = $return->expr;
if (!$methodCall->var instanceof Variable || $methodCall->var->name !== 'this') {
return \false;
}
if (!$this->isName($methodCall->name, 'file')) {
return \false;
}
}
return \true;
}
private function isJsonResponseReturn(ClassMethod $classMethod) : bool
{
$returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($classMethod, Return_::class);
foreach ($returns as $return) {
if (!$return->expr instanceof MethodCall) {
return \false;
}
$methodCall = $return->expr;
if (!$methodCall->var instanceof Variable || $methodCall->var->name !== 'this') {
return \false;
}
if (!$this->isName($methodCall->name, 'json')) {
return \false;
}
}
return \true;
}
private function isStreamedResponseReturn(ClassMethod $classMethod) : bool
{
$returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($classMethod, Return_::class);
foreach ($returns as $return) {
if (!$return->expr instanceof MethodCall) {
return \false;
}
$methodCall = $return->expr;
if (!$methodCall->var instanceof Variable || $methodCall->var->name !== 'this') {
return \false;
}
if (!$this->isName($methodCall->name, 'stream')) {
if (!\in_array($functionName, $methods, \true)) {
return \false;
}
}
@ -207,4 +127,28 @@ CODE_SAMPLE
{
return $this->betterNodeFinder->hasInstancesOf($classMethod, [Return_::class]);
}
private function refactorResponse(ClassMethod $classMethod) : Node
{
if ($this->isResponseReturnMethod($classMethod, ['redirectToRoute', 'redirect'])) {
$classMethod->returnType = new FullyQualified('Symfony\\Component\\HttpFoundation\\RedirectResponse');
return $classMethod;
}
if ($this->isResponseReturnMethod($classMethod, ['file'])) {
$classMethod->returnType = new FullyQualified('Symfony\\Component\\HttpFoundation\\BinaryFileResponse');
return $classMethod;
}
if ($this->isResponseReturnMethod($classMethod, ['json'])) {
$classMethod->returnType = new FullyQualified('Symfony\\Component\\HttpFoundation\\JsonResponse');
return $classMethod;
}
if ($this->isResponseReturnMethod($classMethod, ['stream'])) {
$classMethod->returnType = new FullyQualified('Symfony\\Component\\HttpFoundation\\StreamedResponse');
return $classMethod;
}
if ($this->isResponseReturnMethod($classMethod, ['render', 'forward', 'renderForm'])) {
$classMethod->returnType = new FullyQualified('Symfony\\Component\\HttpFoundation\\Response');
return $classMethod;
}
return $classMethod;
}
}

View File

@ -19,6 +19,7 @@ class ZshCompletionOutput implements CompletionOutputInterface
{
public function write(CompletionSuggestions $suggestions, OutputInterface $output) : void
{
$values = [];
foreach ($suggestions->getValueSuggestions() as $value) {
$values[] = $value->getValue() . ($value->getDescription() ? "\t" . $value->getDescription() : '');
}