Skip to content

Commit

Permalink
Make error message for truthy/falsy more accurate
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Feb 10, 2022
1 parent 547f11e commit b49b5f1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Expand Up @@ -333,7 +333,7 @@ public static function handleParadoxicalCondition(
if ($type->from_docblock) {
IssueBuffer::maybeAdd(
new DocblockTypeContradiction(
'Operand of type ' . $type->getId() . ' is always false',
'Operand of type ' . $type->getId() . ' is always falsy',
new CodeLocation($statements_analyzer, $stmt),
$type->getId() . ' falsy'
),
Expand All @@ -342,7 +342,7 @@ public static function handleParadoxicalCondition(
} else {
IssueBuffer::maybeAdd(
new TypeDoesNotContainType(
'Operand of type ' . $type->getId() . ' is always false',
'Operand of type ' . $type->getId() . ' is always falsy',
new CodeLocation($statements_analyzer, $stmt),
$type->getId() . ' falsy'
),
Expand All @@ -355,7 +355,7 @@ public static function handleParadoxicalCondition(
if ($type->from_docblock) {
IssueBuffer::maybeAdd(
new RedundantConditionGivenDocblockType(
'Operand of type ' . $type->getId() . ' is always true',
'Operand of type ' . $type->getId() . ' is always truthy',
new CodeLocation($statements_analyzer, $stmt),
$type->getId() . ' falsy'
),
Expand All @@ -364,7 +364,7 @@ public static function handleParadoxicalCondition(
} else {
IssueBuffer::maybeAdd(
new RedundantCondition(
'Operand of type ' . $type->getId() . ' is always true',
'Operand of type ' . $type->getId() . ' is always truthy',
new CodeLocation($statements_analyzer, $stmt),
$type->getId() . ' falsy'
),
Expand Down
2 changes: 1 addition & 1 deletion tests/JsonOutputTest.php
Expand Up @@ -144,7 +144,7 @@ function fooFoo(?string $a, ?string $b): void {
}
}',
'error_count' => 1,
'message' => 'Operand of type non-falsy-string is always true',
'message' => 'Operand of type non-falsy-string is always truthy',
'line' => 4,
'error' => '$b',
],
Expand Down
8 changes: 4 additions & 4 deletions tests/TypeReconciliation/InArrayTest.php
Expand Up @@ -313,7 +313,7 @@ function assertInArray($x, $y) {
return $x;
}',
'error_message' => 'DocblockTypeContradiction - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:29 - Operand of type false is always false',
'error_message' => 'DocblockTypeContradiction - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:29 - Operand of type false is always falsy',
],
'assertNegatedInArrayOfNotIntersectingTypeTriggersRedundantCondition' => [
'code' => '<?php
Expand All @@ -329,7 +329,7 @@ function assertInArray($x, $y) {
throw new \Exception();
}',
'error_message' => 'RedundantConditionGivenDocblockType - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:29 - Operand of type true is always true',
'error_message' => 'RedundantConditionGivenDocblockType - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:29 - Operand of type true is always truthy',
],
'assertInArrayOfNotIntersectingTypeTriggersDocblockTypeContradiction' => [
'code' => '<?php
Expand All @@ -345,7 +345,7 @@ function assertInArray($x, $y) {
throw new \Exception();
}',
'error_message' => 'DocblockTypeContradiction - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:29 - Operand of type false is always false',
'error_message' => 'DocblockTypeContradiction - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:29 - Operand of type false is always falsy',
],
'assertInArrayOfNotIntersectingTypeReturnsTriggersDocblockTypeContradiction' => [
'code' => '<?php
Expand All @@ -361,7 +361,7 @@ function assertInArray($x, $y) {
throw new \Exception();
}',
'error_message' => 'DocblockTypeContradiction - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:29 - Operand of type false is always false',
'error_message' => 'DocblockTypeContradiction - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:29 - Operand of type false is always falsy',
'ignored_issues' => ['RedundantConditionGivenDocblockType'],
],
'inArrayDetectType' => [
Expand Down

0 comments on commit b49b5f1

Please sign in to comment.