1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-29 20:28:59 +01:00

Introduce MissingDependency issue, separate from UndefinedClass

Ref #511
This commit is contained in:
Matthew Brown 2018-02-17 11:36:20 -05:00
parent 88ca7d2fa7
commit 09f86ceee7
6 changed files with 24 additions and 2 deletions

View File

@ -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" />

View File

@ -700,6 +700,19 @@ class A {
}
```
### MissingDependency
Emitted when referencing a class that doesnt 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

View File

@ -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

View File

@ -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;
}

View File

@ -0,0 +1,6 @@
<?php
namespace Psalm\Issue;
class MissingDependency extends CodeIssue
{
}

View File

@ -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',
],
];
}