Skip to content

Commit 497fb7c

Browse files
committed
Be more explicit about negation
1 parent eee562c commit 497fb7c

File tree

6 files changed

+111
-54
lines changed

6 files changed

+111
-54
lines changed

src/Psalm/Internal/Type/AssertionReconciler.php

+17-7
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,8 @@ private static function refine(
547547
$old_var_type_string,
548548
$key,
549549
$assertion,
550-
!$negated,
550+
true,
551+
$negated,
551552
$code_location,
552553
$suppressed_issues
553554
);
@@ -574,7 +575,8 @@ private static function refine(
574575
$old_var_type_string,
575576
$key,
576577
$assertion,
577-
!$negated,
578+
true,
579+
$negated,
578580
$code_location,
579581
$suppressed_issues
580582
);
@@ -1025,7 +1027,8 @@ private static function handleLiteralEquality(
10251027
$old_var_type_string,
10261028
$var_id,
10271029
$assertion,
1028-
$negated xor $can_be_equal,
1030+
$can_be_equal,
1031+
$negated,
10291032
$code_location,
10301033
$suppressed_issues
10311034
);
@@ -1039,6 +1042,7 @@ private static function handleLiteralEquality(
10391042
$old_var_type_string,
10401043
$var_id,
10411044
$assertion,
1045+
true,
10421046
$negated,
10431047
$code_location,
10441048
$suppressed_issues
@@ -1072,7 +1076,8 @@ private static function handleLiteralEquality(
10721076
$old_var_type_string,
10731077
$var_id,
10741078
$assertion,
1075-
$negated xor $can_be_equal,
1079+
$can_be_equal,
1080+
$negated,
10761081
$code_location,
10771082
$suppressed_issues
10781083
);
@@ -1166,7 +1171,8 @@ private static function handleLiteralEquality(
11661171
$old_var_type_string,
11671172
$var_id,
11681173
$assertion,
1169-
$negated xor $can_be_equal,
1174+
$can_be_equal,
1175+
$negated,
11701176
$code_location,
11711177
$suppressed_issues
11721178
);
@@ -1187,6 +1193,7 @@ private static function handleLiteralEquality(
11871193
$old_var_type_string,
11881194
$var_id,
11891195
$assertion,
1196+
false,
11901197
$negated,
11911198
$code_location,
11921199
$suppressed_issues
@@ -1228,7 +1235,8 @@ private static function handleLiteralEquality(
12281235
$old_var_type_string,
12291236
$var_id,
12301237
$assertion,
1231-
$negated xor $can_be_equal,
1238+
$can_be_equal,
1239+
$negated,
12321240
$code_location,
12331241
$suppressed_issues
12341242
);
@@ -1242,6 +1250,7 @@ private static function handleLiteralEquality(
12421250
$old_var_type_string,
12431251
$var_id,
12441252
$assertion,
1253+
false,
12451254
$negated,
12461255
$code_location,
12471256
$suppressed_issues
@@ -1275,7 +1284,8 @@ private static function handleLiteralEquality(
12751284
$old_var_type_string,
12761285
$var_id,
12771286
$assertion,
1278-
$negated xor $can_be_equal,
1287+
$can_be_equal,
1288+
$negated,
12791289
$code_location,
12801290
$suppressed_issues
12811291
);

src/Psalm/Internal/Type/NegatedAssertionReconciler.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ public static function reconcile(
259259
$old_var_type_string,
260260
$key,
261261
'!=' . $assertion,
262-
!$negated,
262+
true,
263+
$negated,
263264
$code_location,
264265
$suppressed_issues
265266
);
@@ -276,6 +277,7 @@ public static function reconcile(
276277
$old_var_type_string,
277278
$key,
278279
'!' . $assertion,
280+
false,
279281
$negated,
280282
$code_location,
281283
$suppressed_issues
@@ -381,7 +383,8 @@ private static function handleLiteralNegatedEquality(
381383
$old_var_type_string,
382384
$key,
383385
'!' . $assertion,
384-
$negated xor !$did_remove_type,
386+
!$did_remove_type,
387+
$negated,
385388
$code_location,
386389
$suppressed_issues
387390
);
@@ -400,7 +403,8 @@ private static function handleLiteralNegatedEquality(
400403
$old_var_type_string,
401404
$key,
402405
'!=' . $assertion,
403-
!$negated,
406+
true,
407+
$negated,
404408
$code_location,
405409
$suppressed_issues
406410
);

src/Psalm/Internal/Type/SimpleAssertionReconciler.php

+38-19
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,8 @@ private static function reconcileNonEmptyCountable(
494494
$old_var_type_string,
495495
$key,
496496
'non-empty-countable',
497-
$negated xor !$did_remove_type,
497+
!$did_remove_type,
498+
$negated,
498499
$code_location,
499500
$suppressed_issues
500501
);
@@ -596,7 +597,8 @@ private static function reconcilePositiveNumeric(
596597
$old_var_type_string,
597598
$key,
598599
'positive-numeric',
599-
$negated xor !$did_remove_type,
600+
!$did_remove_type,
601+
$negated,
600602
$code_location,
601603
$suppressed_issues
602604
);
@@ -700,7 +702,8 @@ private static function reconcileHasMethod(
700702
$old_var_type_string,
701703
$key,
702704
'object with method ' . $method_name,
703-
$negated xor !$did_remove_type,
705+
!$did_remove_type,
706+
$negated,
704707
$code_location,
705708
$suppressed_issues
706709
);
@@ -791,7 +794,8 @@ private static function reconcileString(
791794
$old_var_type_string,
792795
$key,
793796
'string',
794-
$negated xor !$did_remove_type,
797+
!$did_remove_type,
798+
$negated,
795799
$code_location,
796800
$suppressed_issues
797801
);
@@ -885,7 +889,8 @@ private static function reconcileInt(
885889
$old_var_type_string,
886890
$key,
887891
'int',
888-
$negated xor !$did_remove_type,
892+
!$did_remove_type,
893+
$negated,
889894
$code_location,
890895
$suppressed_issues
891896
);
@@ -963,7 +968,8 @@ private static function reconcileBool(
963968
$old_var_type_string,
964969
$key,
965970
'bool',
966-
$negated xor !$did_remove_type,
971+
!$did_remove_type,
972+
$negated,
967973
$code_location,
968974
$suppressed_issues
969975
);
@@ -1037,7 +1043,8 @@ private static function reconcileScalar(
10371043
$old_var_type_string,
10381044
$key,
10391045
'scalar',
1040-
$negated xor !$did_remove_type,
1046+
!$did_remove_type,
1047+
$negated,
10411048
$code_location,
10421049
$suppressed_issues
10431050
);
@@ -1128,7 +1135,8 @@ private static function reconcileNumeric(
11281135
$old_var_type_string,
11291136
$key,
11301137
'numeric',
1131-
$negated xor !$did_remove_type,
1138+
!$did_remove_type,
1139+
$negated,
11321140
$code_location,
11331141
$suppressed_issues
11341142
);
@@ -1212,7 +1220,8 @@ private static function reconcileObject(
12121220
$old_var_type_string,
12131221
$key,
12141222
'object',
1215-
$negated xor !$did_remove_type,
1223+
!$did_remove_type,
1224+
$negated,
12161225
$code_location,
12171226
$suppressed_issues
12181227
);
@@ -1268,7 +1277,8 @@ private static function reconcileResource(
12681277
$old_var_type_string,
12691278
$key,
12701279
'resource',
1271-
$negated xor !$did_remove_type,
1280+
!$did_remove_type,
1281+
$negated,
12721282
$code_location,
12731283
$suppressed_issues
12741284
);
@@ -1338,7 +1348,8 @@ private static function reconcileCountable(
13381348
$old_var_type_string,
13391349
$key,
13401350
'countable',
1341-
$negated xor !$did_remove_type,
1351+
!$did_remove_type,
1352+
$negated,
13421353
$code_location,
13431354
$suppressed_issues
13441355
);
@@ -1397,7 +1408,8 @@ private static function reconcileIterable(
13971408
$old_var_type_string,
13981409
$key,
13991410
'iterable',
1400-
$negated xor !$did_remove_type,
1411+
!$did_remove_type,
1412+
$negated,
14011413
$code_location,
14021414
$suppressed_issues
14031415
);
@@ -1541,7 +1553,8 @@ private static function reconcileTraversable(
15411553
$old_var_type_string,
15421554
$key,
15431555
'Traversable',
1544-
$negated xor !$did_remove_type,
1556+
!$did_remove_type,
1557+
$negated,
15451558
$code_location,
15461559
$suppressed_issues
15471560
);
@@ -1613,7 +1626,8 @@ private static function reconcileArray(
16131626
$old_var_type_string,
16141627
$key,
16151628
'array',
1616-
$negated xor !$did_remove_type,
1629+
!$did_remove_type,
1630+
$negated,
16171631
$code_location,
16181632
$suppressed_issues
16191633
);
@@ -1731,7 +1745,8 @@ private static function reconcileList(
17311745
$old_var_type_string,
17321746
$key,
17331747
'array',
1734-
$negated xor !$did_remove_type,
1748+
!$did_remove_type,
1749+
$negated,
17351750
$code_location,
17361751
$suppressed_issues
17371752
);
@@ -1801,7 +1816,8 @@ private static function reconcileStringArrayAccess(
18011816
$old_var_type_string,
18021817
$key,
18031818
'string-array-access',
1804-
!$negated,
1819+
true,
1820+
$negated,
18051821
$code_location,
18061822
$suppressed_issues
18071823
);
@@ -1860,7 +1876,8 @@ private static function reconcileIntArrayAccess(
18601876
$old_var_type_string,
18611877
$key,
18621878
'int-or-string-array-access',
1863-
!$negated,
1879+
true,
1880+
$negated,
18641881
$code_location,
18651882
$suppressed_issues
18661883
);
@@ -1956,7 +1973,8 @@ private static function reconcileCallable(
19561973
$old_var_type_string,
19571974
$key,
19581975
'callable',
1959-
$negated xor !$did_remove_type,
1976+
!$did_remove_type,
1977+
$negated,
19601978
$code_location,
19611979
$suppressed_issues
19621980
);
@@ -2269,7 +2287,8 @@ function (Type\Union $t): bool {
22692287
$old_var_type_string,
22702288
$key,
22712289
$assertion,
2272-
$negated xor !$did_remove_type,
2290+
!$did_remove_type,
2291+
$negated,
22732292
$code_location,
22742293
$suppressed_issues
22752294
);

0 commit comments

Comments
 (0)