mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-14 04:22:17 +02:00
Updated Rector to commit f3242bfadc709ca567975be62691944b5f8301ee
f3242bfadc
[CodeQuality] Handle crash inside block statement with unreachable statement on OptionalParametersAfterRequiredRector (#6640)
This commit is contained in:
parent
7ebf783415
commit
232892cf57
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -1752,12 +1752,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
|
||||
"reference": "9d0a7b24349833f3e95829006d5dfec83525f605"
|
||||
"reference": "f9cc5a03dc2a894691d3878adb6e9eef3483281a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/9d0a7b24349833f3e95829006d5dfec83525f605",
|
||||
"reference": "9d0a7b24349833f3e95829006d5dfec83525f605",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/f9cc5a03dc2a894691d3878adb6e9eef3483281a",
|
||||
"reference": "f9cc5a03dc2a894691d3878adb6e9eef3483281a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1775,7 +1775,7 @@
|
||||
"tomasvotruba\/class-leak": "^1.0",
|
||||
"tracy\/tracy": "^2.10"
|
||||
},
|
||||
"time": "2025-01-01T14:09:19+00:00",
|
||||
"time": "2025-01-01T14:37:24+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
@ -69,7 +69,7 @@ class ContextualBindingBuilder implements ContextualBindingBuilderContract
|
||||
{
|
||||
$this->give(function ($container) use($tag) {
|
||||
$taggedServices = $container->tagged($tag);
|
||||
return \is_array($taggedServices) ? $taggedServices : \iterator_to_array(\is_array($taggedServices) ? new \ArrayIterator($taggedServices) : $taggedServices);
|
||||
return \is_array($taggedServices) ? $taggedServices : \iterator_to_array($taggedServices);
|
||||
});
|
||||
}
|
||||
/**
|
||||
|
@ -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/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main f740789'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 9d0a7b2'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main 6b0e4f0'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 29a1abf'));
|
||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main f740789'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main f9cc5a0'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main 6b0e4f0'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 29a1abf'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -9,8 +9,11 @@ use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Expr\Ternary;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\NodeTraverser;
|
||||
use PHPStan\Type\Type;
|
||||
use PHPStan\Type\TypeCombinator;
|
||||
use Rector\NodeAnalyzer\ArgsAnalyzer;
|
||||
use Rector\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
@ -27,16 +30,21 @@ final class DowngradeIteratorCountToArrayRector extends AbstractRector
|
||||
* @readonly
|
||||
*/
|
||||
private ArgsAnalyzer $argsAnalyzer;
|
||||
public function __construct(ArgsAnalyzer $argsAnalyzer)
|
||||
/**
|
||||
* @readonly
|
||||
*/
|
||||
private BetterNodeFinder $betterNodeFinder;
|
||||
public function __construct(ArgsAnalyzer $argsAnalyzer, BetterNodeFinder $betterNodeFinder)
|
||||
{
|
||||
$this->argsAnalyzer = $argsAnalyzer;
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [FuncCall::class];
|
||||
return [Ternary::class, FuncCall::class];
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
@ -55,10 +63,18 @@ CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @param FuncCall $node
|
||||
* @param Ternary|FuncCall $node
|
||||
* @return null|\PhpParser\Node\Expr\FuncCall|int
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
public function refactor(Node $node)
|
||||
{
|
||||
if ($node instanceof Ternary) {
|
||||
$hasIsArrayCheck = (bool) $this->betterNodeFinder->findFirst($node, fn(Node $subNode): bool => $subNode instanceof FuncCall && $this->isName($subNode, 'is_array'));
|
||||
if ($hasIsArrayCheck) {
|
||||
return NodeTraverser::DONT_TRAVERSE_CHILDREN;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (!$this->isNames($node, ['iterator_count', 'iterator_to_array'])) {
|
||||
return null;
|
||||
}
|
||||
@ -86,6 +102,7 @@ CODE_SAMPLE
|
||||
if ($type->isArray()->yes()) {
|
||||
return \false;
|
||||
}
|
||||
$type = TypeCombinator::removeNull($type);
|
||||
return $type->isObject()->yes();
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ CODE_SAMPLE
|
||||
return null;
|
||||
}
|
||||
$methodName = $classMethod->name->toString();
|
||||
$parents = \array_merge(\is_array($classReflection->getParents()) ? $classReflection->getParents() : \iterator_to_array(\is_array($classReflection->getParents()) ? new \ArrayIterator($classReflection->getParents()) : $classReflection->getParents()), \is_array($classReflection->getInterfaces()) ? $classReflection->getInterfaces() : \iterator_to_array(\is_array($classReflection->getInterfaces()) ? new \ArrayIterator($classReflection->getInterfaces()) : $classReflection->getInterfaces()));
|
||||
$parents = \array_merge(\is_array($classReflection->getParents()) ? $classReflection->getParents() : \iterator_to_array($classReflection->getParents()), \is_array($classReflection->getInterfaces()) ? $classReflection->getInterfaces() : \iterator_to_array($classReflection->getInterfaces()));
|
||||
foreach ($parents as $parent) {
|
||||
if (!$parent->hasMethod($methodName)) {
|
||||
continue;
|
||||
|
@ -45,7 +45,7 @@ final class CommandDataCollector extends DataCollector
|
||||
case OutputInterface::VERBOSITY_DEBUG:
|
||||
return 'debug';
|
||||
}
|
||||
})(), 'interactive' => $command->isInteractive, 'validate_input' => !$command->ignoreValidation, 'enabled' => $command->isEnabled(), 'visible' => !$command->isHidden(), 'input' => $this->cloneVar($command->input), 'output' => $this->cloneVar($command->output), 'interactive_inputs' => \array_map(\Closure::fromCallable([$this, 'cloneVar']), $command->interactiveInputs), 'signalable' => $command->getSubscribedSignals(), 'handled_signals' => $command->handledSignals, 'helper_set' => \array_map(\Closure::fromCallable([$this, 'cloneVar']), \iterator_to_array(\is_array($command->getHelperSet()) ? new \ArrayIterator($command->getHelperSet()) : $command->getHelperSet()))];
|
||||
})(), 'interactive' => $command->isInteractive, 'validate_input' => !$command->ignoreValidation, 'enabled' => $command->isEnabled(), 'visible' => !$command->isHidden(), 'input' => $this->cloneVar($command->input), 'output' => $this->cloneVar($command->output), 'interactive_inputs' => \array_map(\Closure::fromCallable([$this, 'cloneVar']), $command->interactiveInputs), 'signalable' => $command->getSubscribedSignals(), 'handled_signals' => $command->handledSignals, 'helper_set' => \array_map(\Closure::fromCallable([$this, 'cloneVar']), \iterator_to_array($command->getHelperSet()))];
|
||||
$baseDefinition = $application->getDefinition();
|
||||
foreach ($command->arguments as $argName => $argValue) {
|
||||
if ($baseDefinition->hasArgument($argName)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user