本文整理汇总了PHP中Functions::parseArgsSimple方法的典型用法代码示例。如果您正苦于以下问题:PHP Functions::parseArgsSimple方法的具体用法?PHP Functions::parseArgsSimple怎么用?PHP Functions::parseArgsSimple使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Functions
的用法示例。
在下文中一共展示了Functions::parseArgsSimple方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($str)
{
static $templateFunctions;
if (!$templateFunctions) {
$templateFunctions = new Functions();
}
$str = Template::unTokenize($str);
// Parse all arg function calls in the passed string,
// callback creates default values.
$self = $this;
$captureCallback = function ($str) use(&$self) {
$args = Functions::parseArgsSimple($str);
$position = array_shift($args);
// Match the argument index integer.
if (!isset($position) || !ctype_digit($position)) {
return '';
}
// Store the default value.
$defaultValue = isset($args[0]) ? $args[0] : null;
if (isset($defaultValue)) {
$self->defaults[$position] = $defaultValue;
}
// Update argument count.
$argNumber = (int) $position + 1;
$self->argCount = max($self->argCount, $argNumber);
return "?a{$position}?";
};
$templateFunctions->register['#'] = $captureCallback;
$templateFunctions->register['arg'] = $captureCallback;
$this->string = $templateFunctions->apply($str);
}
示例2: fn__this
function fn__this($input, $context)
{
$args = Functions::parseArgsSimple($input);
$property = $args[0];
// Function relies on a context rule, bail if none.
if (!isset($context->rule)) {
return '';
}
$rule = $context->rule;
$rule->declarations->expandData('data', $property);
if (isset($rule->declarations->data[$property])) {
return $rule->declarations->data[$property];
} elseif (isset($args[1])) {
return $args[1];
}
return '';
}
示例3: placeVars
protected function placeVars(&$value)
{
static $varFunction, $varFunctionSimple;
if (!$varFunction) {
$varFunctionSimple = Regex::make('~\\$\\( \\s* ({{ ident }}) \\s* \\)~xS');
$varFunction = new Functions(array('$' => function ($rawArgs) {
list($name, $defaultValue) = Functions::parseArgsSimple($rawArgs);
if (isset(Crush::$process->vars[$name])) {
return Crush::$process->vars[$name];
} else {
return $defaultValue;
}
}));
}
// Variables with no default value.
$value = preg_replace_callback($varFunctionSimple, function ($m) {
$varName = $m[1];
if (isset(Crush::$process->vars[$varName])) {
return Crush::$process->vars[$varName];
}
}, $value, -1, $varsPlaced);
// Variables with default value.
if (strpos($value, '$(') !== false) {
// Assume at least one replace.
$varsPlaced = true;
// Variables may be nested so need to apply full function parsing.
$value = $varFunction->apply($value);
}
// If we know replacements have been made we may want to update $value. e.g URL tokens.
return $varsPlaced;
}
示例4: px2em
function px2em($input, $unit, $default_base)
{
list($px, $base) = Functions::parseArgsSimple($input) + array(16, $default_base);
return round($px / $base, 5) . $unit;
}