Updated Rector to commit 3dfe7f9c11dc0ea75ba73da6f4639c1718843dc2

3dfe7f9c11 [Test] Enable displayDetailsOnTestsThatTriggerWarnings to true in tests to show warning (#4020)
This commit is contained in:
Tomas Votruba 2023-05-29 14:08:28 +00:00
parent 8d722f5b92
commit 9f963a664a
9 changed files with 40 additions and 62 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 ComposerAutoloaderInit1748eb556b93aa8cfd5001028604f51f::getLoader();
return ComposerAutoloaderInit5e03358f1b8a6c37a4b1e0f505237893::getLoader();

View File

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

View File

@ -2059,12 +2059,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "c733d610b633314444616fb12cd0e976d6b304d0"
"reference": "70c2f1368a2b72db44ee55e7d7ba9175c75bba62"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/c733d610b633314444616fb12cd0e976d6b304d0",
"reference": "c733d610b633314444616fb12cd0e976d6b304d0",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/70c2f1368a2b72db44ee55e7d7ba9175c75bba62",
"reference": "70c2f1368a2b72db44ee55e7d7ba9175c75bba62",
"shasum": ""
},
"require": {
@ -2094,7 +2094,7 @@
"tomasvotruba\/type-coverage": "^0.0.9",
"tomasvotruba\/unused-public": "^0.0.34"
},
"time": "2023-05-29T13:50:43+00:00",
"time": "2023-05-29T14:02:53+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

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 7e3df08'), '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 abf0a7f'), '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 edbdd0e'), '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 c733d61'));
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 7e3df08'), '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 abf0a7f'), '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 edbdd0e'), '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 70c2f13'));
private function __construct()
{
}

View File

@ -19,7 +19,6 @@ use PHPStan\Type\IntegerType;
use PHPStan\Type\ObjectType;
use Rector\Core\NodeAnalyzer\TerminatedNodeAnalyzer;
use Rector\Core\Rector\AbstractRector;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -43,7 +42,9 @@ final class ConsoleExecuteReturnIntRector extends AbstractRector
}
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Returns int from Command::execute command', [new CodeSample(<<<'CODE_SAMPLE'
return new RuleDefinition('Returns int from Command::execute() command', [new CodeSample(<<<'CODE_SAMPLE'
use Symfony\Component\Console\Command\Command;
class SomeCommand extends Command
{
public function execute(InputInterface $input, OutputInterface $output)
@ -53,6 +54,8 @@ class SomeCommand extends Command
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
use Symfony\Component\Console\Command\Command;
class SomeCommand extends Command
{
public function execute(InputInterface $input, OutputInterface $output): int
@ -83,7 +86,7 @@ CODE_SAMPLE
return null;
}
$this->refactorReturnTypeDeclaration($executeClassMethod);
$this->addReturn0ToMethod($executeClassMethod);
$this->addReturn0ToExecuteClassMethod($executeClassMethod);
if ($this->hasChanged) {
return $node;
}
@ -98,22 +101,16 @@ CODE_SAMPLE
$classMethod->returnType = new Identifier('int');
$this->hasChanged = \true;
}
private function addReturn0ToMethod(ClassMethod $classMethod) : void
private function addReturn0ToExecuteClassMethod(ClassMethod $classMethod) : void
{
$hasReturn = \false;
$this->traverseNodesWithCallable((array) $classMethod->getStmts(), function (Node $node) use($classMethod, &$hasReturn) : ?int {
if ($node instanceof FunctionLike) {
if ($classMethod->stmts === null) {
return;
}
$this->traverseNodesWithCallable($classMethod->stmts, function (Node $node) : ?int {
// skip anonymous class/function
if ($node instanceof FunctionLike || $node instanceof Class_) {
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}
// skip anonymous class
if ($node instanceof Class_) {
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}
$parentNode = $node->getAttribute(AttributeKey::PARENT_NODE);
if ($parentNode instanceof Node && $this->isReturnWithExprIntEquals($parentNode, $node)) {
$hasReturn = \true;
return null;
}
if (!$node instanceof Return_) {
return null;
}
@ -121,18 +118,12 @@ CODE_SAMPLE
return null;
}
if ($node->expr instanceof Ternary && $this->isIntegerTernaryIfElse($node->expr)) {
$hasReturn = \true;
return null;
}
// is there return without nesting?
if ($parentNode === $classMethod) {
$hasReturn = \true;
}
$this->setReturnTo0InsteadOfNull($node);
$this->hasChanged = \true;
return null;
});
$this->processReturn0ToMethod($hasReturn, $classMethod);
$this->processReturn0ToMethod($classMethod);
}
private function isReturnIntegerType(?Expr $expr) : bool
{
@ -157,11 +148,8 @@ CODE_SAMPLE
$elseType = $this->getType($else);
return $ifType instanceof IntegerType && $elseType instanceof IntegerType;
}
private function processReturn0ToMethod(bool $hasReturn, ClassMethod $classMethod) : void
private function processReturn0ToMethod(ClassMethod $classMethod) : void
{
if ($hasReturn) {
return;
}
$stmts = (array) $classMethod->stmts;
\end($stmts);
$lastKey = \key($stmts);
@ -171,16 +159,6 @@ CODE_SAMPLE
}
$classMethod->stmts[] = $return;
}
private function isReturnWithExprIntEquals(Node $parentNode, Node $node) : bool
{
if (!$parentNode instanceof Return_) {
return \false;
}
if (!$this->nodeComparator->areNodesEqual($parentNode->expr, $node)) {
return \false;
}
return $node instanceof Int_;
}
private function setReturnTo0InsteadOfNull(Return_ $return) : void
{
if (!$return->expr instanceof Expr) {

View File

@ -17,7 +17,6 @@ use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\Symfony\Enum\SensioAttribute;
use Rector\Symfony\Enum\SymfonyAnnotation;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
@ -114,9 +113,11 @@ CODE_SAMPLE
return null;
}
$name = $firstArg->value->value;
$mapping = $attribute->args[$optionsIndex]->value;
$exprValue = $attribute->args[$exprIndex]->value;
$newArguments = $this->getNewArguments($mapping, $exprValue);
$mappingArg = $attribute->args[$optionsIndex] ?? null;
$mappingExpr = $mappingArg instanceof Arg ? $mappingArg->value : null;
$exprArg = $attribute->args[$exprIndex] ?? null;
$exprValue = $exprArg instanceof Arg ? $exprArg->value : null;
$newArguments = $this->getNewArguments($mappingExpr, $exprValue);
if ($newArguments === []) {
return null;
}
@ -129,7 +130,6 @@ CODE_SAMPLE
}
$attribute->args = \array_merge($attribute->args, $newArguments);
$attribute->name = new FullyQualified(SymfonyAnnotation::MAP_ENTITY_CLASS);
// $node = $attribute->getAttribute(AttributeKey::PARENT_NODE);
$this->addMapEntityAttribute($classMethod, $name, $attributeGroup);
return $attribute;
}

View File

@ -109,17 +109,17 @@ CODE_SAMPLE
$constFetch = $this->commandHelper->getCommandHiddenValueFromAttributeOrSetter($node);
return $this->replaceAsCommandAttribute($node, $this->createAttributeGroupAsCommand($defaultName, $defaultDescription, $alisesArray, $constFetch));
}
private function createAttributeGroupAsCommand(string $defaultName, ?string $defaultDescription, ?Array_ $array, ?ConstFetch $constFetch) : AttributeGroup
private function createAttributeGroupAsCommand(string $defaultName, ?string $defaultDescription, ?Array_ $aliasesArray, ?ConstFetch $constFetch) : AttributeGroup
{
$attributeGroup = $this->phpAttributeGroupFactory->createFromClass(CommandHelper::ATTRIBUTE);
$attributeGroup->attrs[0]->args[] = new Arg(new String_($defaultName));
if ($defaultDescription !== null) {
$attributeGroup->attrs[0]->args[] = new Arg(new String_($defaultDescription));
} elseif ($array instanceof Array_ || $constFetch instanceof ConstFetch) {
} elseif ($aliasesArray instanceof Array_ || $constFetch instanceof ConstFetch) {
$attributeGroup->attrs[0]->args[] = new Arg($this->nodeFactory->createNull());
}
if ($array instanceof Array_) {
$attributeGroup->attrs[0]->args[] = new Arg($array);
if ($aliasesArray instanceof Array_) {
$attributeGroup->attrs[0]->args[] = new Arg($aliasesArray);
} elseif ($constFetch instanceof ConstFetch) {
$attributeGroup->attrs[0]->args[] = new Arg(new Array_());
}