1#!/usr/bin/env php 2<?php 3 4/* 5 +----------------------------------------------------------------------+ 6 | Copyright (c) The PHP Group | 7 +----------------------------------------------------------------------+ 8 | This source file is subject to version 3.01 of the PHP license, | 9 | that is bundled with this package in the file LICENSE, and is | 10 | available through the world-wide-web at the following url: | 11 | http://www.php.net/license/3_01.txt | 12 | If you did not receive a copy of the PHP license and are unable to | 13 | obtain it through the world-wide-web, please send a note to | 14 | license@php.net so we can mail you a copy immediately. | 15 +----------------------------------------------------------------------+ 16 | Authors: Marcus Boerger <helly@php.net> | 17 +----------------------------------------------------------------------+ 18 */ 19 20/* This script lists extension-, class- and method names that contain any 21 underscores. It omits magic names (e.g. anything that starts with two 22 underscores but no more). 23 */ 24 25$cnt_modules = 0; 26$cnt_classes = 0; 27$cnt_methods = 0; 28$err = 0; 29 30$classes = array_merge(get_declared_classes(), get_declared_interfaces()); 31 32$extensions = array(); 33 34foreach(get_loaded_extensions() as $ext) { 35 $cnt_modules++; 36 if (strpos($ext, "_") !== false) { 37 $err++; 38 $extensions[$ext] = array(); 39 } 40} 41 42$cnt_classes = count($classes); 43 44foreach($classes as $c) { 45 if (strpos($c, "_") !== false) { 46 $err++; 47 $ref = new ReflectionClass($c); 48 if (!($ext = $ref->getExtensionName())) {; 49 $ext = $ref->isInternal() ? "<internal>" : "<user>"; 50 } 51 if (!array_key_exists($ext, $extensions)) { 52 $extensions[$ext] = array(); 53 } 54 $extensions[$ext][$c] = array(); 55 foreach(get_class_methods($c) as $method) { 56 $cnt_methods++; 57 if (strpos(substr($method, substr($method, 0, 2) != "__" ? 0 : 2), "_") !== false) { 58 $err++; 59 $extensions[$ext][$c][] = $method; 60 } 61 } 62 } 63 else 64 { 65 $cnt_methods += count(get_class_methods($c)); 66 } 67} 68 69$cnt = $cnt_modules + $cnt_classes + $cnt_methods; 70 71printf("\n"); 72printf("Modules: %5d\n", $cnt_modules); 73printf("Classes: %5d\n", $cnt_classes); 74printf("Methods: %5d\n", $cnt_methods); 75printf("\n"); 76printf("Names: %5d\n", $cnt); 77printf("Errors: %5d (%.1f%%)\n", $err, round($err * 100 / $cnt, 1)); 78printf("\n"); 79 80ksort($extensions); 81foreach($extensions as $ext => &$classes) { 82 echo "Extension: $ext\n"; 83 ksort($classes); 84 foreach($classes as $classname => &$methods) { 85 echo " Class: $classname\n"; 86 ksort($methods); 87 foreach($methods as $method) { 88 echo " Method: $method\n"; 89 } 90 } 91} 92 93printf("\n"); 94 95?> 96