Changeset View
Changeset View
Standalone View
Standalone View
support/lib/extract-symbols.php
#!/usr/bin/env php | #!/usr/bin/env php | ||||
<?php | <?php | ||||
// We have to do this first before we load any symbols, because we define the | // We have to do this first before we load any symbols, because we define the | ||||
// built-in symbol list through introspection. | // built-in symbol list through introspection. | ||||
$builtins = phutil_symbols_get_builtins(); | $builtins = phutil_symbols_get_builtins(); | ||||
$root = dirname(dirname(dirname(__FILE__))); | $root = dirname(dirname(__DIR__)); | ||||
require_once $root.'/support/init/init-script.php'; | require_once $root.'/support/init/init-script.php'; | ||||
$args = new PhutilArgumentParser($argv); | $args = new PhutilArgumentParser($argv); | ||||
$args->setTagline(pht('identify symbols in a PHP source file')); | $args->setTagline(pht('identify symbols in a PHP source file')); | ||||
$args->setSynopsis(<<<EOHELP | $args->setSynopsis(<<<EOHELP | ||||
**extract-symbols.php** [__options__] __path.php__ | **extract-symbols.php** [__options__] __path.php__ | ||||
Identify the symbols (clases, functions and interfaces) in a PHP | Identify the symbols (clases, functions and interfaces) in a PHP | ||||
source file. Symbols are divided into "have" symbols (symbols the file | source file. Symbols are divided into "have" symbols (symbols the file | ||||
▲ Show 20 Lines • Show All 539 Lines • ▼ Show 20 Lines | function phutil_symbols_get_builtins() { | ||||
$builtin['classes'] = get_declared_classes(); | $builtin['classes'] = get_declared_classes(); | ||||
$builtin['interfaces'] = get_declared_interfaces(); | $builtin['interfaces'] = get_declared_interfaces(); | ||||
$funcs = get_defined_functions(); | $funcs = get_defined_functions(); | ||||
$builtin['functions'] = $funcs['internal']; | $builtin['functions'] = $funcs['internal']; | ||||
$compat = json_decode( | $compat = json_decode( | ||||
file_get_contents( | file_get_contents( | ||||
dirname(__FILE__).'/../../resources/php/symbol-information.json'), | __DIR__.'/../../resources/php/symbol-information.json'), | ||||
true); | true); | ||||
foreach (array('functions', 'classes', 'interfaces') as $type) { | foreach (array('functions', 'classes', 'interfaces') as $type) { | ||||
// Developers may not have every extension that a library potentially uses | // Developers may not have every extension that a library potentially uses | ||||
// installed. We supplement the list of declared functions and classes with | // installed. We supplement the list of declared functions and classes with | ||||
// a list of known extension functions to avoid raising false positives just | // a list of known extension functions to avoid raising false positives just | ||||
// because you don't have pcntl, etc. | // because you don't have pcntl, etc. | ||||
$extensions = array_keys($compat[$type]); | $extensions = array_keys($compat[$type]); | ||||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0