Page MenuHomePhorge
Diviner Arcanist Tech Docs ArcanistXHPASTLinter

final class ArcanistXHPASTLinter
Arcanist Technical Documentation (Lint)

Uses XHPAST to apply lint rules to PHP.

Tasks

Human Readable Information

Runtime State

Executing Linters

Sharing Parse Trees

  • final protected function getXHPASTLinter() — Get the linter object which is responsible for building parse trees.
  • final protected function buildSharedFutures($paths) — Build futures on this linter, for use and to share with other linters.
  • final protected function releaseSharedFutures($paths) — Release futures on this linter which are no longer in use elsewhere.
  • final protected function getXHPASTTreeForPath($path) — Get a path's tree from the responsible linter.
  • final protected function getXHPASTExceptionForPath($path) — Get a path's parse exception from the responsible linter.

Other Methods

Methods

public function __get($name)
Inherited

This method is not documented.
Parameters
$name
Return
wild

public function __set($name, $value)
Inherited

This method is not documented.
Parameters
$name
$value
Return
wild

public function current()
Inherited

This method is not documented.
Return
wild

public function key()
Inherited

This method is not documented.
Return
wild

public function next()
Inherited

This method is not documented.
Return
wild

public function rewind()
Inherited

This method is not documented.
Return
wild

public function valid()
Inherited

This method is not documented.
Return
wild

private function throwOnAttemptedIteration()
Inherited

This method is not documented.
Return
wild

public function getPhobjectClassConstant($key, $byte_limit)
Inherited

Phobject

Read the value of a class constant.

This is the same as just typing self::CONSTANTNAME, but throws a more useful message if the constant is not defined and allows the constant to be limited to a maximum length.

Parameters
string$keyName of the constant.
int|null$byte_limitMaximum number of bytes permitted in the value.
Return
stringValue of the constant.

public function getInfoURI()
Inherited

ArcanistLinter

Return an optional informative URI where humans can learn more about this linter.

For most linters, this should return a link to the project home page. This is shown on arc linters.

Return
string|nullOptionally, return an informative URI.

public function getInfoDescription()

ArcanistLinter

Return a brief human-readable description of the linter.

These should be a line or two, and are shown on arc linters.

ArcanistXHPASTLinter
This method is not documented.
Return
string|nullOptionally, return a brief human-readable description.

public function getAdditionalInformation()

ArcanistLinter

Return arbitrary additional information.

Linters can use this method to provide arbitrary additional information to be included in the output of arc linters.

ArcanistXHPASTLinter
This method is not documented.
Return
map<string, string>A mapping of header to body content for the additional information sections.

public function getInfoName()

ArcanistLinter

Return a human-readable linter name.

These are used by arc linters, and can let you give a linter a more presentable name.

ArcanistXHPASTLinter
This method is not documented.
Return
stringHuman-readable linter name.

final public function getActivePath()
Inherited

This method is not documented.
Return
wild

final public function setActivePath($path)
Inherited

This method is not documented.
Parameters
$path
Return
wild

final public function setEngine($engine)
Inherited

This method is not documented.
Parameters
ArcanistLintEngine$engine
Return
wild

final protected function getEngine()
Inherited

This method is not documented.
Return
wild

final public function setLinterID($id)
Inherited

ArcanistLinter

Set the internal ID for this linter.

This ID is assigned automatically by the ArcanistLintEngine.

Parameters
string$idUnique linter ID.
Return
this

final public function getLinterID()
Inherited

ArcanistLinter

Get the internal ID for this linter.

Retrieves an internal linter ID managed by the ArcanistLintEngine. This ID is a unique scalar which distinguishes linters in a list.

Return
stringUnique linter ID.

public function willLintPaths($paths)
Inherited

ArcanistLinter

Hook called before a list of paths are linted.

Parallelizable linters can start multiple requests in parallel here, to improve performance. They can implement didLintPaths() to collect results.

Linters which are not parallelizable should normally ignore this callback and implement lintPath() instead.

Parameters
list<string>$pathsA list of paths to be linted
Return
void

final public function lintPath($path)
Inherited

ArcanistLinter

Hook called for each path to be linted.

Linters which are not parallelizable can do work here.

Linters which are parallelizable may want to ignore this callback and implement willLintPaths() and didLintPaths() instead.

Parameters
string$pathPath to lint.
Return
void

public function didLintPaths($paths)
Inherited

ArcanistLinter

Hook called after a list of paths are linted.

Parallelizable linters can collect results here.

Linters which are not paralleizable should normally ignore this callback and implement lintPath() instead.

Parameters
list<string>$pathsA list of paths which were linted.
Return
void

public function getLinterPriority()
Inherited

This method is not documented.
Return
wild

public function setCustomSeverityMap($map)
Inherited

This method is not documented.
Parameters
array$map
Return
wild

public function addCustomSeverityMap($map)
Inherited

This method is not documented.
Parameters
array$map
Return
wild

public function setCustomSeverityRules($rules)
Inherited

This method is not documented.
Parameters
array$rules
Return
wild

final public function getProjectRoot()
Inherited

This method is not documented.
Return
wild

final public function getOtherLocation($offset, $path)
Inherited

This method is not documented.
Parameters
$offset
$path
Return
wild

final public function stopAllLinters()
Inherited

This method is not documented.
Return
wild

final public function didStopAllLinters()
Inherited

This method is not documented.
Return
wild

final public function addPath($path)
Inherited

This method is not documented.
Parameters
$path
Return
wild

final public function setPaths($paths)
Inherited

This method is not documented.
Parameters
array$paths
Return
wild

private function filterPaths($paths)
Inherited

ArcanistLinter

Filter out paths which this linter doesn't act on (for example, because they are binaries and the linter doesn't apply to binaries).

Parameters
list<string>$paths
Return
list<string>

final public function getPaths()
Inherited

This method is not documented.
Return
wild

final public function addData($path, $data)
Inherited

This method is not documented.
Parameters
$path
$data
Return
wild

final protected function getData($path)
Inherited

This method is not documented.
Parameters
$path
Return
wild

final public function getCacheVersion()
Inherited

This method is not documented.
Return
wild

final public function getLintMessageFullCode($short_code)
Inherited

This method is not documented.
Parameters
$short_code
Return
wild

final public function getLintMessageSeverity($code)
Inherited

This method is not documented.
Parameters
$code
Return
wild

protected function getDefaultMessageSeverity($code)
Inherited

This method is not documented.
Parameters
$code
Return
wild

final public function isMessageEnabled($code)
Inherited

This method is not documented.
Parameters
$code
Return
wild

final public function getLintMessageName($code)
Inherited

This method is not documented.
Parameters
$code
Return
wild

final protected function addLintMessage($message)
Inherited

This method is not documented.
Parameters
ArcanistLintMessage$message
Return
wild

final public function getLintMessages()
Inherited

This method is not documented.
Return
wild

final public function raiseLintAtLine($line, $char, $code, $description, $original, $replacement)
Inherited

This method is not documented.
Parameters
$line
$char
$code
$description
$original
$replacement
Return
wild

final public function raiseLintAtPath($code, $desc)
Inherited

This method is not documented.
Parameters
$code
$desc
Return
wild

final public function raiseLintAtOffset($offset, $code, $description, $original, $replacement)
Inherited

This method is not documented.
Parameters
$offset
$code
$description
$original
$replacement
Return
wild

public function canRun()
Inherited

This method is not documented.
Return
wild

public function getLinterName()

This method is not documented.
Return
wild

public function getVersion()

This method is not documented.
Return
wild

final protected function isCodeEnabled($code)
Inherited

This method is not documented.
Parameters
$code
Return
wild

public function getLintSeverityMap()

This method is not documented.
Return
wild

public function getLintNameMap()

This method is not documented.
Return
wild

public function getCacheGranularity()
Inherited

This method is not documented.
Return
wild

public function getLinterConfigurationName()

ArcanistLinter

If this linter is selectable via .arclint configuration files, return a short, human-readable name to identify it. For example, "jshint" or "pep8".

If you do not implement this method, the linter will not be selectable through .arclint files.

ArcanistXHPASTLinter
This method is not documented.
Return
wild
This method is not documented.
Return
wild

public function setLinterConfigurationValue($key, $value)

This method is not documented.
Parameters
$key
$value
Return
wild

protected function canCustomizeLintSeverities()
Inherited

This method is not documented.
Return
wild

protected function shouldLintBinaryFiles()
Inherited

This method is not documented.
Return
wild

protected function shouldLintDeletedFiles()
Inherited

This method is not documented.
Return
wild

protected function shouldLintDirectories()
Inherited

This method is not documented.
Return
wild

protected function shouldLintSymbolicLinks()
Inherited

This method is not documented.
Return
wild

protected function getLintCodeFromLinterConfigurationKey($code)
Inherited

ArcanistLinter

Map a configuration lint code to an arc lint code. Primarily, this is intended for validation, but can also be used to normalize case or otherwise be more permissive in accepted inputs.

If the code is not recognized, you should throw an exception.

Parameters
string$codeCode specified in configuration.
Return
stringNormalized code to use in severity map.

final protected function buildFutures($paths)
Inherited

This method is not documented.
Parameters
array$paths
Return
wild

protected function resolveFuture($path, $future)

This method is not documented.
Parameters
$path
Future$future
Return
wild

final protected function getFuturesLimit()
Inherited

This method is not documented.
Return
wild

protected function didResolveLinterFutures($futures)
Inherited

ArcanistFutureLinter

Hook for cleaning up resources.

This is invoked after a block of futures resolve, and allows linters to discard or clean up any shared resources they no longer need.

Parameters
map<string,$futuresFuture> Map of paths to resolved futures.
Return
void

final public function raiseLintAtToken($token, $code, $desc, $replace)
Inherited

This method is not documented.
Parameters
XHPASTToken$token
$code
$desc
$replace
Return
wild

final public function raiseLintAtNode($node, $code, $desc, $replace)
Inherited

This method is not documented.
Parameters
XHPASTNode$node
$code
$desc
$replace
Return
wild

final protected function getXHPASTLinter()
Inherited

ArcanistBaseXHPASTLinter

Get the linter object which is responsible for building parse trees.

When the engine specifies that several XHPAST linters should execute, we designate one of them as the one which will actually build parse trees. The other linters share trees, so they don't have to recompute them.

Roughly, the first linter to execute elects itself as the builder. Subsequent linters request builds and retrieve results from it.

Return
ArcanistBaseXHPASTLinterResponsible linter.

final protected function buildSharedFutures($paths)
Inherited

ArcanistBaseXHPASTLinter

Build futures on this linter, for use and to share with other linters.

Parameters
list<string>$pathsPaths to build futures for.
Return
list<ExecFuture>Futures.

final protected function releaseSharedFutures($paths)
Inherited

ArcanistBaseXHPASTLinter

Release futures on this linter which are no longer in use elsewhere.

Parameters
list<string>$pathsPaths to release futures for.
Return
void

final protected function getXHPASTTreeForPath($path)
Inherited

ArcanistBaseXHPASTLinter

Get a path's tree from the responsible linter.

Parameters
string$pathPath to retrieve tree for.
Return
XHPASTTree|nullTree, or null if unparseable.

final protected function getXHPASTExceptionForPath($path)
Inherited

ArcanistBaseXHPASTLinter

Get a path's parse exception from the responsible linter.

Parameters
string$pathPath to retrieve exception for.
Return
Exception|nullParse exception, if available.

protected function getFunctionCalls($root, $function_names)
Inherited

ArcanistBaseXHPASTLinter

Retrieve all calls to some specified function(s).

Returns all descendant nodes which represent a function call to one of the specified functions.

Parameters
XHPASTNode$rootRoot node.
list<string>$function_namesFunction names.
Return
AASTNodeList

public function getSuperGlobalNames()
Inherited

This method is not documented.
Return
wild

public function __construct()

This method is not documented.
Return
this//Implicit.//

public function __clone()

This method is not documented.
Return
wild

public function setRules($rules)

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.

Parameters
list<ArcanistXHPASTLinterRule>$rules
Return
this