當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Method::setInfo方法代碼示例

本文整理匯總了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;
 }
開發者ID:emildev35,項目名稱:processmaker,代碼行數:80,代碼來源:PHPClass.php


注:本文中的Method::setInfo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。