Changeset View
Changeset View
Standalone View
Standalone View
src/lint/linter/ArcanistXHPASTLinter.php
| <?php | <?php | ||||
| /** | /** | ||||
| * Uses XHPAST to apply lint rules to PHP. | * Uses XHPAST to apply lint rules to PHP. | ||||
| */ | */ | ||||
| final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter { | final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter { | ||||
| private $rules = array(); | private $rules = array(); | ||||
| private $lintNameMap; | private $lintNameMap; | ||||
| private $lintSeverityMap; | private $lintSeverityMap; | ||||
| public function __construct() { | public function __construct() { | ||||
| $this->rules = ArcanistXHPASTLinterRule::loadAllRules(); | $this->setRules(ArcanistXHPASTLinterRule::loadAllRules()); | ||||
| } | } | ||||
| public function __clone() { | public function __clone() { | ||||
| $rules = $this->rules; | $rules = $this->rules; | ||||
| $this->rules = array(); | $this->rules = array(); | ||||
| foreach ($rules as $rule) { | foreach ($rules as $rule) { | ||||
| $this->rules[] = clone $rule; | $this->rules[] = clone $rule; | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * Set the XHPAST linter rules which are enforced by this linter. | |||||
| * | |||||
| * This is primarily useful for unit tests in which it is desirable to test | |||||
| * linter rules in isolation. By default, all linter rules will be enabled. | |||||
| * | |||||
| * @param list<ArcanistXHPASTLinterRule> | |||||
| * @return this | |||||
| */ | |||||
| public function setRules(array $rules) { | |||||
| assert_instances_of($rules, 'ArcanistXHPASTLinterRule'); | |||||
| $this->rules = $rules; | |||||
| return $this; | |||||
| } | |||||
| public function getInfoName() { | public function getInfoName() { | ||||
| return pht('XHPAST Lint'); | return pht('XHPAST Lint'); | ||||
| } | } | ||||
| public function getInfoDescription() { | public function getInfoDescription() { | ||||
| return pht('Use XHPAST to enforce coding conventions on PHP source files.'); | return pht('Use XHPAST to enforce coding conventions on PHP source files.'); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines | |||||