diff --git a/src/Psalm/Internal/Analyzer/MethodComparator.php b/src/Psalm/Internal/Analyzer/MethodComparator.php index a064be7a1..787af9a8d 100644 --- a/src/Psalm/Internal/Analyzer/MethodComparator.php +++ b/src/Psalm/Internal/Analyzer/MethodComparator.php @@ -73,6 +73,7 @@ class MethodComparator $cased_implementer_method_id, $prevent_method_signature_mismatch, $prevent_abstract_override, + $codebase->php_major_version >= 8, $code_location, $suppressed_issues ); @@ -203,11 +204,13 @@ class MethodComparator string $cased_implementer_method_id, bool $prevent_method_signature_mismatch, bool $prevent_abstract_override, + bool $trait_mismatches_are_fatal, CodeLocation $code_location, array $suppressed_issues ) : void { if ($implementer_visibility > $guide_visibility) { - if ($guide_classlike_storage->is_trait === $implementer_classlike_storage->is_trait + if ($trait_mismatches_are_fatal + || $guide_classlike_storage->is_trait === $implementer_classlike_storage->is_trait || !in_array($guide_classlike_storage->name, $implementer_classlike_storage->used_traits) || $implementer_method_storage->defining_fqcln !== $implementer_classlike_storage->name || (!$implementer_method_storage->abstract @@ -557,7 +560,8 @@ class MethodComparator if (!$is_contained_by) { $config = \Psalm\Config::getInstance(); - if ($guide_classlike_storage->is_trait === $implementer_classlike_storage->is_trait + if ($codebase->php_major_version >= 8 + || $guide_classlike_storage->is_trait === $implementer_classlike_storage->is_trait || !in_array($guide_classlike_storage->name, $implementer_classlike_storage->used_traits) || $implementer_method_storage->defining_fqcln !== $implementer_classlike_storage->name || (!$implementer_method_storage->abstract @@ -851,7 +855,8 @@ class MethodComparator : UnionTypeComparator::isContainedByInPhp($implementer_signature_return_type, $guide_signature_return_type); if (!$is_contained_by) { - if ($guide_classlike_storage->is_trait === $implementer_classlike_storage->is_trait + if ($codebase->php_major_version >= 8 + || $guide_classlike_storage->is_trait === $implementer_classlike_storage->is_trait || !in_array($guide_classlike_storage->name, $implementer_classlike_storage->used_traits) || $implementer_method_storage->defining_fqcln !== $implementer_classlike_storage->name || (!$implementer_method_storage->abstract diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php index 8467a0684..149cd9ec3 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php @@ -171,7 +171,9 @@ class CastAnalyzer return true; } - if ($stmt instanceof PhpParser\Node\Expr\Cast\Unset_) { + if ($stmt instanceof PhpParser\Node\Expr\Cast\Unset_ + && $statements_analyzer->getCodebase()->php_major_version < 8 + ) { if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->expr, $context) === false) { return false; } diff --git a/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php b/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php index 07c15bcf8..8a033c2f9 100644 --- a/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php +++ b/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php @@ -2004,9 +2004,10 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse $class_name_parts = explode('\\', $fq_classlike_name); $class_name = array_pop($class_name_parts); - if ($method_name_lc === strtolower($class_name) && - !isset($class_storage->methods['__construct']) && - strpos($fq_classlike_name, '\\') === false + if ($method_name_lc === strtolower($class_name) + && !isset($class_storage->methods['__construct']) + && strpos($fq_classlike_name, '\\') === false + && $this->codebase->php_major_version < 8 ) { $this->codebase->methods->setDeclaringMethodId( $fq_classlike_name,