File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ class critical {
29
29
'reservedNames ' ,
30
30
'deprecatedFunctions ' ,
31
31
'newOperatorWithReference ' ,
32
+ 'oldClassConstructors ' ,
32
33
];
33
34
34
35
/**
@@ -133,5 +134,30 @@ public function _newOperatorWithReference($line) {
133
134
}
134
135
return false ;
135
136
}
137
+
138
+ public function _oldClassConstructors ($ line ) {
139
+ static $ lastClassName = false ;
140
+
141
+ // reset the name of the class that we've seen
142
+ if ($ line === '<?php ' ) {
143
+ $ lastClassName = false ;
144
+ }
145
+
146
+ // find the start of PHP class declaration
147
+ if (strpos ($ line , 'class ' ) === 0 ) {
148
+ if (preg_match ('#class (\w+)# ' , $ line , $ matches )) {
149
+ $ lastClassName = $ matches [1 ];
150
+ }
151
+ }
152
+
153
+ // is the class name used as the function name?
154
+ if ($ lastClassName !== false && strpos ($ line , 'function ' ) !== false ) {
155
+ if (preg_match ("#function {$ lastClassName }\s?\(# " , $ line )) {
156
+ return true ;
157
+ }
158
+ }
159
+
160
+ return false ;
161
+ }
136
162
}
137
163
?>
You can’t perform that action at this time.
0 commit comments