diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php index 8495f9d83..bdcf83415 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php @@ -41,7 +41,6 @@ use Psalm\Type\Atomic; use Psalm\Type\Atomic\Scalar; use Psalm\Type\Atomic\TArray; use Psalm\Type\Atomic\TDependentListKey; -use Psalm\Type\Atomic\TEmpty; use Psalm\Type\Atomic\TFalse; use Psalm\Type\Atomic\TGenericObject; use Psalm\Type\Atomic\TIntRange; @@ -502,16 +501,11 @@ class ForeachAnalyzer $always_non_empty_array = false; - if ($iterator_atomic_type instanceof Scalar || - $iterator_atomic_type instanceof TVoid - ) { + if ($iterator_atomic_type instanceof Scalar || $iterator_atomic_type instanceof TVoid) { $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 - ) { + } elseif ($iterator_atomic_type instanceof TObject || $iterator_atomic_type instanceof TMixed) { $has_valid_iterator = true; $value_type = Type::getMixed(); $key_type = Type::getMixed(); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayAnalyzer.php index 7db0f8132..bfee36f3a 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayAnalyzer.php @@ -188,7 +188,6 @@ class ArrayAnalyzer if (!$atomic_key_type instanceof TString && !$atomic_key_type instanceof TInt && !$atomic_key_type instanceof TArrayKey - && !$atomic_key_type instanceof TMixed && !$atomic_key_type instanceof TTemplateParam && !( $atomic_key_type instanceof TObjectWithProperties diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php index f39bf696d..407c6d044 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php @@ -1214,11 +1214,7 @@ class AssignmentAnalyzer && !$assign_value_type->hasArrayAccessInterface($codebase) ) { if ($assign_value_type->hasArray()) { - if (($assign_value_atomic_type instanceof TFalse - && $assign_value_type->ignore_falsable_issues) - || ($assign_value_atomic_type instanceof TNull - && $assign_value_type->ignore_nullable_issues) - ) { + if ($assign_value_atomic_type instanceof TFalse && $assign_value_type->ignore_falsable_issues) { // do nothing } elseif (IssueBuffer::accepts( new PossiblyInvalidArrayAccess( diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonComparisonOpAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonComparisonOpAnalyzer.php index 1f99b1d9d..c43811152 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonComparisonOpAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonComparisonOpAnalyzer.php @@ -87,22 +87,6 @@ class NonComparisonOpAnalyzer return; } - if ($stmt instanceof PhpParser\Node\Expr\BinaryOp\BitwiseXor) { - if ($stmt_left_type->hasBool() || $stmt_right_type->hasBool()) { - $statements_analyzer->node_data->setType($stmt, Type::getInt()); - } - - BinaryOpAnalyzer::addDataFlow( - $statements_analyzer, - $stmt, - $stmt->left, - $stmt->right, - 'xor' - ); - - return; - } - if ($stmt instanceof PhpParser\Node\Expr\BinaryOp\LogicalXor) { if ($stmt_left_type->hasBool() || $stmt_right_type->hasBool()) { $statements_analyzer->node_data->setType($stmt, Type::getBool()); @@ -146,25 +130,5 @@ class NonComparisonOpAnalyzer return; } - - if ($stmt instanceof PhpParser\Node\Expr\BinaryOp\BitwiseOr) { - ArithmeticOpAnalyzer::analyze( - $statements_analyzer, - $statements_analyzer->node_data, - $stmt->left, - $stmt->right, - $stmt, - $result_type, - $context - ); - - BinaryOpAnalyzer::addDataFlow( - $statements_analyzer, - $stmt, - $stmt->left, - $stmt->right, - 'or' - ); - } } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php index 225aa21b2..1fa7cdf11 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php @@ -677,7 +677,7 @@ class FunctionCallAnalyzer extends CallAnalyzer $function_call_info->function_exists = true; $has_valid_function_call_type = true; - } elseif ($var_type_part instanceof TMixed || $var_type_part instanceof TTemplateParam) { + } elseif ($var_type_part instanceof TMixed) { $has_valid_function_call_type = true; IssueBuffer::maybeAdd( diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php index 8f4ab9dde..2affd843f 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php @@ -169,12 +169,6 @@ class ArrayMapReturnTypeProvider implements FunctionReturnTypeProviderInterface $function_call_arg->value->items[1]->value->value, [] ); - } elseif ($variable_atomic_type instanceof TTemplateParamClass) { - $fake_method_call = new VirtualStaticCall( - $function_call_arg->value->items[0]->value, - $function_call_arg->value->items[1]->value->value, - [] - ); } } diff --git a/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php b/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php index 109923c61..6f35b1ff3 100644 --- a/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php @@ -395,10 +395,6 @@ class AtomicTypeComparator } foreach ($input_type_part->as->getAtomicTypes() as $input_as_type_part) { - if ($input_as_type_part instanceof TNull && $container_type_part instanceof TNull) { - continue; - } - if (self::isContainedBy( $codebase, $input_as_type_part, diff --git a/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php b/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php index a790a7155..12b1dd951 100644 --- a/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php @@ -89,9 +89,7 @@ class ScalarTypeComparator } if ($container_type_part instanceof TNonspecificLiteralString - && ($input_type_part instanceof TLiteralString - || $input_type_part instanceof TNonspecificLiteralString - || $input_type_part instanceof TNonEmptyNonspecificLiteralString) + && ($input_type_part instanceof TLiteralString || $input_type_part instanceof TNonspecificLiteralString) ) { return true; } diff --git a/src/Psalm/Internal/Type/TypeCombiner.php b/src/Psalm/Internal/Type/TypeCombiner.php index 4cdc543fc..66762c19f 100644 --- a/src/Psalm/Internal/Type/TypeCombiner.php +++ b/src/Psalm/Internal/Type/TypeCombiner.php @@ -53,7 +53,6 @@ use Psalm\Type\Atomic\TScalar; use Psalm\Type\Atomic\TString; use Psalm\Type\Atomic\TTemplateParam; use Psalm\Type\Atomic\TTemplateParamClass; -use Psalm\Type\Atomic\TTraitString; use Psalm\Type\Atomic\TTrue; use Psalm\Type\Union; use UnexpectedValueException; @@ -1050,28 +1049,7 @@ class TypeCombiner $combination->strings = null; } else { - $has_non_literal_class_string = false; - - $shared_classlikes = $codebase ? self::getSharedTypes($combination, $codebase) : []; - - foreach ($combination->strings as $string_type) { - if (!$string_type instanceof TLiteralClassString) { - $has_non_literal_class_string = true; - break; - } - } - - if ($has_non_literal_class_string || - !$type instanceof TClassString - ) { - $combination->value_types[$type_key] = new TString(); - } else { - if (isset($shared_classlikes[$type->as]) && $type->as_type) { - $combination->class_string_types[$type->as] = $type->as_type; - } else { - $combination->class_string_types['object'] = new TObject(); - } - } + $combination->value_types[$type_key] = new TString(); } } else { $combination->value_types[$type_key] = $type; @@ -1079,13 +1057,6 @@ class TypeCombiner } 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 - ) { - $combination->value_types['trait-string'] = $combination->value_types['string']; - $combination->value_types['class-string'] = $type; - - unset($combination->value_types['string']); } elseif (get_class($combination->value_types['string']) !== get_class($type)) { if (get_class($type) === TNonEmptyString::class && get_class($combination->value_types['string']) === TNumericString::class diff --git a/src/Psalm/Type/Reconciler.php b/src/Psalm/Type/Reconciler.php index 48e2e0b48..f67cdbf1a 100644 --- a/src/Psalm/Type/Reconciler.php +++ b/src/Psalm/Type/Reconciler.php @@ -732,7 +732,6 @@ class Reconciler 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 || $existing_key_type_part instanceof TObject || ($existing_key_type_part instanceof TNamedObject && strtolower($existing_key_type_part->value) === 'stdclass') diff --git a/tests/TestCase.php b/tests/TestCase.php index a34e8e477..f48b50cc9 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -15,7 +15,6 @@ use Psalm\Internal\Type\TypeTokenizer; use Psalm\IssueBuffer; use Psalm\Tests\Internal\Provider\FakeParserCacheProvider; use Psalm\Type\Union; -use RuntimeException; use Throwable; use function array_filter; @@ -151,15 +150,7 @@ class TestCase extends BaseTestCase */ protected function getTestName($withDataSet = true): string { - $name = parent::getName($withDataSet); - /** - * @psalm-suppress TypeDoesNotContainNull PHPUnit 8.2 made it non-nullable again - */ - if (null === $name) { - throw new RuntimeException('anonymous test - shouldn\'t happen'); - } - - return $name; + return $this->getName($withDataSet); } /**