Skip to content

[CodeQuality] Restore adding code with named previous arg in ThrowWithPreviousExceptionRector - #9063

Closed
TomasVotruba wants to merge 1 commit into
mainfrom
restore-throw-with-previous-code
Closed

TomasVotruba wants to merge 1 commit into
mainfrom
restore-throw-with-previous-code

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Follow up of #9062

#9052 changed ThrowWithPreviousExceptionRector to skip adding $e->getCode() when previous: is already passed as named argument, so it would not loop with NarrowPreviousExceptionCodeArgRector. That rule is now removed, as dropping the code changes getCode() of the new exception to 0.

This restores the original behavior, so the code is kept the same way as with positional arguments:

 } catch (\Throwable $throwable) {
-    throw new \LogicException('Some exception', previous: $throwable);
+    throw new \LogicException('Some exception', $throwable->getCode(), previous: $throwable);
 }

@TomasVotruba
TomasVotruba enabled auto-merge (squash) November 24, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant