1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Promote CircularReference from exception to issue

This commit is contained in:
Matthew Brown 2017-12-22 18:56:59 +01:00
parent 50074bfab1
commit 2f5b05887b
6 changed files with 30 additions and 10 deletions

View File

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

View File

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

View File

@ -1,6 +0,0 @@
<?php
namespace Psalm\Exception;
class CircularReferenceException extends CodeException
{
}

View File

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

View File

@ -238,6 +238,11 @@ class ClassTest extends TestCase
}',
'error_message' => 'LessSpecificReturnStatement',
],
'circularReference' => [
'<?php
class A extends A {}',
'error_message' => 'CircularReference',
],
];
}
}

View File

@ -324,6 +324,13 @@ class ClosureTest extends TestCase
$take_string(42);',
'error_message' => 'InvalidScalarArgument',
],
'missingClosureReturnType' => [
'<?php
$a = function() {
return "foo";
}',
'error_message' => 'MissingClosureReturnType',
],
];
}
}