Skip to content

Commit 868d2da

Browse files
committed
Updated Rector to commit 64ba1b31738854b34b1455cf14ca54777984e052
rectorphp/rector-src@64ba1b3 [CodeQuality] Skip with custom param in previous position on ThrowWithPreviousExceptionRector (#7919)
1 parent 69f19bd commit 868d2da

16 files changed

Lines changed: 169 additions & 77 deletions

File tree

rules/CodeQuality/Rector/Catch_/ThrowWithPreviousExceptionRector.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ private function refactorThrow(Throw_ $throw, Variable $caughtThrowableVariable)
134134
$hasChanged = \true;
135135
}
136136
if (!isset($new->getArgs()[1])) {
137-
if ($this->hasCodeParameter($new->class)) {
137+
if ($this->hasParameter($new, 'code') && !$this->hasArgument($new, 'code')) {
138138
// get previous code
139139
$new->args[1] = new Arg(new MethodCall($caughtThrowableVariable, 'getCode'), \false, \false, [], $shouldUseNamedArguments ? new Identifier('code') : null);
140140
$hasChanged = \true;
@@ -145,24 +145,30 @@ private function refactorThrow(Throw_ $throw, Variable $caughtThrowableVariable)
145145
/** @var Arg $arg1 */
146146
$arg1 = $new->args[1];
147147
if ($arg1->name instanceof Identifier && $arg1->name->toString() === 'previous') {
148-
if ($this->hasCodeParameter($new->class)) {
148+
if ($this->hasParameter($new, 'code') && !$this->hasArgument($new, 'code')) {
149149
$new->args[1] = new Arg(new MethodCall($caughtThrowableVariable, 'getCode'), \false, \false, [], $shouldUseNamedArguments ? new Identifier('code') : null);
150150
$new->args[$exceptionArgumentPosition] = $arg1;
151151
$hasChanged = \true;
152152
} elseif (!$hasChanged) {
153153
return null;
154154
}
155-
} else {
155+
} elseif ($this->hasParameter($new, 'previous') && !$this->hasArgument($new, 'previous')) {
156156
$new->args[$exceptionArgumentPosition] = new Arg($caughtThrowableVariable, \false, \false, [], $shouldUseNamedArguments ? new Identifier('previous') : null);
157+
$hasChanged = \true;
158+
} elseif (!$hasChanged) {
159+
return null;
157160
}
158161
// null the node, to fix broken format preserving printers, see https://github.com/rectorphp/rector/issues/5576
159162
$new->setAttribute(AttributeKey::ORIGINAL_NODE, null);
160163
// nothing more to add
161164
return NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
162165
}
163-
private function hasCodeParameter(Name $exceptionName): bool
166+
private function hasParameter(New_ $new, string $parameterName): bool
164167
{
165-
$className = $this->getName($exceptionName);
168+
$className = $this->getName($new->class);
169+
if ($className === null) {
170+
return \false;
171+
}
166172
if (!$this->reflectionProvider->hasClass($className)) {
167173
return \false;
168174
}
@@ -174,7 +180,16 @@ private function hasCodeParameter(Name $exceptionName): bool
174180
$extendedMethodReflection = $classReflection->getConstructor();
175181
$extendedParametersAcceptor = ParametersAcceptorSelector::combineAcceptors($extendedMethodReflection->getVariants());
176182
foreach ($extendedParametersAcceptor->getParameters() as $extendedParameterReflection) {
177-
if ($extendedParameterReflection->getName() === 'code') {
183+
if ($extendedParameterReflection->getName() === $parameterName) {
184+
return \true;
185+
}
186+
}
187+
return \false;
188+
}
189+
private function hasArgument(New_ $new, string $argumentName): bool
190+
{
191+
foreach ($new->getArgs() as $arg) {
192+
if ($arg->name instanceof Identifier && $arg->name->toString() === $argumentName) {
178193
return \true;
179194
}
180195
}

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 = '44a8dfcfbc50eab152582d466b3df5eceff009d7';
22+
public const PACKAGE_VERSION = '64ba1b31738854b34b1455cf14ca54777984e052';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2026-02-26 00:18:12';
27+
public const RELEASE_DATE = '2026-02-27 00:03:10';
2828
/**
2929
* @var int
3030
*/

vendor/composer/installed.json

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,17 +2020,17 @@
20202020
},
20212021
{
20222022
"name": "symfony\/console",
2023-
"version": "v6.4.32",
2024-
"version_normalized": "6.4.32.0",
2023+
"version": "v6.4.34",
2024+
"version_normalized": "6.4.34.0",
20252025
"source": {
20262026
"type": "git",
20272027
"url": "https:\/\/github.com\/symfony\/console.git",
2028-
"reference": "0bc2199c6c1f05276b05956f1ddc63f6d7eb5fc3"
2028+
"reference": "7b1f1c37eff5910ddda2831345467e593a5120ad"
20292029
},
20302030
"dist": {
20312031
"type": "zip",
2032-
"url": "https:\/\/api.github.com\/repos\/symfony\/console\/zipball\/0bc2199c6c1f05276b05956f1ddc63f6d7eb5fc3",
2033-
"reference": "0bc2199c6c1f05276b05956f1ddc63f6d7eb5fc3",
2032+
"url": "https:\/\/api.github.com\/repos\/symfony\/console\/zipball\/7b1f1c37eff5910ddda2831345467e593a5120ad",
2033+
"reference": "7b1f1c37eff5910ddda2831345467e593a5120ad",
20342034
"shasum": ""
20352035
},
20362036
"require": {
@@ -2063,7 +2063,7 @@
20632063
"symfony\/stopwatch": "^5.4|^6.0|^7.0",
20642064
"symfony\/var-dumper": "^5.4|^6.0|^7.0"
20652065
},
2066-
"time": "2026-01-13T08:45:59+00:00",
2066+
"time": "2026-02-23T15:42:15+00:00",
20672067
"type": "library",
20682068
"installation-source": "dist",
20692069
"autoload": {
@@ -2097,7 +2097,7 @@
20972097
"terminal"
20982098
],
20992099
"support": {
2100-
"source": "https:\/\/github.com\/symfony\/console\/tree\/v6.4.32"
2100+
"source": "https:\/\/github.com\/symfony\/console\/tree\/v6.4.34"
21012101
},
21022102
"funding": [
21032103
{
@@ -2191,17 +2191,17 @@
21912191
},
21922192
{
21932193
"name": "symfony\/filesystem",
2194-
"version": "v7.4.0",
2195-
"version_normalized": "7.4.0.0",
2194+
"version": "v7.4.6",
2195+
"version_normalized": "7.4.6.0",
21962196
"source": {
21972197
"type": "git",
21982198
"url": "https:\/\/github.com\/symfony\/filesystem.git",
2199-
"reference": "d551b38811096d0be9c4691d406991b47c0c630a"
2199+
"reference": "3ebc794fa5315e59fd122561623c2e2e4280538e"
22002200
},
22012201
"dist": {
22022202
"type": "zip",
2203-
"url": "https:\/\/api.github.com\/repos\/symfony\/filesystem\/zipball\/d551b38811096d0be9c4691d406991b47c0c630a",
2204-
"reference": "d551b38811096d0be9c4691d406991b47c0c630a",
2203+
"url": "https:\/\/api.github.com\/repos\/symfony\/filesystem\/zipball\/3ebc794fa5315e59fd122561623c2e2e4280538e",
2204+
"reference": "3ebc794fa5315e59fd122561623c2e2e4280538e",
22052205
"shasum": ""
22062206
},
22072207
"require": {
@@ -2212,7 +2212,7 @@
22122212
"require-dev": {
22132213
"symfony\/process": "^6.4|^7.0|^8.0"
22142214
},
2215-
"time": "2025-11-27T13:27:24+00:00",
2215+
"time": "2026-02-25T16:50:00+00:00",
22162216
"type": "library",
22172217
"installation-source": "dist",
22182218
"autoload": {
@@ -2240,7 +2240,7 @@
22402240
"description": "Provides basic utilities for the filesystem",
22412241
"homepage": "https:\/\/symfony.com",
22422242
"support": {
2243-
"source": "https:\/\/github.com\/symfony\/filesystem\/tree\/v7.4.0"
2243+
"source": "https:\/\/github.com\/symfony\/filesystem\/tree\/v7.4.6"
22442244
},
22452245
"funding": [
22462246
{
@@ -2264,17 +2264,17 @@
22642264
},
22652265
{
22662266
"name": "symfony\/finder",
2267-
"version": "v6.4.33",
2268-
"version_normalized": "6.4.33.0",
2267+
"version": "v6.4.34",
2268+
"version_normalized": "6.4.34.0",
22692269
"source": {
22702270
"type": "git",
22712271
"url": "https:\/\/github.com\/symfony\/finder.git",
2272-
"reference": "24965ca011dac87431729640feef8bcf7b5523e0"
2272+
"reference": "9590e86be1d1c57bfbb16d0dd040345378c20896"
22732273
},
22742274
"dist": {
22752275
"type": "zip",
2276-
"url": "https:\/\/api.github.com\/repos\/symfony\/finder\/zipball\/24965ca011dac87431729640feef8bcf7b5523e0",
2277-
"reference": "24965ca011dac87431729640feef8bcf7b5523e0",
2276+
"url": "https:\/\/api.github.com\/repos\/symfony\/finder\/zipball\/9590e86be1d1c57bfbb16d0dd040345378c20896",
2277+
"reference": "9590e86be1d1c57bfbb16d0dd040345378c20896",
22782278
"shasum": ""
22792279
},
22802280
"require": {
@@ -2283,7 +2283,7 @@
22832283
"require-dev": {
22842284
"symfony\/filesystem": "^6.0|^7.0"
22852285
},
2286-
"time": "2026-01-26T13:03:48+00:00",
2286+
"time": "2026-01-28T15:16:37+00:00",
22872287
"type": "library",
22882288
"installation-source": "dist",
22892289
"autoload": {
@@ -2311,7 +2311,7 @@
23112311
"description": "Finds files and directories via an intuitive fluent interface",
23122312
"homepage": "https:\/\/symfony.com",
23132313
"support": {
2314-
"source": "https:\/\/github.com\/symfony\/finder\/tree\/v6.4.33"
2314+
"source": "https:\/\/github.com\/symfony\/finder\/tree\/v6.4.34"
23152315
},
23162316
"funding": [
23172317
{
@@ -3006,17 +3006,17 @@
30063006
},
30073007
{
30083008
"name": "symfony\/string",
3009-
"version": "v7.4.4",
3010-
"version_normalized": "7.4.4.0",
3009+
"version": "v7.4.6",
3010+
"version_normalized": "7.4.6.0",
30113011
"source": {
30123012
"type": "git",
30133013
"url": "https:\/\/github.com\/symfony\/string.git",
3014-
"reference": "1c4b10461bf2ec27537b5f36105337262f5f5d6f"
3014+
"reference": "9f209231affa85aa930a5e46e6eb03381424b30b"
30153015
},
30163016
"dist": {
30173017
"type": "zip",
3018-
"url": "https:\/\/api.github.com\/repos\/symfony\/string\/zipball\/1c4b10461bf2ec27537b5f36105337262f5f5d6f",
3019-
"reference": "1c4b10461bf2ec27537b5f36105337262f5f5d6f",
3018+
"url": "https:\/\/api.github.com\/repos\/symfony\/string\/zipball\/9f209231affa85aa930a5e46e6eb03381424b30b",
3019+
"reference": "9f209231affa85aa930a5e46e6eb03381424b30b",
30203020
"shasum": ""
30213021
},
30223022
"require": {
@@ -3037,7 +3037,7 @@
30373037
"symfony\/translation-contracts": "^2.5|^3.0",
30383038
"symfony\/var-exporter": "^6.4|^7.0|^8.0"
30393039
},
3040-
"time": "2026-01-12T10:54:30+00:00",
3040+
"time": "2026-02-09T09:33:46+00:00",
30413041
"type": "library",
30423042
"installation-source": "dist",
30433043
"autoload": {
@@ -3076,7 +3076,7 @@
30763076
"utf8"
30773077
],
30783078
"support": {
3079-
"source": "https:\/\/github.com\/symfony\/string\/tree\/v7.4.4"
3079+
"source": "https:\/\/github.com\/symfony\/string\/tree\/v7.4.6"
30803080
},
30813081
"funding": [
30823082
{
@@ -3100,17 +3100,17 @@
31003100
},
31013101
{
31023102
"name": "symfony\/yaml",
3103-
"version": "v7.4.1",
3104-
"version_normalized": "7.4.1.0",
3103+
"version": "v7.4.6",
3104+
"version_normalized": "7.4.6.0",
31053105
"source": {
31063106
"type": "git",
31073107
"url": "https:\/\/github.com\/symfony\/yaml.git",
3108-
"reference": "24dd4de28d2e3988b311751ac49e684d783e2345"
3108+
"reference": "58751048de17bae71c5aa0d13cb19d79bca26391"
31093109
},
31103110
"dist": {
31113111
"type": "zip",
3112-
"url": "https:\/\/api.github.com\/repos\/symfony\/yaml\/zipball\/24dd4de28d2e3988b311751ac49e684d783e2345",
3113-
"reference": "24dd4de28d2e3988b311751ac49e684d783e2345",
3112+
"url": "https:\/\/api.github.com\/repos\/symfony\/yaml\/zipball\/58751048de17bae71c5aa0d13cb19d79bca26391",
3113+
"reference": "58751048de17bae71c5aa0d13cb19d79bca26391",
31143114
"shasum": ""
31153115
},
31163116
"require": {
@@ -3124,7 +3124,7 @@
31243124
"require-dev": {
31253125
"symfony\/console": "^6.4|^7.0|^8.0"
31263126
},
3127-
"time": "2025-12-04T18:11:45+00:00",
3127+
"time": "2026-02-09T09:33:46+00:00",
31283128
"bin": [
31293129
"Resources\/bin\/yaml-lint"
31303130
],
@@ -3155,7 +3155,7 @@
31553155
"description": "Loads and dumps YAML files",
31563156
"homepage": "https:\/\/symfony.com",
31573157
"support": {
3158-
"source": "https:\/\/github.com\/symfony\/yaml\/tree\/v7.4.1"
3158+
"source": "https:\/\/github.com\/symfony\/yaml\/tree\/v7.4.6"
31593159
},
31603160
"funding": [
31613161
{

0 commit comments

Comments
 (0)