function testFindShortOpen() { $scripts = $this->getAllScripts(false); $function_defs = array(); foreach ($scripts as $s) { $matches = array(); preg_match_all('/^\\s*(?:\\/\\*[^*]*\\*\\/)?\\s*' . '(?:(?:private|public|protected|static|abstract)\\s+)*' . 'function\\s+&?\\s*([^(\\s]+)\\s*\\(/m', file_get_contents($s), $matches); $function_defs = array_merge($function_defs, $matches[1]); } foreach (find_function_calls($scripts) as $call) { list($file, $no, $line, $func) = $call; if (!in_array($func, $function_defs)) { $this->fail($file, $no, "{$func}: Definitely undefined"); } else { $this->pass(); } } }
function testFindShortOpen() { $scripts = $this->getAllScripts(false); $function_defs = array(); foreach ($scripts as $s) { $matches = array(); preg_match_all('/^\s*(?:\/\*[^*]*\*\/)?\s*' .'(?:(?:private|public|protected|static|abstract)\s+)*' .'function\s+&?\s*([^(\s]+)\s*\(/m', file_get_contents($s), $matches); $function_defs = array_merge($function_defs, $matches[1]); } foreach (find_function_calls($scripts) as $call) { list($file, $no, $line, $func) = $call; if (!in_array($func, $function_defs)) { // We don't ship all of mdpf, so a bit of it looks undefined if (strpos($file, '/mpdf/') === false) $this->fail($file, $no, "$func: Definitely undefined"); } else { $this->pass(); } } }
$matches = array(); preg_match_all('/-[>]([a-zA-Z0-9]*)\\(/', $line, $matches, PREG_SET_ORDER); foreach ($matches as $m) { $calls[] = array($s, $lineno, $line, $m[1]); } } } return $calls; } $php_script_content = ''; foreach ($scripts as $s) { $php_script_content .= file_get_contents($s); } echo "Access to undefined object methods: "; ob_start(); foreach (find_function_calls($scripts) as $call) { list($file, $no, $line, $func) = $call; if (!preg_match('/^\\s*(\\/\\*[^*]*\\*\\/)?' . "\\s*function\\s+&?\\s*{$func}\\(/m", $php_script_content)) { print "{$func}: Definitely undefined, from {$file}:{$no}\n"; } } $undef_func_errors = ob_get_clean(); if (strlen($undef_func_errors)) { $undef_func_errors = str_replace("{$root}/", '', $undef_func_errors); echo "FAIL\n"; echo "-------------------------------------------------------\n"; echo "{$undef_func_errors}"; exit; } else { echo "\n"; }