mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-21 16:02:23 +02:00
Updated Rector to commit 1b2453f90e3def5feb7090482d742242064db4c2
1b2453f90e
[TypeDeclaration] ReturnTypeFromStrictNewArrayRector support list (#6820)
This commit is contained in:
parent
27f4dfbf46
commit
0e6e1c6ac7
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -1748,12 +1748,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
|
||||
"reference": "480f1cfb59923251e4835a9f94792452ce3e948d"
|
||||
"reference": "15fd706ad6def5c0ebba948cc8a9a262dfa17045"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/480f1cfb59923251e4835a9f94792452ce3e948d",
|
||||
"reference": "480f1cfb59923251e4835a9f94792452ce3e948d",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/15fd706ad6def5c0ebba948cc8a9a262dfa17045",
|
||||
"reference": "15fd706ad6def5c0ebba948cc8a9a262dfa17045",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1771,7 +1771,7 @@
|
||||
"tomasvotruba\/class-leak": "^1.0",
|
||||
"tracy\/tracy": "^2.10"
|
||||
},
|
||||
"time": "2025-03-27T18:35:36+00:00",
|
||||
"time": "2025-04-06T09:36:28+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
@ -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 c923389'), '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 480f1cf'), '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 0da29d9'), '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 d446023'));
|
||||
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 c923389'), '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 15fd706'), '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 0da29d9'), '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 d446023'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -61,12 +61,12 @@ CODE_SAMPLE
|
||||
}
|
||||
/**
|
||||
* @param ConstFetch|BitwiseOr|If_ $node
|
||||
* @return \PhpParser\Node\Expr|\PhpParser\Node\Stmt\If_|null
|
||||
*/
|
||||
public function refactor(Node $node)
|
||||
public function refactor(Node $node) : ?\PhpParser\Node\Expr
|
||||
{
|
||||
if ($node instanceof If_) {
|
||||
return $this->refactorIf($node);
|
||||
$this->markConstantKnownInInnerStmts($node);
|
||||
return null;
|
||||
}
|
||||
// skip as known
|
||||
if ((bool) $node->getAttribute(self::PHP72_JSON_CONSTANT_IS_KNOWN)) {
|
||||
@ -74,15 +74,14 @@ CODE_SAMPLE
|
||||
}
|
||||
return $this->jsonConstCleaner->clean($node, [JsonConstant::INVALID_UTF8_IGNORE, JsonConstant::INVALID_UTF8_SUBSTITUTE]);
|
||||
}
|
||||
private function refactorIf(If_ $if) : ?If_
|
||||
private function markConstantKnownInInnerStmts(If_ $if) : void
|
||||
{
|
||||
if (!$this->defineFuncCallAnalyzer->isDefinedWithConstants($if->cond, [JsonConstant::INVALID_UTF8_IGNORE, JsonConstant::INVALID_UTF8_SUBSTITUTE])) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
$this->traverseNodesWithCallable($if, static function (Node $node) {
|
||||
$node->setAttribute(self::PHP72_JSON_CONSTANT_IS_KNOWN, \true);
|
||||
return null;
|
||||
});
|
||||
return $if;
|
||||
}
|
||||
}
|
||||
|
@ -92,12 +92,13 @@ CODE_SAMPLE
|
||||
}
|
||||
/**
|
||||
* @param ConstFetch|BitwiseOr|If_|TryCatch|Expression $node
|
||||
* @return null|Expr|If_|array<Expression|If_>
|
||||
* @return null|Expr|array<Expression|If_>
|
||||
*/
|
||||
public function refactor(Node $node)
|
||||
{
|
||||
if ($node instanceof If_) {
|
||||
return $this->refactorIf($node);
|
||||
$this->markConstantKnownInInnerStmts($node);
|
||||
return null;
|
||||
}
|
||||
// skip as known
|
||||
if ((bool) $node->getAttribute(self::PHP73_JSON_CONSTANT_IS_KNOWN)) {
|
||||
@ -124,16 +125,15 @@ CODE_SAMPLE
|
||||
}
|
||||
return $this->jsonConstCleaner->clean($node, [JsonConstant::THROW_ON_ERROR]);
|
||||
}
|
||||
private function refactorIf(If_ $if) : ?If_
|
||||
private function markConstantKnownInInnerStmts(If_ $if) : void
|
||||
{
|
||||
if (!$this->defineFuncCallAnalyzer->isDefinedWithConstants($if->cond, [JsonConstant::THROW_ON_ERROR])) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
$this->traverseNodesWithCallable($if, static function (Node $node) {
|
||||
$node->setAttribute(self::PHP73_JSON_CONSTANT_IS_KNOWN, \true);
|
||||
return null;
|
||||
});
|
||||
return $if;
|
||||
}
|
||||
private function resolveFuncCall(Expression $Expression) : ?FuncCall
|
||||
{
|
||||
|
@ -67,10 +67,12 @@ CODE_SAMPLE
|
||||
public function refactor(Node $node) : ?\PhpParser\Node
|
||||
{
|
||||
if ($node instanceof Instanceof_) {
|
||||
return $this->refactorInstanceof($node);
|
||||
$this->markSkipInstanceof($node);
|
||||
return null;
|
||||
}
|
||||
if ($node instanceof Ternary) {
|
||||
return $this->refactorTernary($node);
|
||||
$this->markSkipTernary($node);
|
||||
return null;
|
||||
}
|
||||
if ($node->getAttribute(self::SKIP_NODE) === \true) {
|
||||
return null;
|
||||
@ -84,30 +86,28 @@ CODE_SAMPLE
|
||||
$args = [new Arg($node->var), new Arg(new String_('getType'))];
|
||||
return new Ternary($this->nodeFactory->createFuncCall('method_exists', $args), $node, $this->nodeFactory->createNull());
|
||||
}
|
||||
private function refactorInstanceof(Instanceof_ $instanceof) : ?Instanceof_
|
||||
private function markSkipInstanceof(Instanceof_ $instanceof) : void
|
||||
{
|
||||
if (!$this->isName($instanceof->class, 'ReflectionNamedType')) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
if (!$instanceof->expr instanceof MethodCall) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
// checked typed → safe
|
||||
$instanceof->expr->setAttribute(self::SKIP_NODE, \true);
|
||||
return $instanceof;
|
||||
}
|
||||
private function refactorTernary(Ternary $ternary) : ?Ternary
|
||||
private function markSkipTernary(Ternary $ternary) : void
|
||||
{
|
||||
if (!$ternary->if instanceof Expr) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
if (!$ternary->cond instanceof FuncCall) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
if (!$this->isName($ternary->cond, 'method_exists')) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
$ternary->if->setAttribute(self::SKIP_NODE, \true);
|
||||
return $ternary;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user