From: Marcus Boerger Date: Tue, 30 Mar 2004 18:50:39 +0000 (+0000) Subject: The test script to search for underscores X-Git-Tag: php-5.0.0RC2RC1~148 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a5c94d01840fc68c1e07de286e3af6d4e5556f5c;p=php The test script to search for underscores --- diff --git a/scripts/dev/search_underscores.php b/scripts/dev/search_underscores.php new file mode 100755 index 0000000000..867642f174 --- /dev/null +++ b/scripts/dev/search_underscores.php @@ -0,0 +1,86 @@ +#! /usr/local/bin/php -n + | + +----------------------------------------------------------------------+ + */ + +/* This script lists extension-, class- and method names that contain any + underscores. It omits magic names (e.g. anything that starts with two + underscores but no more). + */ +$cnt = 0; +$err = 0; + +$classes = array_merge(get_declared_classes(), get_declared_interfaces()); + +$extensions = array(); + +foreach(get_loaded_extensions() as $ext) { + $cnt++; + if (strpos($ext, "_") !== false) { + $err++; + $extensions[$ext] = array(); + } +} + +$cnt += count($classes); + +foreach($classes as $c) { + if (strpos($c, "_") !== false) { + $err++; + $ref = new ReflectionClass($c); + if (!($ext = $ref->getExtensionName())) {; + $ext = $ref->isInternal() ? "" : ""; + } + if (!array_key_exists($ext, $extensions)) { + $extensions[$ext] = array(); + } + $extensions[$ext][$c] = array(); + foreach(get_class_methods($c) as $method) { + $cnt++; + if (strpos(substr($method, substr($method, 0, 2) != "__" ? 0 : 2), "_") !== false) { + $err++; + $extensions[$ext][$c][] = $method; + } + } + } + else + { + $cnt += count(get_class_methods($c)); + } +} + +ksort($extensions); +foreach($extensions as $ext => &$classes) { + echo "Extension: $ext\n"; + ksort($classes); + foreach($classes as $classname => &$methods) { + echo " Class: $classname\n"; + ksort($methods); + foreach($methods as $method) { + echo " Method: $method\n"; + } + } +} + +printf("\n"); +printf("Names: %5d\n", $cnt); +printf("Errors: %5d (%.1f%%)\n", $err, round($err * 100 / $cnt, 1)); +printf("\n"); + +?> \ No newline at end of file