Page MenuHomePhorge
Diviner libphutil Tech Docs PhutilLibraryMapBuilder

final class PhutilLibraryMapBuilder
libphutil Technical Documentation (libphutil Library System)

Build maps of libphutil libraries. libphutil uses the library map to locate and load classes and functions in the library.

Tasks

Mapping libphutil Libraries

  • public function __construct($root) — Create a new map builder for a library.
  • public function setSubprocessLimit($limit) — Control subprocess parallelism limit. Use `--limit` to set this.
  • public function buildMap() — Get the map of symbols in this library, analyzing the library to build it if necessary.
  • public function buildFileSymbolMap() — Get the map of files in this library, analyzing the library to build it if necessary.
  • public function buildAndWriteMap() — Build and update the library map.

Path Management

Symbol Analysis and Caching

  • private function loadSymbolCache() — Load the library symbol cache, if it exists and is readable and valid.
  • private function writeSymbolCache($symbol_map, $source_map) — Write a symbol map to disk cache.
  • public function dropSymbolCache() — Drop the symbol cache, forcing a clean rebuild.
  • private function buildSymbolAnalysisFuture($file) — Build a future which returns a `extract-symbols.php` analysis of a source file.

Source Management

  • private function loadSourceFileMap() — Build a map of all source files in a library to hashes of their content. Returns an array like this:
  • private function buildLibraryMap($symbol_map) — Convert the symbol analysis of all the source files in the library into a library map.
  • private function writeLibraryMap($library_map) — Write a finalized library map.

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 __construct($root)

Create a new map builder for a library.

Parameters
string$rootPath to the library root.
Return
this//Implicit.//

public function setSubprocessLimit($limit)

Control subprocess parallelism limit. Use --limit to set this.

Parameters
int$limitMaximum number of subprocesses to run in parallel.
Return
this

public function buildMap()

Get the map of symbols in this library, analyzing the library to build it if necessary.

Return
map<string, wild>Information about symbols in this library.

public function buildFileSymbolMap()

Get the map of files in this library, analyzing the library to build it if necessary.

Returns a map of file paths to information about symbols used and defined in the file.

Return
map<string, wild>Information about files in this library.

public function buildAndWriteMap()

Build and update the library map.

Return
void

private function getPath($path)

Get the path to some file in the library.

Parameters
string$pathA library-relative path. If omitted, returns the library root path.
Return
stringAn absolute path.

private function getPathForSymbolCache()

Get the path to the symbol cache file.

Return
stringAbsolute path to symbol cache.

private function getPathForLibraryMap()

Get the path to the map file.

Return
stringAbsolute path to the library map.

private function getPathForLibraryInit()

Get the path to the library init file.

Return
stringAbsolute path to the library init file

private function loadSymbolCache()

Load the library symbol cache, if it exists and is readable and valid.

Return
dictMap of content hashes to cache of output from `extract-symbols.php`.

private function writeSymbolCache($symbol_map, $source_map)

Write a symbol map to disk cache.

Parameters
dict$symbol_mapSymbol map of relative paths to symbols.
dict$source_mapSource map (like @{method:loadSourceFileMap}).
Return
void

public function dropSymbolCache()

Drop the symbol cache, forcing a clean rebuild.

Return
this

private function buildSymbolAnalysisFuture($file)

Build a future which returns a extract-symbols.php analysis of a source file.

Parameters
string$fileRelative path to the source file to analyze.
Return
FutureAnalysis future.

private static function newExtractSymbolsFuture($flags, $paths)

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

public static function newBuiltinMap()

This method is not documented.
Return
wild

private function loadSourceFileMap()

Build a map of all source files in a library to hashes of their content. Returns an array like this:

array(
  'src/parser/ExampleParser.php' => '60b725f10c9c85c70d97880dfe8191b3',
  // ...
);
Return
dictMap of library-relative paths to content hashes.

private function buildLibraryMap($symbol_map)

Convert the symbol analysis of all the source files in the library into a library map.

Parameters
dict$symbol_mapSymbol analysis of all source files.
Return
dictLibrary map.

private function writeLibraryMap($library_map)

Write a finalized library map.

Parameters
dict$library_mapLibrary map structure to write.
Return
void

private function analyzeLibrary()

Analyze the library, generating the file and symbol maps.

Return
void