mirror of
https://github.com/danog/psalm.git
synced 2024-11-29 20:28:59 +01:00
Promote CircularReference from exception to issue
This commit is contained in:
parent
50074bfab1
commit
2f5b05887b
@ -86,6 +86,7 @@
|
||||
<xs:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element name="AbstractInstantiation" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="AssignmentToVoid" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="CircularReference" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="ContinueOutsideLoop" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="ConflictingReferenceConstraint" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="DeprecatedClass" type="IssueHandlerType" minOccurs="0" />
|
||||
|
@ -4,8 +4,8 @@ namespace Psalm\Checker;
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Exception;
|
||||
use Psalm\Exception\CircularReferenceException;
|
||||
use Psalm\FileManipulation\FunctionDocblockManipulator;
|
||||
use Psalm\Issue\CircularReference;
|
||||
use Psalm\Issue\PossiblyUnusedMethod;
|
||||
use Psalm\Issue\UnusedClass;
|
||||
use Psalm\Issue\UnusedMethod;
|
||||
@ -547,9 +547,16 @@ class ProjectChecker
|
||||
}
|
||||
|
||||
if (isset($dependent_classlikes[strtolower($storage->name)])) {
|
||||
throw new CircularReferenceException(
|
||||
'Circular reference discovered when loading ' . $storage->name
|
||||
);
|
||||
if ($storage->location && IssueBuffer::accepts(
|
||||
new CircularReference(
|
||||
'Circular reference discovered when loading ' . $storage->name,
|
||||
$storage->location
|
||||
)
|
||||
)) {
|
||||
// fall through
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$storage_provider = $this->classlike_storage_provider;
|
||||
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
namespace Psalm\Exception;
|
||||
|
||||
class CircularReferenceException extends CodeException
|
||||
{
|
||||
}
|
6
src/Psalm/Issue/CircularReference.php
Normal file
6
src/Psalm/Issue/CircularReference.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
namespace Psalm\Issue;
|
||||
|
||||
class CircularReference extends CodeError
|
||||
{
|
||||
}
|
@ -238,6 +238,11 @@ class ClassTest extends TestCase
|
||||
}',
|
||||
'error_message' => 'LessSpecificReturnStatement',
|
||||
],
|
||||
'circularReference' => [
|
||||
'<?php
|
||||
class A extends A {}',
|
||||
'error_message' => 'CircularReference',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -324,6 +324,13 @@ class ClosureTest extends TestCase
|
||||
$take_string(42);',
|
||||
'error_message' => 'InvalidScalarArgument',
|
||||
],
|
||||
'missingClosureReturnType' => [
|
||||
'<?php
|
||||
$a = function() {
|
||||
return "foo";
|
||||
}',
|
||||
'error_message' => 'MissingClosureReturnType',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user