-
Notifications
You must be signed in to change notification settings - Fork 551
Fix #13963 with unit tests. #4786
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
Open
niconoe-
wants to merge
17
commits into
phpstan:2.1.x
Choose a base branch
from
niconoe-:fix-13963
base: 2.1.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+389
−17
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
aaf71de
Fix #13963 with unit tests.
niconoe- a4a2cb2
Improve handling of input type for filter_var with option FILTER_FLAG…
niconoe- 187e52e
Fix forgotten import of function.
niconoe- 3983d21
Better usage of PHPStan API.
niconoe- 3998efd
Code clean up.
niconoe- 7e0aeb0
Refactor thanks to @VincentLanglet + add new test cases.
niconoe- b348d10
Make unit tests complient with PHP 7.4.
niconoe- 84367f3
Apply comments.
niconoe- 191f1a3
Try to make unit test OK with PHP 7.4.
niconoe- 5b0796f
Try to make unit test OK with PHP 7.4.
niconoe- ff4f572
Add lots of unit tests and combinations to cover all kinds of types.
niconoe- 8567e3a
Remove forced type mixed on PHPUnit test to be compliant with PHP 7.4.
niconoe- 7c44caa
Simplify some type detection.
niconoe- 7c7379e
Fix deprecated RequiresPhp attribute.
niconoe- 48b0b46
Simplify comparisions.
niconoe- f24e1e2
Removing mutants.
niconoe- aa4d70a
Simplify method `canStringBeSanitized`.
niconoe- File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the 2 mutations here, I don't know how to kill them.
I want to find a data-set where only the
$inputType->isSuperTypeOf($type)->yes()part toogles, which implies that such data-set must produce the following statements:$exactTypeis notnull$hasOptions->maybe()isfalse(not a big deal)$this->isValidationFilter($filterValue) istrue`$inputType->equals($type)isfalse.Also, as the body of this
ifstatement implies a possible change of the$typeto return by adding it the$defaultType, it means that$exactTypemust not be$defaultTypetoo (or the whole condition would have no effect, and mutants are still alive).Now, regarding how
$exactTypeis set to something different fromdefaultTypeand$this->isValidationFilter(…)must betrue, the data-set MUST be viafilter_var(???, FILTER_VALIDATE_(BOOLEAN|INT|FLOAT), ???)(Please note that my PR was only about caring of the flag
FILTER_FLAG_EMPTY_STRING_NULLwhich has no effect when used along one of the 3 validators identified, so I'm pretty sure the mutants to kill are not alive due to my changes, but anyway, let's say I'm a mutant killer 😆 )About FILTER_VALIDATE_BOOLEAN, as we don't want
$exactTypeto be$defaultType, the only data-set possible to search is when$inIS a boolean. Such situation produce that$exactType === $inputType === $type, therefore$inputType->equals($type)is alwaystrue. So this filterValue does not allow me to kill the mutant (no data-set possible).About FILTER_VALIDATE_FLOAT, searched data-set would be
$inistrueor an integer (float would lead to the same outcome than any boolean withFILTER_VALIDATE_BOOLEANandnullwould lead to$defaultType). In such data-set,$exactType(and therefore,$type) would be a Float or a ConstantFloat. But as$inputType as trueis never a super-type of ConstantFloat, nor$inputType as intis never a super-type of Float, there is no way to toogle$inputType->isSuperTypeOf($type)->yes()from any possible data-set. This leads to a dead-end.Finally, about FILTER_VALIDATE_INT, long story short,
$exactTypeis a different type from$inputTypeor$defaultTypeonly when:$in === true=> implies$typeto be a ConstantInteger andtrueis never a super-type of a constant integer, therefore no data-set is possible$in is a floatwhich value matches its "integer" value => implies$typeto be an integer and a float is never a super-type of an integer, therefore no sata-set is possible$in is a numerical constant string=> implies$typeto be an integer and a string is never a super-type of an integer, therefore no data-set is possible.I really do have the feeling that finding a data-set that could kill the mutants is not possible here 😢 .