if (!is_dir(PHD_INSTALL_DIR)) { echo 'Fatal error: PHD_INSTALL_DIR is not a directory. It must contain PhD (look for a phpdotnet/ subdirectory).' . PHP_EOL; exit; } if (!is_dir(PHD_OUTPUT_DIR)) { echo 'Fatal error: PHD_OUTPUT_DIR is not a directory. It must contain output generated by PhD.' . PHP_EOL; echo 'Information: $ phd --docbook /foo/.manual.xml --package IDE --format xml' . PHP_EOL; echo 'Information: $ phd --docbook /foo/.manual.xml --package IDE --format funclist' . PHP_EOL; exit; } require PHD_INSTALL_DIR . DS . 'phpdotnet' . DS . 'phd' . DS . 'Autoloader.php'; require PHD_INSTALL_DIR . DS . 'phpdotnet' . DS . 'phd' . DS . 'functions.php'; spl_autoload_register(array('phpdotnet\\phd\\Autoloader', 'autoload')); // @todo this may not be needed in the future PhD\Config::init(array()); $api = new PhD\Package_IDE_API(PHD_OUTPUT_DIR); // Gets all documented functions/methods $functions = $api->getFunctionList(); $json_arr = array(); foreach ($functions as $function_name) { // @todo fix source so trim() isn't needed $function_name = trim($function_name); $function = $api->getFunctionByName($function_name); $prototype = (string) $function; // @todo fix this. Replaces class.method with class::method // @todo fix this? Replaces NULL with null, to remain consistent $function_name_fixed = str_replace('.', '::', (string) $function_name); $prototype = str_replace($function_name, $function_name_fixed, $prototype); $prototype = str_replace('NULL', 'null', $prototype); // Some contain new lines, let's remove them $purpose = str_replace("\n", '', (string) $function->getPurpose());
break; default: trigger_error('Invalid Option: ' . $k, E_USER_ERROR); } } if ($OPTION['help'] === true || !$options) { usage(); exit(0); } if ($OPTION['dir'] == NULL) { trigger_error('You must specify the PhD output directory with the --dir option.', E_USER_ERROR); } if ($OPTION['function'] == NULL && $OPTION['class'] == NULL) { trigger_error('You must pass either --class or --function options.', E_USER_ERROR); } $api = new PhD\Package_IDE_API($OPTION['dir']); if ($OPTION['class'] != NULL) { $methods = $api->getMethodsByClass($OPTION['class']); if ($methods == NULL) { trigger_error('Invalid Class name: ' . $OPTION['class'], E_USER_ERROR); } foreach ($methods as $method) { echo $method . PHP_EOL; } exit(0); } $function = $api->getFunctionByName($OPTION['function']); if ($function == NULL) { trigger_error('Invalid Function: ' . $OPTION['function'], E_USER_ERROR); } if ($OPTION['signature'] === true) {