Changeset View
Changeset View
Standalone View
Standalone View
scripts/library/library-symbols.php
- This file was moved from scripts/phutil_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(); | ||||
| require_once dirname(__FILE__).'/__init_script__.php'; | require_once dirname(dirname(__FILE__)).'/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 | ||||
| **phutil_symbols.php** [__options__] __path.php__ | **library-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 | ||||
| declares) and "need" symbols (symbols the file depends on). For example, | declares) and "need" symbols (symbols the file depends on). For example, | ||||
| class declarations are "have" symbols, while object instantiations | class declarations are "have" symbols, while object instantiations | ||||
| with "new X()" are "need" symbols. | with "new X()" are "need" symbols. | ||||
| Dependencies on builtins and symbols marked '@phutil-external-symbol' | Dependencies on builtins and symbols marked '@phutil-external-symbol' | ||||
| in docblocks are omitted without __--all__. | in docblocks are omitted without __--all__. | ||||
| ▲ Show 20 Lines • Show All 497 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_compat_info.json'), | dirname(dirname(__FILE__)).'/../resources/php/php_compat_info.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 51 Lines • Show Last 20 Lines | |||||