feature: allow creating custom linting rules using PHP.
This would be epic indeed. Do you have the same in mind for analyzer? One of the things I love doing most is creating PHPStan rules to steer a project in a certain direction. Having the full type context is really good to have in order to not have a rule producing false positives.
for linter, you won't have type information, that's just how the linter is.
But i think if we managed to get this implemented, we would also be able to implement custom heuristic checks for the analyzer using PHP, i.e ability to post process statements, expressions, class-like, and function-like nodes after they have been fully analyzed, which would give you access to the type information.
from discord:
would be pretty nice for organizations to be able to create their own rules using php something along the lines of:
<?php use Mago\Ast\Node; use Mago\Ast\ExitConstruct; use Mago\Reporting\Issue; Mago\Linter\rule('no-exit', function(Node $node): ?Issue { if (!$node instanceof ExitConstruct) { return null; } return Issue::error("we said no exit!")->withAnnotation( Annotation::primary($node->span())->withMessage("Here!") ); });[linter] custom-rules = ["rules/no-exit.php"]