本文整理汇总了PHP中Helpers::getSuggestion方法的典型用法代码示例。如果您正苦于以下问题:PHP Helpers::getSuggestion方法的具体用法?PHP Helpers::getSuggestion怎么用?PHP Helpers::getSuggestion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Helpers
的用法示例。
在下文中一共展示了Helpers::getSuggestion方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __get
public function __get($key)
{
$hint = Helpers::getSuggestion(array_keys((array) $this), $key);
trigger_error("Attempt to read missing column '{$key}'" . ($hint ? ", did you mean '{$hint}'?" : '.'), E_USER_NOTICE);
}
示例2: expandMacro
/**
* Expands macro and returns node & code.
* @param string
* @param string
* @param string
* @return MacroNode
* @internal
*/
public function expandMacro($name, $args, $modifiers = NULL, $nPrefix = NULL)
{
$inScript = in_array($this->context[0], array(self::CONTENT_JS, self::CONTENT_CSS), TRUE);
if (empty($this->macros[$name])) {
$hint = ($t = Helpers::getSuggestion(array_keys($this->macros), $name)) ? ", did you mean {{$t}}?" : '';
throw new CompileException("Unknown macro {{$name}}{$hint}" . ($inScript ? ' (in JavaScript or CSS, try to put a space after bracket.)' : ''));
}
if (strpbrk($name, '=~%^&_')) {
if ($this->context[1] === self::CONTENT_URL) {
$modifiers = preg_replace('#\\|nosafeurl\\s?(?=\\||\\z)#i', '', $modifiers, -1, $found);
if (!$found && !preg_match('#\\|datastream(?=\\s|\\||\\z)#i', $modifiers)) {
$modifiers .= '|safeurl';
}
}
$modifiers = preg_replace('#\\|noescape\\s?(?=\\||\\z)#i', '', $modifiers, -1, $found);
if (!$found) {
$modifiers .= '|escape';
}
if (!$found && $inScript && $name === '=' && preg_match('#["\'] *\\z#', $this->tokens[$this->position - 1]->text)) {
throw new CompileException("Do not place {$this->tokens[$this->position]->text} inside quotes.");
}
}
foreach (array_reverse($this->macros[$name]) as $macro) {
$node = new MacroNode($macro, $name, $args, $modifiers, $this->macroNode, $this->htmlNode, $nPrefix);
if ($macro->nodeOpened($node) !== FALSE) {
return $node;
}
}
throw new CompileException('Unknown ' . ($nPrefix ? 'attribute ' . Parser::N_PREFIX . ($nPrefix === MacroNode::PREFIX_NONE ? '' : "{$nPrefix}-") . $name : 'macro {' . $name . ($args ? " {$args}" : '') . '}'));
}
示例3: invokeFilter
/**
* Call a run-time filter.
* @param string filter name
* @param array arguments
* @return mixed
*/
public function invokeFilter($name, array $args)
{
$lname = strtolower($name);
if (!isset($this->filters[$lname])) {
$args2 = $args;
array_unshift($args2, $lname);
foreach ($this->filters[NULL] as $filter) {
$res = call_user_func_array(Helpers::checkCallback($filter), $args2);
if ($res !== NULL) {
return $res;
} elseif (isset($this->filters[$lname])) {
return call_user_func_array(Helpers::checkCallback($this->filters[$lname]), $args);
}
}
$hint = ($t = Helpers::getSuggestion(array_keys($this->filters), $name)) ? ", did you mean '{$t}'?" : '.';
throw new \LogicException("Filter '{$name}' is not defined{$hint}");
}
return call_user_func_array(Helpers::checkCallback($this->filters[$lname]), $args);
}
示例4: expandMacro
/**
* Expands macro and returns node & code.
* @param string
* @param string
* @param string
* @return MacroNode
* @internal
*/
public function expandMacro($name, $args, $modifiers = NULL, $nPrefix = NULL)
{
$inScript = in_array($this->context, [self::CONTEXT_HTML_JS, self::CONTEXT_HTML_CSS], TRUE);
if (empty($this->macros[$name])) {
$hint = ($t = Helpers::getSuggestion(array_keys($this->macros), $name)) ? ", did you mean {{$t}}?" : '';
throw new CompileException("Unknown macro {{$name}}{$hint}" . ($inScript ? ' (in JavaScript or CSS, try to put a space after bracket or use n:syntax=off)' : ''));
}
if (preg_match('#\\|(no)?safeurl(?!\\w)#i', $modifiers, $m)) {
$hint = $m[1] ? '|nocheck' : '|checkurl';
$modifiers = str_replace($m[0], $hint, $modifiers);
trigger_error("Modifier {$m['0']} is deprecated, please replace it with {$hint}.", E_USER_DEPRECATED);
}
if (strpbrk($name, '=~%^&_')) {
if (in_array($this->context, [self::CONTEXT_HTML_ATTRIBUTE_URL, self::CONTEXT_HTML_ATTRIBUTE_UNQUOTED_URL], TRUE)) {
if (!Helpers::removeFilter($modifiers, 'nosafeurl|nocheck') && !preg_match('#\\|datastream(?=\\s|\\||\\z)#i', $modifiers)) {
$modifiers .= '|checkurl';
}
}
if (!Helpers::removeFilter($modifiers, 'noescape')) {
$modifiers .= '|escape';
if ($inScript && $name === '=' && preg_match('#["\'] *\\z#', $this->tokens[$this->position - 1]->text)) {
throw new CompileException("Do not place {$this->tokens[$this->position]->text} inside quotes.");
}
}
}
if ($nPrefix === MacroNode::PREFIX_INNER && !strcasecmp($this->htmlNode->name, 'script')) {
$context = [$this->contentType, self::CONTEXT_HTML_JS];
} elseif ($nPrefix === MacroNode::PREFIX_INNER && !strcasecmp($this->htmlNode->name, 'style')) {
$context = [$this->contentType, self::CONTEXT_HTML_CSS];
} elseif ($nPrefix) {
$context = [$this->contentType, self::CONTEXT_HTML_TEXT];
} else {
$context = [$this->contentType, $this->context];
}
foreach (array_reverse($this->macros[$name]) as $macro) {
$node = new MacroNode($macro, $name, $args, $modifiers, $this->macroNode, $this->htmlNode, $nPrefix);
$node->context = $context;
$node->startLine = $nPrefix ? $this->htmlNode->startLine : $this->getLine();
if ($macro->nodeOpened($node) !== FALSE) {
return $node;
}
}
throw new CompileException('Unknown ' . ($nPrefix ? 'attribute ' . Parser::N_PREFIX . ($nPrefix === MacroNode::PREFIX_NONE ? '' : "{$nPrefix}-") . $name : 'macro {' . $name . ($args ? " {$args}" : '') . '}'));
}