mirror of
https://github.com/danog/psalm-insane-comparison.git
synced 2024-11-26 20:14:46 +01:00
commit
659164543e
@ -27,5 +27,10 @@
|
|||||||
"require-dev": {
|
"require-dev": {
|
||||||
"vimeo/psalm": "^4.0",
|
"vimeo/psalm": "^4.0",
|
||||||
"nikic/php-parser": "^4.0"
|
"nikic/php-parser": "^4.0"
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"allow-plugins": {
|
||||||
|
"composer/package-versions-deprecated": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,30 +5,29 @@ declare(strict_types=1);
|
|||||||
namespace Orklah\PsalmInsaneComparison\Hooks;
|
namespace Orklah\PsalmInsaneComparison\Hooks;
|
||||||
|
|
||||||
use PhpParser\Node\Expr;
|
use PhpParser\Node\Expr;
|
||||||
use Psalm\Codebase;
|
|
||||||
use Psalm\CodeLocation;
|
use Psalm\CodeLocation;
|
||||||
use Psalm\Context;
|
|
||||||
use Psalm\Internal\Type\Comparator\UnionTypeComparator;
|
use Psalm\Internal\Type\Comparator\UnionTypeComparator;
|
||||||
use Psalm\Issue\PluginIssue;
|
use Psalm\Issue\PluginIssue;
|
||||||
use Psalm\IssueBuffer;
|
use Psalm\IssueBuffer;
|
||||||
use Psalm\Plugin\Hook\AfterExpressionAnalysisInterface;
|
use Psalm\Plugin\EventHandler\AfterExpressionAnalysisInterface;
|
||||||
use Psalm\StatementsSource;
|
use Psalm\Plugin\EventHandler\Event\AfterExpressionAnalysisEvent;
|
||||||
use Psalm\Type;
|
use Psalm\Type;
|
||||||
use Psalm\Type\Atomic\TLiteralInt;
|
use Psalm\Type\Atomic\TLiteralInt;
|
||||||
use Psalm\Type\Atomic\TLiteralString;
|
use Psalm\Type\Atomic\TLiteralString;
|
||||||
use Psalm\Type\Atomic\TPositiveInt;
|
use Psalm\Type\Atomic\TPositiveInt;
|
||||||
use Psalm\Type\Atomic\TSingleLetter;
|
|
||||||
|
|
||||||
class InsaneComparisonAnalyzer implements AfterExpressionAnalysisInterface
|
class InsaneComparisonAnalyzer implements AfterExpressionAnalysisInterface
|
||||||
{
|
{
|
||||||
public static function afterExpressionAnalysis(
|
/**
|
||||||
Expr $expr,
|
* Called after an expression has been checked
|
||||||
Context $context,
|
*
|
||||||
StatementsSource $statements_source,
|
* @return null|false
|
||||||
Codebase $codebase,
|
*/
|
||||||
array &$file_replacements = []
|
public static function afterExpressionAnalysis(AfterExpressionAnalysisEvent $event): ?bool
|
||||||
): ?bool
|
|
||||||
{
|
{
|
||||||
|
$expr = $event->getExpr();
|
||||||
|
$statements_source = $event->getStatementsSource();
|
||||||
|
$codebase = $event->getCodebase();
|
||||||
if (!$expr instanceof Expr\BinaryOp\Equal && !$expr instanceof Expr\BinaryOp\NotEqual) {
|
if (!$expr instanceof Expr\BinaryOp\Equal && !$expr instanceof Expr\BinaryOp\NotEqual) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user