From 5be656aa57166fbe4416802c9403023bfd9aeff5 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 26 Jul 2012 14:46:53 -0700 Subject: [PATCH] Include extension classes in the builtin list Summary: Just like we ship with a list of extension functions, add a list of extension classes so people stop getting lint errors about DOMDocument just because some linter uses it. Test Plan: Ran "arc lint". Reviewers: vrana, btrahan, codeblock Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D3082 --- scripts/lib/PhutilLibraryMapBuilder.php | 2 +- scripts/php_extension_classes.txt | 1 + scripts/phutil_symbols.php | 33 ++++++++++++++----------- 3 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 scripts/php_extension_classes.txt diff --git a/scripts/lib/PhutilLibraryMapBuilder.php b/scripts/lib/PhutilLibraryMapBuilder.php index 84b95b86..e58fde04 100755 --- a/scripts/lib/PhutilLibraryMapBuilder.php +++ b/scripts/lib/PhutilLibraryMapBuilder.php @@ -37,7 +37,7 @@ final class PhutilLibraryMapBuilder { const LIBRARY_MAP_VERSION = 2; const SYMBOL_CACHE_VERSION_KEY = '__symbol_cache_version__'; - const SYMBOL_CACHE_VERSION = 5; + const SYMBOL_CACHE_VERSION = 6; /* -( Mapping libphutil Libraries )---------------------------------------- */ diff --git a/scripts/php_extension_classes.txt b/scripts/php_extension_classes.txt new file mode 100644 index 00000000..5cdc95ce --- /dev/null +++ b/scripts/php_extension_classes.txt @@ -0,0 +1 @@ +DOMDocument diff --git a/scripts/phutil_symbols.php b/scripts/phutil_symbols.php index 740ce680..9df312f4 100755 --- a/scripts/phutil_symbols.php +++ b/scripts/phutil_symbols.php @@ -410,23 +410,26 @@ if ($args->getArg('ugly')) { function phutil_symbols_get_builtins() { - $builtin_classes = get_declared_classes(); - $builtin_interfaces = get_declared_interfaces(); - $builtin_functions = get_defined_functions(); - $builtin_functions = $builtin_functions['internal']; + $builtin = array(); + $builtin['classes'] = get_declared_classes(); + $builtin['interfaces'] = get_declared_interfaces(); - // Developers may not have every extension that a library potentially uses - // installed. We supplement the list of declared functions with a list of - // known extension functions to avoid raising false positives just because - // you don't have pcntl, etc. - $list = dirname(__FILE__).'/php_extension_functions.txt'; - $extension_functions = file_get_contents($list); - $extension_functions = explode("\n", trim($extension_functions)); + $funcs = get_defined_functions(); + $builtin['functions'] = $funcs['internal']; - $builtin_functions = array_merge($builtin_functions, $extension_functions); + foreach (array('functions', 'classes') as $type) { + // Developers may not have every extension that a library potentially uses + // installed. We supplement the list of declared functions and classses with + // a list of known extension functions to avoid raising false positives just + // because you don't have pcntl, etc. + $list = dirname(__FILE__)."/php_extension_{$type}.txt"; + $extensions = file_get_contents($list); + $extensions = explode("\n", trim($extensions)); + $builtin[$type] = array_merge($builtin[$type], $extensions); + } return array( - 'class' => array_fill_keys($builtin_classes, true) + array( + 'class' => array_fill_keys($builtin['classes'], true) + array( 'PhutilBootloader' => true, ), 'function' => array_filter( @@ -446,7 +449,7 @@ function phutil_symbols_get_builtins() { // them as builtin since we need to add dependencies for them. 'idx' => false, 'id' => false, - ) + array_fill_keys($builtin_functions, true)), - 'interface' => array_fill_keys($builtin_interfaces, true), + ) + array_fill_keys($builtin['functions'], true)), + 'interface' => array_fill_keys($builtin['interfaces'], true), ); }