Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds ThrowIfRector rule #154

Merged
merged 2 commits into from
Dec 6, 2023
Merged

Conversation

peterfox
Copy link
Collaborator

@peterfox peterfox commented Dec 6, 2023

Changes

  • Adds the new rule
  • Adds tests for the rule
  • Updates the Rule list

Why

I thought it would be a nice addition to be able to automatically convert simply if statements that are used to throw an exception.

Example code:

-if ($condition) {
-    throw new Exception();
-}
-if (!$condition) {
-    throw new Exception();
-}
+throw_if($condition, new Exception());
+throw_unless($condition, new Exception());

@GeniJaho GeniJaho merged commit cf00851 into driftingly:main Dec 6, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants