Skip to content

Commit

Permalink
Be more explicit about negation
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Oct 19, 2020
1 parent eee562c commit 497fb7c
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 54 deletions.
24 changes: 17 additions & 7 deletions src/Psalm/Internal/Type/AssertionReconciler.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,8 @@ private static function refine(
$old_var_type_string,
$key,
$assertion,
!$negated,
true,
$negated,
$code_location,
$suppressed_issues
);
Expand All @@ -574,7 +575,8 @@ private static function refine(
$old_var_type_string,
$key,
$assertion,
!$negated,
true,
$negated,
$code_location,
$suppressed_issues
);
Expand Down Expand Up @@ -1025,7 +1027,8 @@ private static function handleLiteralEquality(
$old_var_type_string,
$var_id,
$assertion,
$negated xor $can_be_equal,
$can_be_equal,
$negated,
$code_location,
$suppressed_issues
);
Expand All @@ -1039,6 +1042,7 @@ private static function handleLiteralEquality(
$old_var_type_string,
$var_id,
$assertion,
true,
$negated,
$code_location,
$suppressed_issues
Expand Down Expand Up @@ -1072,7 +1076,8 @@ private static function handleLiteralEquality(
$old_var_type_string,
$var_id,
$assertion,
$negated xor $can_be_equal,
$can_be_equal,
$negated,
$code_location,
$suppressed_issues
);
Expand Down Expand Up @@ -1166,7 +1171,8 @@ private static function handleLiteralEquality(
$old_var_type_string,
$var_id,
$assertion,
$negated xor $can_be_equal,
$can_be_equal,
$negated,
$code_location,
$suppressed_issues
);
Expand All @@ -1187,6 +1193,7 @@ private static function handleLiteralEquality(
$old_var_type_string,
$var_id,
$assertion,
false,
$negated,
$code_location,
$suppressed_issues
Expand Down Expand Up @@ -1228,7 +1235,8 @@ private static function handleLiteralEquality(
$old_var_type_string,
$var_id,
$assertion,
$negated xor $can_be_equal,
$can_be_equal,
$negated,
$code_location,
$suppressed_issues
);
Expand All @@ -1242,6 +1250,7 @@ private static function handleLiteralEquality(
$old_var_type_string,
$var_id,
$assertion,
false,
$negated,
$code_location,
$suppressed_issues
Expand Down Expand Up @@ -1275,7 +1284,8 @@ private static function handleLiteralEquality(
$old_var_type_string,
$var_id,
$assertion,
$negated xor $can_be_equal,
$can_be_equal,
$negated,
$code_location,
$suppressed_issues
);
Expand Down
10 changes: 7 additions & 3 deletions src/Psalm/Internal/Type/NegatedAssertionReconciler.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ public static function reconcile(
$old_var_type_string,
$key,
'!=' . $assertion,
!$negated,
true,
$negated,
$code_location,
$suppressed_issues
);
Expand All @@ -276,6 +277,7 @@ public static function reconcile(
$old_var_type_string,
$key,
'!' . $assertion,
false,
$negated,
$code_location,
$suppressed_issues
Expand Down Expand Up @@ -381,7 +383,8 @@ private static function handleLiteralNegatedEquality(
$old_var_type_string,
$key,
'!' . $assertion,
$negated xor !$did_remove_type,
!$did_remove_type,
$negated,
$code_location,
$suppressed_issues
);
Expand All @@ -400,7 +403,8 @@ private static function handleLiteralNegatedEquality(
$old_var_type_string,
$key,
'!=' . $assertion,
!$negated,
true,
$negated,
$code_location,
$suppressed_issues
);
Expand Down
57 changes: 38 additions & 19 deletions src/Psalm/Internal/Type/SimpleAssertionReconciler.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,8 @@ private static function reconcileNonEmptyCountable(
$old_var_type_string,
$key,
'non-empty-countable',
$negated xor !$did_remove_type,
!$did_remove_type,
$negated,
$code_location,
$suppressed_issues
);
Expand Down Expand Up @@ -596,7 +597,8 @@ private static function reconcilePositiveNumeric(
$old_var_type_string,
$key,
'positive-numeric',
$negated xor !$did_remove_type,
!$did_remove_type,
$negated,
$code_location,
$suppressed_issues
);
Expand Down Expand Up @@ -700,7 +702,8 @@ private static function reconcileHasMethod(
$old_var_type_string,
$key,
'object with method ' . $method_name,
$negated xor !$did_remove_type,
!$did_remove_type,
$negated,
$code_location,
$suppressed_issues
);
Expand Down Expand Up @@ -791,7 +794,8 @@ private static function reconcileString(
$old_var_type_string,
$key,
'string',
$negated xor !$did_remove_type,
!$did_remove_type,
$negated,
$code_location,
$suppressed_issues
);
Expand Down Expand Up @@ -885,7 +889,8 @@ private static function reconcileInt(
$old_var_type_string,
$key,
'int',
$negated xor !$did_remove_type,
!$did_remove_type,
$negated,
$code_location,
$suppressed_issues
);
Expand Down Expand Up @@ -963,7 +968,8 @@ private static function reconcileBool(
$old_var_type_string,
$key,
'bool',
$negated xor !$did_remove_type,
!$did_remove_type,
$negated,
$code_location,
$suppressed_issues
);
Expand Down Expand Up @@ -1037,7 +1043,8 @@ private static function reconcileScalar(
$old_var_type_string,
$key,
'scalar',
$negated xor !$did_remove_type,
!$did_remove_type,
$negated,
$code_location,
$suppressed_issues
);
Expand Down Expand Up @@ -1128,7 +1135,8 @@ private static function reconcileNumeric(
$old_var_type_string,
$key,
'numeric',
$negated xor !$did_remove_type,
!$did_remove_type,
$negated,
$code_location,
$suppressed_issues
);
Expand Down Expand Up @@ -1212,7 +1220,8 @@ private static function reconcileObject(
$old_var_type_string,
$key,
'object',
$negated xor !$did_remove_type,
!$did_remove_type,
$negated,
$code_location,
$suppressed_issues
);
Expand Down Expand Up @@ -1268,7 +1277,8 @@ private static function reconcileResource(
$old_var_type_string,
$key,
'resource',
$negated xor !$did_remove_type,
!$did_remove_type,
$negated,
$code_location,
$suppressed_issues
);
Expand Down Expand Up @@ -1338,7 +1348,8 @@ private static function reconcileCountable(
$old_var_type_string,
$key,
'countable',
$negated xor !$did_remove_type,
!$did_remove_type,
$negated,
$code_location,
$suppressed_issues
);
Expand Down Expand Up @@ -1397,7 +1408,8 @@ private static function reconcileIterable(
$old_var_type_string,
$key,
'iterable',
$negated xor !$did_remove_type,
!$did_remove_type,
$negated,
$code_location,
$suppressed_issues
);
Expand Down Expand Up @@ -1541,7 +1553,8 @@ private static function reconcileTraversable(
$old_var_type_string,
$key,
'Traversable',
$negated xor !$did_remove_type,
!$did_remove_type,
$negated,
$code_location,
$suppressed_issues
);
Expand Down Expand Up @@ -1613,7 +1626,8 @@ private static function reconcileArray(
$old_var_type_string,
$key,
'array',
$negated xor !$did_remove_type,
!$did_remove_type,
$negated,
$code_location,
$suppressed_issues
);
Expand Down Expand Up @@ -1731,7 +1745,8 @@ private static function reconcileList(
$old_var_type_string,
$key,
'array',
$negated xor !$did_remove_type,
!$did_remove_type,
$negated,
$code_location,
$suppressed_issues
);
Expand Down Expand Up @@ -1801,7 +1816,8 @@ private static function reconcileStringArrayAccess(
$old_var_type_string,
$key,
'string-array-access',
!$negated,
true,
$negated,
$code_location,
$suppressed_issues
);
Expand Down Expand Up @@ -1860,7 +1876,8 @@ private static function reconcileIntArrayAccess(
$old_var_type_string,
$key,
'int-or-string-array-access',
!$negated,
true,
$negated,
$code_location,
$suppressed_issues
);
Expand Down Expand Up @@ -1956,7 +1973,8 @@ private static function reconcileCallable(
$old_var_type_string,
$key,
'callable',
$negated xor !$did_remove_type,
!$did_remove_type,
$negated,
$code_location,
$suppressed_issues
);
Expand Down Expand Up @@ -2269,7 +2287,8 @@ function (Type\Union $t): bool {
$old_var_type_string,
$key,
$assertion,
$negated xor !$did_remove_type,
!$did_remove_type,
$negated,
$code_location,
$suppressed_issues
);
Expand Down
Loading

0 comments on commit 497fb7c

Please sign in to comment.