From 2f5b05887b92e4302d2221758f48bfed5b989dbb Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Fri, 22 Dec 2017 18:56:59 +0100 Subject: [PATCH] Promote CircularReference from exception to issue --- config.xsd | 1 + src/Psalm/Checker/ProjectChecker.php | 15 +++++++++++---- .../Exception/CircularReferenceException.php | 6 ------ src/Psalm/Issue/CircularReference.php | 6 ++++++ tests/ClassTest.php | 5 +++++ tests/ClosureTest.php | 7 +++++++ 6 files changed, 30 insertions(+), 10 deletions(-) delete mode 100644 src/Psalm/Exception/CircularReferenceException.php create mode 100644 src/Psalm/Issue/CircularReference.php diff --git a/config.xsd b/config.xsd index fe7e6a8b7..7aac4c502 100644 --- a/config.xsd +++ b/config.xsd @@ -86,6 +86,7 @@ + diff --git a/src/Psalm/Checker/ProjectChecker.php b/src/Psalm/Checker/ProjectChecker.php index 4a6207160..0b066dcd6 100644 --- a/src/Psalm/Checker/ProjectChecker.php +++ b/src/Psalm/Checker/ProjectChecker.php @@ -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; diff --git a/src/Psalm/Exception/CircularReferenceException.php b/src/Psalm/Exception/CircularReferenceException.php deleted file mode 100644 index 7031105a5..000000000 --- a/src/Psalm/Exception/CircularReferenceException.php +++ /dev/null @@ -1,6 +0,0 @@ - 'LessSpecificReturnStatement', ], + 'circularReference' => [ + ' 'CircularReference', + ], ]; } } diff --git a/tests/ClosureTest.php b/tests/ClosureTest.php index 5824bdc47..cb82c1db9 100644 --- a/tests/ClosureTest.php +++ b/tests/ClosureTest.php @@ -324,6 +324,13 @@ class ClosureTest extends TestCase $take_string(42);', 'error_message' => 'InvalidScalarArgument', ], + 'missingClosureReturnType' => [ + ' 'MissingClosureReturnType', + ], ]; } }