-
Notifications
You must be signed in to change notification settings - Fork 542
Test loose comparison on constant types #3755
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
Merged
Merged
Changes from all commits
Commits
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -729,6 +729,8 @@ public function sayInt( | |
array $array, | ||
int $int, | ||
int $intRange, | ||
string $emptyStr, | ||
string $phpStr, | ||
): void | ||
{ | ||
assertType('bool', $int == $true); | ||
|
@@ -747,19 +749,37 @@ public function sayInt( | |
assertType('false', $intRange == $emptyArr); | ||
assertType('false', $intRange == $array); | ||
|
||
assertType('false', 5 == $emptyArr); | ||
assertType('false', $emptyArr == 5); | ||
assertType('false', 5 == $array); | ||
assertType('false', $array == 5); | ||
assertType('false', [] == 5); | ||
assertType('false', 5 == []); | ||
|
||
assertType('false', 5 == $emptyStr); | ||
assertType('false', 5 == $phpStr); | ||
assertType('false', 5 == 'a'); | ||
|
||
assertType('false', $emptyStr == 5); | ||
assertType('false', $phpStr == 5); | ||
assertType('false', 'a' == 5); | ||
Comment on lines
+759
to
+765
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
/** | ||
* @param true|1|"1" $looseOne | ||
* @param false|0|"0" $looseZero | ||
* @param false|1 $constMix | ||
* @param "abc"|"def" $constNonFalsy | ||
* @param array{abc: string, num?: int, nullable: ?string} $arrShape | ||
* @param array{} $emptyArr | ||
*/ | ||
public function sayConstUnion( | ||
$looseOne, | ||
$looseZero, | ||
$constMix, | ||
$constNonFalsy, | ||
array $arrShape, | ||
array $emptyArr | ||
): void | ||
{ | ||
assertType('true', $looseOne == 1); | ||
|
@@ -802,13 +822,22 @@ public function sayConstUnion( | |
assertType('false', $constNonFalsy == "1"); | ||
assertType('false', $constNonFalsy == "0"); | ||
assertType('false', $constNonFalsy == []); | ||
|
||
assertType('false', $emptyArr == $looseOne); | ||
assertType('bool', $emptyArr == $constMix); | ||
assertType('bool', $emptyArr == $looseZero); | ||
Comment on lines
+826
to
+828
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
assertType('bool', $arrShape == $looseOne); | ||
assertType('bool', $arrShape == $constMix); | ||
assertType('bool', $arrShape == $looseZero); | ||
} | ||
|
||
/** | ||
* @param uppercase-string $upper | ||
* @param lowercase-string $lower | ||
* @param array{} $emptyArr | ||
* @param non-empty-array $nonEmptyArr | ||
* @param array{abc: string, num?: int, nullable: ?string} $arrShape | ||
* @param int<10, 20> $intRange | ||
*/ | ||
public function sayIntersection( | ||
|
@@ -818,6 +847,7 @@ public function sayIntersection( | |
array $emptyArr, | ||
array $nonEmptyArr, | ||
array $arr, | ||
array $arrShape, | ||
int $i, | ||
int $intRange, | ||
): void | ||
|
@@ -849,11 +879,24 @@ public function sayIntersection( | |
assertType('false', $nonEmptyArr == $i); | ||
assertType('false', $arr == $intRange); | ||
assertType('false', $nonEmptyArr == $intRange); | ||
assertType('bool', $emptyArr == $nonEmptyArr); // should be false | ||
assertType('false', $emptyArr == $nonEmptyArr); | ||
assertType('false', $nonEmptyArr == $emptyArr); | ||
assertType('bool', $arr == $nonEmptyArr); | ||
assertType('bool', $nonEmptyArr == $arr); | ||
|
||
assertType('false', 5 == $arr); | ||
assertType('false', $arr == 5); | ||
assertType('false', 5 == $emptyArr); | ||
assertType('false', $emptyArr == 5); | ||
assertType('false', 5 == $nonEmptyArr); | ||
assertType('false', $nonEmptyArr == 5); | ||
assertType('false', 5 == $arrShape); | ||
assertType('false', $arrShape == 5); | ||
if (count($arr) > 0) { | ||
assertType('false', 5 == $arr); | ||
assertType('false', $arr == 5); | ||
} | ||
|
||
assertType('bool', '' == $lower); | ||
if ($lower != '') { | ||
assertType('false', '' == $lower); | ||
|
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.
mirrored from
ArrayType