Skip to content

Commit

Permalink
Merge pull request #8 from kkmuffme/docblock-configurable
Browse files Browse the repository at this point in the history
configurable: allow fixes for types from docblock
  • Loading branch information
orklah committed Apr 28, 2024
2 parents 0717794 + 2280b85 commit c4e458b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Hooks/StrictEqualityHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use PhpParser\Node\Expr\BinaryOp\Equal;
use PhpParser\Node\Expr\BinaryOp\NotEqual;
use Psalm\CodeLocation;
use Psalm\Config;
use Psalm\FileManipulation;
use Psalm\Issue\PluginIssue;
use Psalm\IssueBuffer;
Expand Down Expand Up @@ -52,7 +53,23 @@ public static function afterExpressionAnalysis(AfterExpressionAnalysisEvent $eve
}

if ($left_type->from_docblock || $right_type->from_docblock) {
return true;// this is risky
$allow_docblock = false;
$config = Config::getInstance();
foreach ($config->getPluginClasses() as $plugin) {
if ($plugin['class'] !== 'Orklah\StrictEquality\Plugin') {
continue;
}

if (isset($plugin['config']->strictEqualityFromDocblock['value']) && (string) $plugin['config']->strictEqualityFromDocblock['value'] === 'true') {
$allow_docblock = true;
}

break;
}

if ($allow_docblock === false) {
return true;
}
}

if (!$left_type->isSingle() || !$right_type->isSingle()) {
Expand Down

0 comments on commit c4e458b

Please sign in to comment.