Skip to content

Commit ef69d0b

Browse files
committed
Improve error messaging
1 parent 497fb7c commit ef69d0b

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/Psalm/Type/Reconciler.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -818,10 +818,6 @@ protected static function triggerIssueForImpossible(
818818
$not = !$not;
819819
}
820820

821-
if ($not) {
822-
$assertion = '!' . $assertion;
823-
}
824-
825821
$existing_var_atomic_types = $existing_var_type->getAtomicTypes();
826822

827823
$from_docblock = $existing_var_type->from_docblock
@@ -834,7 +830,7 @@ protected static function triggerIssueForImpossible(
834830
new RedundantConditionGivenDocblockType(
835831
'Docblock-defined type ' . $old_var_type_string
836832
. ' for ' . $key
837-
. ' is always ' . $assertion,
833+
. ' is ' . ($not ? 'never ' : 'always ') . $assertion,
838834
$code_location,
839835
$old_var_type_string . ' ' . $safe_assertion
840836
),
@@ -847,7 +843,7 @@ protected static function triggerIssueForImpossible(
847843
new RedundantCondition(
848844
'Type ' . $old_var_type_string
849845
. ' for ' . $key
850-
. ' is always ' . $assertion,
846+
. ' is ' . ($not ? 'never ' : 'always ') . $assertion,
851847
$code_location,
852848
$old_var_type_string . ' ' . $safe_assertion
853849
),
@@ -862,7 +858,7 @@ protected static function triggerIssueForImpossible(
862858
new DocblockTypeContradiction(
863859
'Docblock-defined type ' . $old_var_type_string
864860
. ' for ' . $key
865-
. ' is never ' . $assertion,
861+
. ' is ' . ($not ? 'always ' : 'never ') . $assertion,
866862
$code_location,
867863
$old_var_type_string . ' ' . $safe_assertion
868864
),
@@ -871,7 +867,7 @@ protected static function triggerIssueForImpossible(
871867
// fall through
872868
}
873869
} else {
874-
if ($assertion === 'null') {
870+
if ($assertion === 'null' && !$not) {
875871
$issue = new TypeDoesNotContainNull(
876872
'Type ' . $old_var_type_string
877873
. ' for ' . $key
@@ -883,7 +879,7 @@ protected static function triggerIssueForImpossible(
883879
$issue = new TypeDoesNotContainType(
884880
'Type ' . $old_var_type_string
885881
. ' for ' . $key
886-
. ' is never ' . $assertion,
882+
. ' is ' . ($not ? 'always ' : 'never ') . $assertion,
887883
$code_location,
888884
$old_var_type_string . ' ' . $safe_assertion
889885
);

0 commit comments

Comments
 (0)