mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Introduce MissingDependency issue, separate from UndefinedClass
Ref #511
This commit is contained in:
parent
88ca7d2fa7
commit
09f86ceee7
@ -146,6 +146,7 @@
|
||||
<xs:element name="MissingClosureParamType" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="MissingClosureReturnType" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="MissingConstructor" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="MissingDependency" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="MissingFile" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="MissingParamType" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="MissingPropertyType" type="IssueHandlerType" minOccurs="0" />
|
||||
|
@ -700,6 +700,19 @@ class A {
|
||||
}
|
||||
```
|
||||
|
||||
### MissingDependency
|
||||
|
||||
Emitted when referencing a class that doesn’t exist
|
||||
|
||||
```php
|
||||
/**
|
||||
* @psalm-suppress UndefinedClass
|
||||
*/
|
||||
class A extends B {}
|
||||
|
||||
$a = new A();
|
||||
```
|
||||
|
||||
### MissingDocblockType
|
||||
|
||||
Emitted when a docblock is present, but the type is missing or badly formatted
|
||||
|
@ -10,6 +10,7 @@ use Psalm\FileManipulation\FileManipulationBuffer;
|
||||
use Psalm\Issue\DuplicateClass;
|
||||
use Psalm\Issue\InaccessibleProperty;
|
||||
use Psalm\Issue\InvalidClass;
|
||||
use Psalm\Issue\MissingDependency;
|
||||
use Psalm\Issue\ReservedWord;
|
||||
use Psalm\Issue\UndefinedClass;
|
||||
use Psalm\IssueBuffer;
|
||||
@ -271,7 +272,7 @@ abstract class ClassLikeChecker extends SourceChecker implements StatementsSourc
|
||||
|
||||
foreach ($class_storage->invalid_dependencies as $dependency_class_name) {
|
||||
if (IssueBuffer::accepts(
|
||||
new UndefinedClass(
|
||||
new MissingDependency(
|
||||
$fq_class_name . ' depends on class or interface '
|
||||
. $dependency_class_name . ' that does not exist',
|
||||
$code_location
|
||||
|
@ -84,6 +84,7 @@ class ArrayFetchChecker
|
||||
|
||||
if ($keyed_array_var_id && isset($context->vars_in_scope[$keyed_array_var_id])) {
|
||||
$stmt->inferredType = clone $context->vars_in_scope[$keyed_array_var_id];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
6
src/Psalm/Issue/MissingDependency.php
Normal file
6
src/Psalm/Issue/MissingDependency.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
namespace Psalm\Issue;
|
||||
|
||||
class MissingDependency extends CodeIssue
|
||||
{
|
||||
}
|
@ -244,7 +244,7 @@ class MethodCallTest extends TestCase
|
||||
class B extends A {}
|
||||
|
||||
$b = new B();',
|
||||
'error_message' => 'UndefinedClass - src/somefile.php:7',
|
||||
'error_message' => 'MissingDependency - src/somefile.php:7',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user