mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Fix #714 - fix trait class constants
This commit is contained in:
parent
8f9b4098bc
commit
77d4629896
@ -242,15 +242,17 @@ abstract class ClassLikeChecker extends SourceChecker implements StatementsSourc
|
|||||||
$interface_exists = $codebase->interfaceExists($fq_class_name);
|
$interface_exists = $codebase->interfaceExists($fq_class_name);
|
||||||
|
|
||||||
if (!$class_exists && !$interface_exists) {
|
if (!$class_exists && !$interface_exists) {
|
||||||
if (IssueBuffer::accepts(
|
if (!$codebase->classlikes->traitExists($fq_class_name)) {
|
||||||
new UndefinedClass(
|
if (IssueBuffer::accepts(
|
||||||
'Class or interface ' . $fq_class_name . ' does not exist',
|
new UndefinedClass(
|
||||||
$code_location,
|
'Class or interface ' . $fq_class_name . ' does not exist',
|
||||||
$fq_class_name
|
$code_location,
|
||||||
),
|
$fq_class_name
|
||||||
$suppressed_issues
|
),
|
||||||
)) {
|
$suppressed_issues
|
||||||
return false;
|
)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -508,6 +508,16 @@ class ClassLikes
|
|||||||
return $storage->parent_interfaces;
|
return $storage->parent_interfaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $fq_trait_name
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function traitExists($fq_trait_name)
|
||||||
|
{
|
||||||
|
return $this->hasFullyQualifiedTraitName($fq_trait_name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether or not a class has the correct casing
|
* Determine whether or not a class has the correct casing
|
||||||
*
|
*
|
||||||
|
@ -522,6 +522,20 @@ class TraitTest extends TestCase
|
|||||||
}
|
}
|
||||||
}',
|
}',
|
||||||
],
|
],
|
||||||
|
'traitClassConst' => [
|
||||||
|
'<?php
|
||||||
|
trait A {
|
||||||
|
public function foo(): string {
|
||||||
|
return B::class;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
trait B {}
|
||||||
|
|
||||||
|
class C {
|
||||||
|
use A;
|
||||||
|
}'
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user