mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Complain about unevaluated code in more concrete fashion
This commit is contained in:
parent
b80628b1c4
commit
e0e92785f8
@ -166,6 +166,7 @@
|
||||
<xs:element name="UnimplementedInterfaceMethod" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="UnrecognizedExpression" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="UnrecognizedStatement" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="UnevaluatedCode" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="UnusedVariable" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="UnusedClass" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="UnusedMethod" type="IssueHandlerType" minOccurs="0" />
|
||||
|
@ -18,6 +18,7 @@ use Psalm\Exception\FileIncludeException;
|
||||
use Psalm\Issue\ContinueOutsideLoop;
|
||||
use Psalm\Issue\InvalidGlobal;
|
||||
use Psalm\Issue\InvalidNamespace;
|
||||
use Psalm\Issue\UnevaluatedCode;
|
||||
use Psalm\Issue\UnrecognizedStatement;
|
||||
use Psalm\IssueBuffer;
|
||||
use Psalm\StatementsSource;
|
||||
@ -98,8 +99,17 @@ class StatementsChecker extends SourceChecker implements StatementsSource
|
||||
if ($has_returned && !($stmt instanceof PhpParser\Node\Stmt\Nop) &&
|
||||
!($stmt instanceof PhpParser\Node\Stmt\InlineHTML)
|
||||
) {
|
||||
echo('Warning: Expressions after return/throw/continue in ' .
|
||||
$this->getCheckedFileName() . ' on line ' . $stmt->getLine() . PHP_EOL);
|
||||
if ($context->count_references) {
|
||||
if (IssueBuffer::accepts(
|
||||
new UnevaluatedCode(
|
||||
'Expressions after return/throw/continue',
|
||||
new CodeLocation($this->source, $stmt)
|
||||
),
|
||||
$this->source->getSuppressedIssues()
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
6
src/Psalm/Issue/UnevaluatedCode.php
Normal file
6
src/Psalm/Issue/UnevaluatedCode.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
namespace Psalm\Issue;
|
||||
|
||||
class UnevaluatedCode extends CodeError
|
||||
{
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user