本文整理汇总了PHP中Method::setInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP Method::setInfo方法的具体用法?PHP Method::setInfo怎么用?PHP Method::setInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Method
的用法示例。
在下文中一共展示了Method::setInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseFromFile
/**
* Parses a class from supplied filename
* @method parseFromFile
* @param string filename
* @returns true if successful, false otherwise
*/
function parseFromFile($filename)
{
$success = false;
if (file_exists($filename) && is_readable($filename)) {
$arrContents = file($filename);
$parsing = false;
$parsingBlocks = array();
$tempBlock = array();
foreach ($arrContents as $line) {
if (trim($line) == "/**") {
$parsing = true;
$blockstart = true;
} elseif ($parsing && trim($line) == "*/") {
$parsing = false;
$parsingBlocks[] = $tempBlock;
$tempBlock = array();
} else {
if ($parsing) {
if ($blockstart) {
$tempBlock[] = $line;
$blockstart = false;
} else {
$tempBlock[] = $line;
}
}
}
}
foreach ($parsingBlocks as $blockLines) {
$block = array();
foreach ($blockLines as $line) {
$str = strstr($line, "@");
$str = substr($str, 1);
if ($str !== false) {
$separatorPos = strpos($str, " ") && strpos($str, "\t") ? min(strpos($str, " "), strpos($str, "\t")) : (strpos($str, " ") ? strpos($str, " ") : (strpos($str, "\t") ? strpos($str, "\t") : strlen($str)));
$name = trim(substr($str, 0, $separatorPos));
$value = trim(substr($str, $separatorPos));
} else {
$name = "description";
$value = trim($line);
}
if ($name == "param" || $name == "description") {
$block[$name][] = $value;
} else {
$block[$name] = $value;
}
}
//print("<pre>");
//print_r($block);
//print("</pre>");
if (array_key_exists("method", $block)) {
$tempMethod = new Method($block["method"]);
unset($block["method"]);
if (isset($block["param"]) && is_array($block["param"])) {
foreach ($block["param"] as $param) {
$tempMethod->setParam($param, "");
}
}
unset($block["param"]);
foreach ($block as $name => $value) {
$tempMethod->setInfo($name, $value);
}
$this->setMethod($tempMethod);
} elseif (array_key_exists("class", $block)) {
$this->setInfo("name", $block["class"]);
unset($block["class"]);
foreach ($block as $name => $value) {
$this->setInfo($name, $value);
}
}
}
$success = true;
}
return $success;
}