mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Elevate trait mismatch issues in PHP 8.0
This commit is contained in:
parent
956199c688
commit
698d50c87a
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user