本文整理汇总了PHP中Operation::isa方法的典型用法代码示例。如果您正苦于以下问题:PHP Operation::isa方法的具体用法?PHP Operation::isa怎么用?PHP Operation::isa使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Operation
的用法示例。
在下文中一共展示了Operation::isa方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: lex
/**
* Lex an expression into Script tokens.
*
* @param string $string expression to lex
* @param Context $context the context in which the expression is lexed
* @return array tokens
*/
public function lex($string, $context)
{
// if it's already lexed, just return it as-is
if (is_object($string)) {
return [$string];
}
if (is_array($string)) {
return $string;
}
$tokens = [];
// whilst the string is not empty, split it into it's tokens.
while ($string !== FALSE) {
if (($match = $this->isWhitespace($string)) !== FALSE) {
$tokens[] = NULL;
} elseif (($match = ScriptFunction::isa($string)) !== FALSE) {
preg_match(ScriptFunction::MATCH_FUNC, $match, $matches);
$args = [];
foreach (ScriptFunction::extractArgs($matches[ScriptFunction::ARGS], FALSE, $context) as $key => $expression) {
$args[$key] = $this->parser->evaluate($expression, $context);
}
$tokens[] = new ScriptFunction($matches[ScriptFunction::NAME], $args);
} elseif (($match = Literals\Boolean::isa($string)) !== FALSE) {
$tokens[] = new Literals\Boolean($match);
} elseif (($match = Literals\Colour::isa($string)) !== FALSE) {
$tokens[] = new Literals\Colour($match);
} elseif (($match = Literals\Number::isa($string)) !== FALSE) {
$tokens[] = new Literals\Number($match);
} elseif (($match = Literals\SassString::isa($string)) !== FALSE) {
$stringed = new Literals\SassString($match);
$tokens[] = !strlen($stringed->quote) && Literals\SassList::isa($string) !== FALSE && !preg_match("/^\\-\\w+\\-\\w+\$/", $stringed->value) ? new Literals\SassList($string) : $stringed;
} elseif ($string == '()') {
$match = $string;
$tokens[] = new Literals\SassList($match);
} elseif (($match = Operation::isa($string)) !== FALSE) {
$tokens[] = new Operation($match);
} elseif (($match = Variable::isa($string)) !== FALSE) {
$tokens[] = new Variable($match);
} else {
$_string = $string;
$match = '';
while (strlen($_string) && !$this->isWhitespace($_string)) {
foreach (Operation::$inStrOperators as $operator) {
if (substr($_string, 0, strlen($operator)) == $operator) {
break 2;
}
}
$match .= $_string[0];
$_string = substr($_string, 1);
}
$tokens[] = new Literals\SassString($match);
}
$string = substr($string, strlen($match));
}
return $tokens;
}