Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 018d83e

Browse files
committed
fix php7 expectations
1 parent 83a87f9 commit 018d83e

File tree

4 files changed

+51
-12
lines changed

4 files changed

+51
-12
lines changed

‎tests/PHPStan/Analyser/data/equal.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,12 @@ public function doFoo(string $a, int $b, float $c): void
152152
assertType('false', 'a' != 'a');
153153
assertType('true', 'a' != 'b');
154154

155-
assertType('false', $b == 'a');
155+
// assertType('false', $b == 'a'); depends on PHP version
156156
assertType('bool', $a == 1);
157157
assertType('true', 1 == 1);
158158
assertType('false', 1 == 0);
159159

160-
assertType('false', $c == 'a');
160+
// assertType('false', $c == 'a'); depends on PHP version
161161
assertType('bool', $c == 1);
162162
assertType('bool', $c == 1.2);
163163
assertType('true', 1.2 == 1.2);

‎tests/PHPStan/Analyser/data/loose-comparisons.php‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,6 @@ public function looseFloat(
797797
assertType('bool', $float == $minusOneStr);
798798
assertType('bool', $float == $null);
799799
assertType('false', $float == $emptyArr);
800-
assertType('false', $float == $phpStr);
801800
assertType('false', $float == $emptyStr);
802801
assertType('false', $float == []);
803802
assertType('false', $float == $arr);
@@ -809,7 +808,6 @@ public function looseFloat(
809808
assertType('bool', $float == new \stdClass());
810809
assertType('bool', $float == $unionMaybeNumeric);
811810
assertType('bool', $float == $unionNumbers);
812-
assertType('false', $float == $unionStrings);
813811
}
814812

815813
/**
@@ -925,8 +923,6 @@ public function looseInt(
925923
assertType('bool', $int == $minusOneStr);
926924
assertType('bool', $int == $null);
927925
assertType('false', $int == $emptyArr);
928-
assertType('false', $int == $phpStr);
929-
assertType('false', $int == $emptyStr);
930926
assertType('bool', $int == $float);
931927
assertType('false', $int == []);
932928
assertType('false', $int == $arr);
@@ -938,7 +934,6 @@ public function looseInt(
938934
assertType('bool', $int == new \stdClass());
939935
assertType('bool', $int == $unionMaybeNumeric);
940936
assertType('bool', $int == $unionNumbers);
941-
assertType('false', $int == $unionStrings);
942937
}
943938

944939
/**
@@ -1279,7 +1274,6 @@ public function looseUnion(
12791274
assertType('true', $unionMaybeNumeric == $true);
12801275
assertType('false', $unionMaybeNumeric == $false);
12811276
assertType('false', $unionMaybeNumeric == $one);
1282-
assertType('false', $unionMaybeNumeric == $zero);
12831277
assertType('false', $unionMaybeNumeric == 10);
12841278
assertType('false', $unionMaybeNumeric == $minusOne);
12851279
assertType('false', $unionMaybeNumeric == $oneStr);
@@ -1329,7 +1323,6 @@ public function looseUnion(
13291323
assertType('true', $unionStrings == $true);
13301324
assertType('false', $unionStrings == $false);
13311325
assertType('false', $unionStrings == $one);
1332-
assertType('false', $unionStrings == $zero);
13331326
assertType('false', $unionStrings == 10);
13341327
assertType('false', $unionStrings == $minusOne);
13351328
assertType('false', $unionStrings == $oneStr);
@@ -1352,7 +1345,6 @@ public function looseUnion(
13521345
assertType('bool', $unionMaybeArray == $true);
13531346
assertType('bool', $unionMaybeArray == $false);
13541347
assertType('false', $unionMaybeArray == $one);
1355-
assertType('false', $unionMaybeArray == $zero);
13561348
assertType('false', $unionMaybeArray == 10);
13571349
assertType('false', $unionMaybeArray == $minusOne);
13581350
assertType('false', $unionMaybeArray == $oneStr);

‎tests/PHPStan/Analyser/data/loose-const-comparison-php7.php‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,21 @@
88
* @param int<1, 100> $nonZeroRange
99
* @param 'abc' $nonNumericString
1010
* @param 'a'|'b'|'c' $unionStrings
11+
* @param 'a'|'123'|'123.23' $unionMaybeNumeric
12+
* @param 0 $zero
13+
* @param 'a'|'123'|123|array $unionMaybeArray
1114
* @return void
1215
*/
13-
function doFoo($nonZeroRange, int $i, float $f, string $nonNumericString, $unionStrings) {
16+
function doFoo(
17+
$nonZeroRange,
18+
int $i,
19+
float $f,
20+
string $nonNumericString,
21+
$unionStrings,
22+
$unionMaybeNumeric,
23+
$zero,
24+
$unionMaybeArray,
25+
) {
1426
assertType('true', 0 == "0");
1527
assertType('true', 0 == "0.0");
1628
assertType('true', 0 == "foo");
@@ -52,4 +64,15 @@ function doFoo($nonZeroRange, int $i, float $f, string $nonNumericString, $union
5264
assertType('bool', $unionStrings == $f);
5365
assertType('bool', $f == $unionStrings);
5466

67+
assertType('bool', $i == '');
68+
assertType('bool', '' == $i);
69+
70+
assertType('bool', $unionMaybeNumeric == $zero);
71+
assertType('bool', $zero == $unionMaybeNumeric);
72+
73+
assertType('true', $unionStrings == $zero);
74+
assertType('true', $zero == $unionStrings);
75+
76+
assertType('bool', $unionMaybeArray == $zero);
77+
assertType('bool', $zero == $unionMaybeArray);
5578
}

‎tests/PHPStan/Analyser/data/loose-const-comparison-php8.php‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,21 @@
88
* @param int<1, 100> $nonZeroRange
99
* @param 'abc' $nonNumericString
1010
* @param 'a'|'b'|'c' $unionStrings
11+
* @param 'a'|'123'|'123.23' $unionMaybeNumeric
12+
* @param 0 $zero
13+
* @param 'a'|'123'|123|array $unionMaybeArray
1114
* @return void
1215
*/
13-
function doFoo($nonZeroRange, int $i, float $f, string $nonNumericString, $unionStrings) {
16+
function doFoo(
17+
$nonZeroRange,
18+
int $i,
19+
float $f,
20+
string $nonNumericString,
21+
$unionStrings,
22+
$unionMaybeNumeric,
23+
$zero,
24+
$unionMaybeArray,
25+
) {
1426
assertType('true', 0 == "0");
1527
assertType('true', 0 == "0.0");
1628
assertType('false', 0 == "foo");
@@ -51,4 +63,16 @@ function doFoo($nonZeroRange, int $i, float $f, string $nonNumericString, $union
5163

5264
assertType('false', $unionStrings == $f);
5365
assertType('false', $f == $unionStrings);
66+
67+
assertType('false', $i == '');
68+
assertType('false', '' == $i);
69+
70+
assertType('false', $unionMaybeNumeric == $zero);
71+
assertType('false', $zero == $unionMaybeNumeric);
72+
73+
assertType('false', $unionStrings == $zero);
74+
assertType('false', $zero == $unionStrings);
75+
76+
assertType('false', $unionMaybeArray == $zero);
77+
assertType('false', $zero == $unionMaybeArray);
5478
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /