mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fixing API shell script to work with core classes
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5900 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
3b60dd5d5f
commit
ce2f730320
1 changed files with 13 additions and 6 deletions
|
@ -109,7 +109,7 @@ class ApiShell extends Shell {
|
|||
|
||||
if ($File->exists()) {
|
||||
if (!class_exists($class)) {
|
||||
include($File->pwd());
|
||||
include_once($File->pwd());
|
||||
}
|
||||
if (class_exists($class)) {
|
||||
break;
|
||||
|
@ -185,18 +185,25 @@ class ApiShell extends Shell {
|
|||
function __parseClass(&$File, $class) {
|
||||
$parsed = array();
|
||||
|
||||
$methods = am(array(), array_diff(get_class_methods($class), get_class_methods(get_parent_class($class))));
|
||||
if (get_parent_class($class)) {
|
||||
$methods = am(array(), array_diff(get_class_methods($class), get_class_methods(get_parent_class($class))));
|
||||
} else {
|
||||
$methods = get_class_methods($class);
|
||||
}
|
||||
|
||||
$contents = $File->read();
|
||||
|
||||
foreach ($methods as $method) {
|
||||
if (strpos($method, '__') !== 0 && strpos($method, '_') !== 0) {
|
||||
$regex = '/\s+function\s+(' . preg_quote($method, '/') . ')\s*\(([^{]*)\)\s*{/is';
|
||||
$regex = array(
|
||||
'/\s+function\s+(' . preg_quote($method, '/') . ')\s*\(([^{]*)\)\s*{/is',
|
||||
'/\s+function\s+(' . preg_quote('&' . $method, '/') . ')\s*\(([^{]*)\)\s*{/is'
|
||||
);
|
||||
|
||||
if (preg_match($regex, $contents, $matches)) {
|
||||
if (preg_match($regex[0], $contents, $matches) || preg_match($regex[1], $contents, $matches)) {
|
||||
$parsed[$method] = array(
|
||||
'method' => trim($matches[1]),
|
||||
'parameters' => trim($matches[2])
|
||||
'method' => trim($matches[1]),
|
||||
'parameters' => trim($matches[2])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue