Fix: Don't rewrite non-boolean expectations in the boolean-simplification rules - #3
Merged
MrPunyapal merged 2 commits intoJul 29, 2026
Conversation
MrPunyapal
approved these changes
Jul 29, 2026
Collaborator
|
@webard once CI passes we are good to go. |
Collaborator
|
thanks |
Contributor
Author
|
@MrPunyapal done! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two boolean-simplification rules can silently change what a test asserts when the expected value isn't a real boolean:
ToBeTrueNotFalseRectorrewrites->not->toBeFalse()->->toBeTrue()SimplifyExpectNotRectorrewritesexpect(!$x)->toBeTrue()->expect($x)->toBeFalse()Both rewrites are only equivalent when the subject is a pure boolean. For anything else - most commonly a
T|falseunion likemb_strstr()/openssl_pkey_get_public()(string|false), or a plainint / string / mixed- they turn a loose check into a strict === true / === false and break passing tests.Example for
ToBeTrueNotFalseRectorbecomes
Example for
SimplifyExpectNotRectorbecomes
Both rules now flip the matcher only when the subject is provably a pure boolean (
isBoolean()->yes()). Otherwise they leave the expectation untouched.BTW: Thanks for releasing PestPHP 5! 🎉