} else { $default = ""; } $zpp[] = array("type" => $type, "short" => $short, "name" => $arg, "default" => $default); $req_args += !$param->isOptional(); } $classtype = "php_phongo_{$class}_t"; $codes = get_code_from($m->getFilename(), $m->getStartLine(), $m->getEndLine()); $code = render("generator/zpp.php", compact("zpp", "req_args", "classtype", "codes", "config")); if ($n > 0) { $protoargs .= str_repeat("]", $n + 1 - $req_args); } $arginfos .= render("generator/arginfos.php", compact("class", "method", "args", "req_args", "docblock", "config")); $oneliner = explode("\n", $docblock)[1]; $oneliner = " " . trim($oneliner, " *\t"); $rettype = get_return_type($docblock); if ($method == "__construct") { $rettype = str_replace("\\\\", "\\", $ns) . "\\" . $class; } if (!$reflection->isInterface()) { $implementations .= render("generator/implementations.php", compact("class", "method", "oneliner", "protoargs", "code", "rettype", "config")); } } $docblock = untab($reflection->getDocComment()) . "\n"; $declarations .= render("generator/declaration.php", compact("ns", "class", "entries", "docblock", "arginfos", "config")); $minitname = $class; $data = render($_SERVER["argv"][1], compact("declarations", "registrations", "implementations", "minitname", "class", "config")); $namespace = str_replace("\\", "/", $reflection->getNamespaceName()); if (!is_dir("src/{$namespace}")) { mkdir("src/{$namespace}", 0777, true); }
/** * Retrieve the function's prototype as HTML * * Use the wp_parser_prototype filter to change the content of this. * * @return string Prototype HTML */ function get_prototype() { $type = get_return_type(); $friendly_args = array(); $args = get_arguments(); foreach ($args as $arg) { $friendly = sprintf('<span class="type">%s</span> <span class="variable">%s</span>', implode('|', $arg['types']), $arg['name']); $friendly .= empty($arg['default_value']) ? '' : ' <span class="default"> = <span class="value">' . $arg['default_value'] . '</span></span>'; $friendly_args[] = $friendly; } $friendly_args = implode(', ', $friendly_args); $name = get_the_title(); $prototype = sprintf('<p class="wp-parser-prototype"><code><span class="type">%s</span> %s ( %s )</code></p>', implode('|', $type), $name, $friendly_args); return apply_filters('wp_parser_prototype', $prototype); }