Skip to content

Commit 1b80e93

Browse files
committed
Updated Rector to commit 22644d9e28a6a103c0e0f12eb6fb644f1bbf3ab0
rectorphp/rector-src@22644d9 Temporary re-pin nette/utils to 4.1.2 (#7893)
1 parent f97c6e3 commit 1b80e93

File tree

6 files changed

+51
-15
lines changed

6 files changed

+51
-15
lines changed

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = '051866ce70a8fa7a327056cdfddaa2d1f9954ecf';
22+
public const PACKAGE_VERSION = '22644d9e28a6a103c0e0f12eb6fb644f1bbf3ab0';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2026-02-14 04:45:23';
27+
public const RELEASE_DATE = '2026-02-14 05:45:23';
2828
/**
2929
* @var int
3030
*/

vendor/composer/installed.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,12 +1757,12 @@
17571757
"source": {
17581758
"type": "git",
17591759
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
1760-
"reference": "a110e2fcf94e7513739f54bc27cd473ba9eff5d5"
1760+
"reference": "db13b8fe0b57a5c292f8fe9696d2dcad0609dc65"
17611761
},
17621762
"dist": {
17631763
"type": "zip",
1764-
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/a110e2fcf94e7513739f54bc27cd473ba9eff5d5",
1765-
"reference": "a110e2fcf94e7513739f54bc27cd473ba9eff5d5",
1764+
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/db13b8fe0b57a5c292f8fe9696d2dcad0609dc65",
1765+
"reference": "db13b8fe0b57a5c292f8fe9696d2dcad0609dc65",
17661766
"shasum": ""
17671767
},
17681768
"require": {
@@ -1786,7 +1786,7 @@
17861786
"tomasvotruba\/unused-public": "^2.2",
17871787
"tracy\/tracy": "^2.11"
17881788
},
1789-
"time": "2026-01-16T19:42:03+00:00",
1789+
"time": "2026-02-14T05:36:31+00:00",
17901790
"default-branch": true,
17911791
"type": "rector-extension",
17921792
"extra": {

vendor/composer/installed.php

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

vendor/rector/extension-installer/src/GeneratedConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
final class GeneratedConfig
1111
{
12-
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 46e4f77'), '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 a110e2f'), '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 adce7d9'), '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 e9008b6'));
12+
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 46e4f77'), '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 db13b8f'), '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 adce7d9'), '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 e9008b6'));
1313
private function __construct()
1414
{
1515
}

vendor/rector/rector-downgrade-php/rules/DowngradePhp80/Rector/Expression/DowngradeThrowExprRector.php

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use PhpParser\Node\Expr\BinaryOp\Coalesce;
1212
use PhpParser\Node\Expr\BinaryOp\Identical;
1313
use PhpParser\Node\Expr\BooleanNot;
14+
use PhpParser\Node\Expr\CallLike;
1415
use PhpParser\Node\Expr\Closure;
1516
use PhpParser\Node\Expr\ConstFetch;
1617
use PhpParser\Node\Expr\Isset_;
@@ -24,6 +25,7 @@
2425
use PhpParser\Node\Stmt\If_;
2526
use PhpParser\Node\Stmt\Return_;
2627
use Rector\NodeAnalyzer\CoalesceAnalyzer;
28+
use Rector\NodeFactory\NamedVariableFactory;
2729
use Rector\NodeManipulator\BinaryOpManipulator;
2830
use Rector\Php72\NodeFactory\AnonymousFunctionFactory;
2931
use Rector\PhpParser\Node\BetterNodeFinder;
@@ -53,12 +55,17 @@ final class DowngradeThrowExprRector extends AbstractRector
5355
* @readonly
5456
*/
5557
private AnonymousFunctionFactory $anonymousFunctionFactory;
56-
public function __construct(CoalesceAnalyzer $coalesceAnalyzer, BinaryOpManipulator $binaryOpManipulator, BetterNodeFinder $betterNodeFinder, AnonymousFunctionFactory $anonymousFunctionFactory)
58+
/**
59+
* @readonly
60+
*/
61+
private NamedVariableFactory $namedVariableFactory;
62+
public function __construct(CoalesceAnalyzer $coalesceAnalyzer, BinaryOpManipulator $binaryOpManipulator, BetterNodeFinder $betterNodeFinder, AnonymousFunctionFactory $anonymousFunctionFactory, NamedVariableFactory $namedVariableFactory)
5763
{
5864
$this->coalesceAnalyzer = $coalesceAnalyzer;
5965
$this->binaryOpManipulator = $binaryOpManipulator;
6066
$this->betterNodeFinder = $betterNodeFinder;
6167
$this->anonymousFunctionFactory = $anonymousFunctionFactory;
68+
$this->namedVariableFactory = $namedVariableFactory;
6269
}
6370
public function getRuleDefinition(): RuleDefinition
6471
{
@@ -102,6 +109,19 @@ public function refactor(Node $node)
102109
return $resultNode;
103110
}
104111
}
112+
if ($node->expr instanceof CallLike && !$node->expr->isFirstClassCallable()) {
113+
$args = $node->expr->getArgs();
114+
foreach ($args as $arg) {
115+
if ($arg->value instanceof Ternary && $arg->value->else instanceof Throw_) {
116+
$refactorTernary = $this->refactorTernary($arg->value, null, \true);
117+
if (is_array($refactorTernary) && $refactorTernary[0] instanceof Expression && $refactorTernary[0]->expr instanceof Assign) {
118+
$arg->value = $refactorTernary[0]->expr->var;
119+
return array_merge($refactorTernary, [$node]);
120+
}
121+
}
122+
}
123+
return null;
124+
}
105125
if ($node->expr instanceof Coalesce) {
106126
return $this->refactorCoalesce($node->expr, null);
107127
}
@@ -140,13 +160,24 @@ private function refactorAssign(Assign $assign)
140160
/**
141161
* @return If_|Stmt[]|null
142162
*/
143-
private function refactorTernary(Ternary $ternary, ?Assign $assign)
163+
private function refactorTernary(Ternary $ternary, ?Assign $assign, bool $onArg = \false)
144164
{
145-
if (!$ternary->else instanceof Throw_) {
165+
if ($ternary->if instanceof Throw_) {
166+
$else = $ternary->if;
167+
} elseif ($ternary->else instanceof Throw_) {
168+
$else = $ternary->else;
169+
} else {
146170
return null;
147171
}
148-
$inversedTernaryExpr = $this->binaryOpManipulator->inverseNode($ternary->cond);
149-
$if = new If_($inversedTernaryExpr, ['stmts' => [new Expression($ternary->else)]]);
172+
$inversedTernaryExpr = $ternary->if instanceof Throw_ ? $ternary->cond : $this->binaryOpManipulator->inverseNode($ternary->cond);
173+
$if = new If_($inversedTernaryExpr, ['stmts' => [new Expression($else)]]);
174+
if (!$assign instanceof Assign && $onArg) {
175+
$tempVar = $this->namedVariableFactory->createVariable('arg', $ternary);
176+
$assign = new Assign($tempVar, $ternary->if ?? $ternary->cond);
177+
$inversedTernaryExpr = $this->binaryOpManipulator->inverseNode($tempVar);
178+
$if = new If_($inversedTernaryExpr, ['stmts' => [new Expression($else)]]);
179+
return [new Expression($assign), $if];
180+
}
150181
if (!$assign instanceof Assign) {
151182
return $if;
152183
}
@@ -223,7 +254,8 @@ private function refactorReturn(Return_ $return): ?array
223254
if (!$if instanceof If_) {
224255
return null;
225256
}
226-
return [$if, new Return_($return->expr->cond)];
257+
$returnExpr = $return->expr->if instanceof Throw_ ? $return->expr->else : $return->expr->if ?? $return->expr->cond;
258+
return [$if, new Return_($returnExpr)];
227259
}
228260
return null;
229261
}

vendor/rector/rector-downgrade-php/src/NodeFactory/NamedVariableFactory.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
declare (strict_types=1);
44
namespace Rector\NodeFactory;
55

6+
use PhpParser\Node\Expr\Ternary;
67
use PhpParser\Node\Expr\Variable;
78
use PhpParser\Node\Stmt\Expression;
89
use Rector\Naming\Naming\VariableNaming;
@@ -17,7 +18,10 @@ public function __construct(VariableNaming $variableNaming)
1718
{
1819
$this->variableNaming = $variableNaming;
1920
}
20-
public function createVariable(string $variableName, Expression $expression): Variable
21+
/**
22+
* @param \PhpParser\Node\Stmt\Expression|\PhpParser\Node\Expr\Ternary $expression
23+
*/
24+
public function createVariable(string $variableName, $expression): Variable
2125
{
2226
$scope = $expression->getAttribute(AttributeKey::SCOPE);
2327
$variableName = $this->variableNaming->createCountedValueName($variableName, $scope);

0 commit comments

Comments
 (0)