Skip to content

Commit

Permalink
Merge pull request #6476 from orklah/alwaysTruthy
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Sep 12, 2021
2 parents f496cca + 96adb96 commit 6f1d438
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
Expand Up @@ -242,7 +242,7 @@ function (Type\Union $_): bool {
// fall through
}
}
} elseif ($cond_type->isTrue()) {
} elseif ($cond_type->isAlwaysTruthy()) {
if ($cond_type->from_docblock) {
if (IssueBuffer::accepts(
new RedundantConditionGivenDocblockType(
Expand Down
Expand Up @@ -284,7 +284,7 @@ public static function parse(
),
'start_offset' => $offset,
'end_offset' => $offset + strlen($imported_type_entry),
'parts' => CommentAnalyzer::splitDocLine($imported_type_entry) ?: []
'parts' => CommentAnalyzer::splitDocLine($imported_type_entry)
];
}

Expand Down
1 change: 1 addition & 0 deletions src/Psalm/Internal/Type/SimpleAssertionReconciler.php
Expand Up @@ -2364,6 +2364,7 @@ function (Type\Union $t): bool {
}
}

/** @psalm-suppress RedundantCondition can be empty after removing above */
if ($existing_var_type->getAtomicTypes()) {
return $existing_var_type;
}
Expand Down
5 changes: 5 additions & 0 deletions src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php
Expand Up @@ -450,6 +450,7 @@ private static function reconcileNull(
}
}

/** @psalm-suppress RedundantCondition can be empty after removing above */
if ($existing_var_type->getAtomicTypes()) {
return $existing_var_type;
}
Expand Down Expand Up @@ -516,6 +517,7 @@ private static function reconcileFalse(
}
}

/** @psalm-suppress RedundantCondition can be empty after removing above */
if ($existing_var_type->getAtomicTypes()) {
return $existing_var_type;
}
Expand Down Expand Up @@ -601,6 +603,7 @@ private static function reconcileFalsyOrEmpty(
$existing_var_type->possibly_undefined = false;
$existing_var_type->possibly_undefined_from_try = false;

/** @psalm-suppress RedundantCondition can be empty after removing above */
if ($existing_var_type->getAtomicTypes()) {
return $existing_var_type;
}
Expand Down Expand Up @@ -826,6 +829,7 @@ private static function reconcileFalsyOrEmpty(
}
}

/** @psalm-suppress RedundantCondition can be empty after removing above */
if ($existing_var_type->getAtomicTypes()) {
return $existing_var_type;
}
Expand Down Expand Up @@ -1569,6 +1573,7 @@ private static function reconcileResource(
}
}

/** @psalm-suppress RedundantCondition can be empty after removing above */
if ($existing_var_type->getAtomicTypes()) {
return $existing_var_type;
}
Expand Down
1 change: 1 addition & 0 deletions src/Psalm/Internal/Type/TemplateStandinTypeReplacer.php
Expand Up @@ -58,6 +58,7 @@ public static function replace(
}
}

/** @psalm-suppress RedundantCondition can be empty after removing above */
if ($new_input_type->getAtomicTypes()) {
$input_type = $new_input_type;
}
Expand Down

0 comments on commit 6f1d438

Please sign in to comment.