Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove always true/false conditions #7229

Merged
merged 3 commits into from
Dec 27, 2021
Merged

remove always true/false conditions #7229

merged 3 commits into from
Dec 27, 2021

Conversation

orklah
Copy link
Collaborator

@orklah orklah commented Dec 27, 2021

I'll explain them in review mode

$invalid_iterator_types[] = $iterator_atomic_type->getKey();

$value_type = Type::getMixed();
} elseif ($iterator_atomic_type instanceof TObject ||
$iterator_atomic_type instanceof TMixed ||
$iterator_atomic_type instanceof TEmpty
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TEmpty is already covered by Scalar on the previous if

@@ -188,7 +188,6 @@ public static function analyze(
if (!$atomic_key_type instanceof TString
&& !$atomic_key_type instanceof TInt
&& !$atomic_key_type instanceof TArrayKey
&& !$atomic_key_type instanceof TMixed
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TMixed is handled above

@@ -1214,11 +1214,7 @@ private static function analyzeDestructuringAssignment(
&& !$assign_value_type->hasArrayAccessInterface($codebase)
) {
if ($assign_value_type->hasArray()) {
if (($assign_value_atomic_type instanceof TFalse
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TNull is handled above

@@ -87,22 +87,6 @@ public static function analyze(
return;
}

if ($stmt instanceof PhpParser\Node\Expr\BinaryOp\BitwiseXor) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BitwiseXor is handled above

@@ -146,25 +130,5 @@ public static function analyze(

return;
}

if ($stmt instanceof PhpParser\Node\Expr\BinaryOp\BitwiseOr) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BitwiseOr is handled above

@@ -89,9 +89,7 @@ public static function isContainedBy(
}

if ($container_type_part instanceof TNonspecificLiteralString
&& ($input_type_part instanceof TLiteralString
|| $input_type_part instanceof TNonspecificLiteralString
|| $input_type_part instanceof TNonEmptyNonspecificLiteralString)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TNonEmptyNonspecificLiteralString is a child of TNonspecificLiteralString just above

@@ -1061,9 +1061,7 @@ private static function scrapeStringProperties(
}
}

if ($has_non_literal_class_string ||
!$type instanceof TClassString
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$type instanceof TClassString was handled in another branch

@@ -1079,13 +1077,6 @@ private static function scrapeStringProperties(
} elseif (get_class($combination->value_types['string']) !== TString::class) {
if (get_class($type) === TString::class) {
$combination->value_types['string'] = $type;
} elseif ($combination->value_types['string'] instanceof TTraitString
&& $type instanceof TClassString
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -732,7 +732,6 @@ private static function getValueForKey(
if ($existing_key_type_part instanceof TNull) {
$class_property_type = Type::getNull();
} elseif ($existing_key_type_part instanceof TMixed
|| $existing_key_type_part instanceof TTemplateParam
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continued just above

/**
* @psalm-suppress TypeDoesNotContainNull PHPUnit 8.2 made it non-nullable again
*/
if (null === $name) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-nullable since 8.2 and Psalm 4 requires PHPunit 9

@orklah orklah added the release:internal The PR will be included in 'Internal changes' section of the release notes label Dec 27, 2021
Copy link
Collaborator

@weirdan weirdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@orklah orklah merged commit 3828db5 into vimeo:master Dec 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:internal The PR will be included in 'Internal changes' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants