|
21 | 21 |
|
22 | 22 |
|
23 | 23 | define('REPORT_LEVEL', 2); // 0 reports less false-positives. up to level 5. |
24 | | -define('VERSION', '5.2'); // minimum is 5.2 |
| 24 | +define('VERSION', '7.0'); // minimum is 7.0 |
25 | 25 | define('PHPDIR', realpath(dirname(__FILE__) . '/../..')); |
26 | 26 |
|
27 | 27 |
|
|
33 | 33 |
|
34 | 34 |
|
35 | 35 | $API_params = array( |
36 | | - 'a' => array('zval**'), // array as zval* |
| 36 | + 'a' => array('zval**'), // array |
| 37 | + 'A' => array('zval**'), // array or object |
37 | 38 | 'b' => array('zend_bool*'), // boolean |
38 | 39 | 'C' => array('zend_class_entry**'), // class |
39 | 40 | 'd' => array('double*'), // double |
40 | 41 | 'f' => array('zend_fcall_info*', 'zend_fcall_info_cache*'), // function |
41 | 42 | 'h' => array('HashTable**'), // array as an HashTable* |
42 | | - 'l' => array('long*'), // long |
| 43 | + 'H' => array('HashTable**'), // array or HASH_OF(object) |
| 44 | + 'l' => array('zend_long*'), // long |
| 45 | + //TODO 'L' => array('zend_long*, '), // long |
43 | 46 | 'o' => array('zval**'), //object |
44 | 47 | 'O' => array('zval**', 'zend_class_entry*'), // object of given type |
| 48 | + 'p' => array('char**', 'size_t*'), // valid path |
| 49 | + 'P' => array('zend_string**'), // valid path |
45 | 50 | 'r' => array('zval**'), // resource |
46 | | - 's' => array('char**', 'int*'), // string |
| 51 | + 's' => array('char**', 'size_t*'), // string |
| 52 | + 'S' => array('zend_string**'), // string |
47 | 53 | 'z' => array('zval**'), // zval* |
48 | 54 | 'Z' => array('zval***') // zval** |
49 | 55 | ); |
50 | 56 |
|
51 | | -// specific to PHP >= 6 |
52 | | -if (version_compare(VERSION, '6', 'ge')) { |
53 | | - $API_params['S'] = $API_params['s']; // binary string |
54 | | - $API_params['t'] = array('zstr*', 'int*', 'zend_uchar*'); // text |
55 | | - $API_params['T'] = $API_params['t']; |
56 | | - $API_params['u'] = array('UChar**', 'int*'); // unicode |
57 | | - $API_params['U'] = $API_params['u']; |
58 | | -} |
59 | | - |
60 | | - |
61 | 57 | /** reports an error, according to its level */ |
62 | 58 | function error($str, $level = 0) |
63 | 59 | { |
64 | 60 | global $current_file, $current_function, $line; |
65 | 61 |
|
66 | 62 | if ($level <= REPORT_LEVEL) { |
67 | 63 | if (strpos($current_file,PHPDIR) === 0) { |
68 | | - $filename = substr($current_file, strlen(PHPDIR)+1); |
| 64 | + $filename = substr($current_file, strlen(PHPDIR)+1); |
69 | 65 | } else { |
70 | 66 | $filename = $current_file; |
71 | 67 | } |
@@ -243,31 +239,15 @@ function check_function($name, $txt, $offset) |
243 | 239 | } |
244 | 240 | break; |
245 | 241 |
|
246 | | - case '&': |
247 | | - if (version_compare(VERSION, '6', 'ge')) { |
248 | | - if ($last_char == 's' || ($last_last_char == 's' && $last_char == '!')) { |
249 | | - check_param($params, ++$j, 'UConverter*', $optional); |
250 | | - |
251 | | - } else { |
252 | | - error("the '&' specifier cannot be applied to '$last_char'"); |
253 | | - } |
254 | | - } else { |
255 | | - error("unknown char ('&') at column $i"); |
256 | | - } |
257 | | - break; |
258 | | - |
| 242 | + // variadic arguments |
259 | 243 | case '+': |
260 | 244 | case '*': |
261 | | - if (version_compare(VERSION, '6', 'ge')) { |
262 | | - if ($varargs) { |
263 | | - error("A varargs specifier can only be used once. repeated char at column $i"); |
264 | | - } else { |
265 | | - check_param($params, ++$j, 'zval****', $optional); |
266 | | - check_param($params, ++$j, 'int*', $optional); |
267 | | - $varargs = true; |
268 | | - } |
| 245 | + if ($varargs) { |
| 246 | + error("A varargs specifier can only be used once. repeated char at column $i"); |
269 | 247 | } else { |
270 | | - error("unknown char ('$char') at column $i"); |
| 248 | + check_param($params, ++$j, 'zval**', $optional); |
| 249 | + check_param($params, ++$j, 'int*', $optional); |
| 250 | + $varargs = true; |
271 | 251 | } |
272 | 252 | break; |
273 | 253 |
|
@@ -306,8 +286,10 @@ function recurse($path) |
306 | 286 |
|
307 | 287 | $txt = file_get_contents($file); |
308 | 288 | // remove comments (but preserve the number of lines) |
309 | | - $txt = preg_replace(array('@//.*@S', '@/\*.*\*/@SsUe'), array('', 'preg_replace("/[^\r\n]+/S", "", \'$0\')'), $txt); |
310 | | - |
| 289 | + $txt = preg_replace('@//.*@S', '', $txt); |
| 290 | + $txt = preg_replace_callback('@/\*.*\*/@SsU', function($matches) { |
| 291 | + return preg_replace("/[^\r\n]+/S", "", $matches[0]); |
| 292 | + }, $txt); |
311 | 293 |
|
312 | 294 | $split = preg_split('/PHP_(?:NAMED_)?(?:FUNCTION|METHOD)\s*\((\w+(?:,\s*\w+)?)\)/S', $txt, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE); |
313 | 295 |
|
@@ -352,7 +334,7 @@ function recurse($path) |
352 | 334 | for ($i = 1; $i < $argc; $i++) { |
353 | 335 | $dirs[] = $argv[$i]; |
354 | 336 | } |
355 | | -} else { |
| 337 | +} else { |
356 | 338 | $dirs[] = PHPDIR; |
357 | 339 | } |
358 | 340 |
|
|
0 commit comments