diff --git a/phpstan.neon.dist b/phpstan.neon.dist index c67aa93fcb04..929ac4409664 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,9 +1,3 @@ -services: - - - class: Utils\PHPStan\CheckUseStatementsAfterLicenseRule - tags: - - phpstan.rules.rule - includes: - phpstan-baseline.php @@ -18,7 +12,6 @@ parameters: - app - system - tests - - utils/src/PHPStan excludePaths: - app/Views/errors/cli/* - app/Views/errors/html/* diff --git a/utils/src/PHPStan/CheckUseStatementsAfterLicenseRule.php b/utils/src/PHPStan/CheckUseStatementsAfterLicenseRule.php deleted file mode 100644 index 4b23d3204ca1..000000000000 --- a/utils/src/PHPStan/CheckUseStatementsAfterLicenseRule.php +++ /dev/null @@ -1,77 +0,0 @@ - - * - * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. - */ - -namespace Utils\PHPStan; - -use PhpParser\Comment\Doc; -use PhpParser\Node; -use PhpParser\Node\Stmt; -use PhpParser\Node\Stmt\Use_; -use PHPStan\Analyser\Scope; -use PHPStan\Rules\IdentifierRuleError; -use PHPStan\Rules\Rule; -use PHPStan\Rules\RuleErrorBuilder; - -/** - * @implements Rule - */ -final class CheckUseStatementsAfterLicenseRule implements Rule -{ - private const ERROR_MESSAGE = 'Use statement must be located after license docblock'; - private const COPYRIGHT_REGEX = '/\* \(c\) CodeIgniter Foundation /m'; - - public function getNodeType(): string - { - return Stmt::class; - } - - /** - * @param Stmt $node - * - * @return list - */ - public function processNode(Node $node, Scope $scope): array - { - $comments = $node->getComments(); - - if ($comments === []) { - return []; - } - - foreach ($comments as $comment) { - if (! $comment instanceof Doc) { - continue; - } - - if (! preg_match(self::COPYRIGHT_REGEX, $comment->getText())) { - continue; - } - - $previous = $node->getAttribute('previous'); - - while ($previous) { - if ($previous instanceof Use_) { - return [ - RuleErrorBuilder::message(self::ERROR_MESSAGE) - ->identifier('codeigniter.useStmtAfterLicense') - ->build(), - ]; - } - - $previous = $previous->getAttribute('previous'); - } - } - - return []; - } -}