Skip to content

Commit

Permalink
Improve error messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Oct 19, 2020
1 parent 497fb7c commit ef69d0b
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/Psalm/Type/Reconciler.php
Expand Up @@ -818,10 +818,6 @@ protected static function triggerIssueForImpossible(
$not = !$not;
}

if ($not) {
$assertion = '!' . $assertion;
}

$existing_var_atomic_types = $existing_var_type->getAtomicTypes();

$from_docblock = $existing_var_type->from_docblock
Expand All @@ -834,7 +830,7 @@ protected static function triggerIssueForImpossible(
new RedundantConditionGivenDocblockType(
'Docblock-defined type ' . $old_var_type_string
. ' for ' . $key
. ' is always ' . $assertion,
. ' is ' . ($not ? 'never ' : 'always ') . $assertion,
$code_location,
$old_var_type_string . ' ' . $safe_assertion
),
Expand All @@ -847,7 +843,7 @@ protected static function triggerIssueForImpossible(
new RedundantCondition(
'Type ' . $old_var_type_string
. ' for ' . $key
. ' is always ' . $assertion,
. ' is ' . ($not ? 'never ' : 'always ') . $assertion,
$code_location,
$old_var_type_string . ' ' . $safe_assertion
),
Expand All @@ -862,7 +858,7 @@ protected static function triggerIssueForImpossible(
new DocblockTypeContradiction(
'Docblock-defined type ' . $old_var_type_string
. ' for ' . $key
. ' is never ' . $assertion,
. ' is ' . ($not ? 'always ' : 'never ') . $assertion,
$code_location,
$old_var_type_string . ' ' . $safe_assertion
),
Expand All @@ -871,7 +867,7 @@ protected static function triggerIssueForImpossible(
// fall through
}
} else {
if ($assertion === 'null') {
if ($assertion === 'null' && !$not) {
$issue = new TypeDoesNotContainNull(
'Type ' . $old_var_type_string
. ' for ' . $key
Expand All @@ -883,7 +879,7 @@ protected static function triggerIssueForImpossible(
$issue = new TypeDoesNotContainType(
'Type ' . $old_var_type_string
. ' for ' . $key
. ' is never ' . $assertion,
. ' is ' . ($not ? 'always ' : 'never ') . $assertion,
$code_location,
$old_var_type_string . ' ' . $safe_assertion
);
Expand Down

0 comments on commit ef69d0b

Please sign in to comment.