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