本文整理汇总了PHP中PHPParser::GetComponentParams方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPParser::GetComponentParams方法的具体用法?PHP PHPParser::GetComponentParams怎么用?PHP PHPParser::GetComponentParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPParser
的用法示例。
在下文中一共展示了PHPParser::GetComponentParams方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ParseScript
public static function ParseScript($scriptContent)
{
$arComponents = array();
$componentNumber = -1;
$bInComponent = false;
$bInPHP = false;
$bInString = false;
$quoteChar = "";
$bSlashed = false;
$string = false;
$instruction = "";
//mb_substr is catastrophic slow, so in UTF we use array of characters
if (defined("BX_UTF")) {
$allChars = preg_split('//u', $scriptContent, -1, PREG_SPLIT_NO_EMPTY);
} else {
$allChars =& $scriptContent;
}
$scriptContentLength = strlen($scriptContent);
$arAllStr = array();
$ind = -1;
while ($ind < $scriptContentLength - 1) {
$ind++;
$ch = $allChars[$ind];
if ($bInPHP) {
if (!$bInString) {
if (!$bInComponent && $instruction != '') {
if (preg_match("#\\s*((\\\$[A-Z_][A-Z0-9_]*\\s*=)?\\s*\\\$APPLICATION->IncludeComponent\\s*\\()#is", $instruction, $arMatches)) {
$arAllStr = array();
$bInComponent = true;
$componentNumber++;
$instruction = $arMatches[1];
$arComponents[$componentNumber] = array("START" => $ind - strlen($arMatches[1]), "END" => false, "DATA" => array());
}
}
if ($string !== false) {
if ($bInComponent) {
$arAllStr[] = $string;
$instruction .= chr(1) . (count($arAllStr) - 1) . chr(2);
}
$string = false;
}
if ($ch == ";") {
if ($bInComponent) {
$bInComponent = false;
$arComponents[$componentNumber]["END"] = $ind + 1;
$arComponents[$componentNumber]["DATA"] = PHPParser::GetComponentParams(preg_replace("#[ \r\n\t]#", "", $instruction), $arAllStr);
}
$instruction = "";
continue;
}
if ($ch == "/" && $ind < $scriptContentLength - 2) {
$nextChar = $allChars[$ind + 1];
if ($nextChar == "/") {
$endPos = strpos($scriptContent, "\n", $ind + 2);
if ($endPos === false) {
$ind = $scriptContentLength - 1;
} else {
$ind = $endPos;
}
continue;
} elseif ($nextChar == "*") {
$endPos = strpos($scriptContent, "*/", $ind + 2);
if ($endPos === false) {
$ind = $scriptContentLength - 1;
} else {
$ind = $endPos + 1;
}
continue;
}
}
if ($ch == "\"" || $ch == "'") {
$bInString = true;
$string = "";
$quoteChar = $ch;
continue;
}
if ($ch == "?" && $ind < $scriptContentLength - 2 && $allChars[$ind + 1] == ">") {
$ind += 1;
if ($bInComponent) {
$bInComponent = false;
$arComponents[$componentNumber]["END"] = $ind - 1;
$arComponents[$componentNumber]["DATA"] = PHPParser::GetComponentParams(preg_replace("#[ \r\n\t]#", "", $instruction), $arAllStr);
}
$instruction = "";
$bInPHP = false;
continue;
}
$instruction .= $ch;
if ($ch == " " || $ch == "\r" || $ch == "\n" || $ch == "\t") {
continue;
}
} else {
if ($ch == "\\" && !$bSlashed) {
$bSlashed = true;
continue;
}
if ($ch == $quoteChar && !$bSlashed) {
$bInString = false;
continue;
}
//.........这里部分代码省略.........