mirror of
https://github.com/Mibew/handlebars.php.git
synced 2024-11-15 08:44:12 +03:00
CS fixes
This commit is contained in:
parent
0111689f47
commit
e1956be453
@ -142,10 +142,12 @@ class Arguments
|
||||
// Remove found argument from arguments string.
|
||||
$current_str = ltrim(substr($current_str, strlen($matches[0])));
|
||||
} else {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'Malformed arguments string: "%s"',
|
||||
var_export($args_String, true)
|
||||
));
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf(
|
||||
'Malformed arguments string: "%s"',
|
||||
var_export($args_string, true)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -196,10 +196,12 @@ class Context
|
||||
}
|
||||
if (count($this->stack) < $level) {
|
||||
if ($strict) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'Can not find variable in context: "%s"',
|
||||
var_export($variableName, true)
|
||||
));
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf(
|
||||
'Can not find variable in context: "%s"',
|
||||
var_export($variableName, true)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return '';
|
||||
@ -216,10 +218,12 @@ class Context
|
||||
$current = current($this->stack);
|
||||
if (!$variableName) {
|
||||
if ($strict) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'Can not find variable in context: "%s"',
|
||||
var_export($variableName, true)
|
||||
));
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf(
|
||||
'Can not find variable in context: "%s"',
|
||||
var_export($variableName, true)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return '';
|
||||
@ -230,10 +234,12 @@ class Context
|
||||
if (isset($specialVariables[$variableName])) {
|
||||
return $specialVariables[$variableName];
|
||||
} elseif ($strict) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'Can not find variable in context: "%s"',
|
||||
var_export($variableName, true)
|
||||
));
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf(
|
||||
'Can not find variable in context: "%s"',
|
||||
var_export($variableName, true)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
@ -279,10 +285,12 @@ class Context
|
||||
}
|
||||
|
||||
if ($strict) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'Can not find variable in context: "%s"',
|
||||
var_export($variable, true)
|
||||
));
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf(
|
||||
'Can not find variable in context: "%s"',
|
||||
var_export($variable, true)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $value;
|
||||
@ -306,10 +314,12 @@ class Context
|
||||
$get_pattern = "/(?:" . $name_pattern . ")/";
|
||||
|
||||
if (!preg_match($check_pattern, $variableName)) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'Variable name is invalid: "%s"',
|
||||
$variableName
|
||||
));
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf(
|
||||
'Variable name is invalid: "%s"',
|
||||
$variableName
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
preg_match_all($get_pattern, $variableName, $matches);
|
||||
|
@ -459,10 +459,12 @@ class Handlebars
|
||||
public function setTemplateClass($class)
|
||||
{
|
||||
if (!is_a($class, 'Handlebars\\Template', true)) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'Custom template class "%s" must extend Template',
|
||||
var_export($class, true)
|
||||
));
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf(
|
||||
'Custom template class "%s" must extend Template',
|
||||
var_export($class, true)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->_templateClass = $class;
|
||||
|
@ -99,10 +99,12 @@ class Helpers
|
||||
public function add($name, $helper)
|
||||
{
|
||||
if (!is_callable($helper) && ! $helper instanceof Helper) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
"%s Helper is not a callable or doesn't implement the Helper interface.",
|
||||
var_export($name, true)
|
||||
));
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf(
|
||||
"%s Helper is not a callable or doesn't implement the Helper interface.",
|
||||
var_export($name, true)
|
||||
)
|
||||
);
|
||||
}
|
||||
$this->helpers[$name] = $helper;
|
||||
}
|
||||
@ -137,10 +139,12 @@ class Helpers
|
||||
public function call($name, Template $template, Context $context, $args, $source)
|
||||
{
|
||||
if (!$this->has($name)) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'Unknown helper: "%s"',
|
||||
var_export($name, true)
|
||||
));
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf(
|
||||
'Unknown helper: "%s"',
|
||||
var_export($name, true)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->helpers[$name] instanceof Helper) {
|
||||
@ -175,10 +179,12 @@ class Helpers
|
||||
public function __get($name)
|
||||
{
|
||||
if (!$this->has($name)) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'Unknown helper: "%s"',
|
||||
var_export($name, true)
|
||||
));
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf(
|
||||
'Unknown helper: "%s"',
|
||||
var_export($name, true)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->helpers[$name];
|
||||
@ -233,10 +239,12 @@ class Helpers
|
||||
public function remove($name)
|
||||
{
|
||||
if (!$this->has($name)) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'Unknown helper: "%s"',
|
||||
var_export($name, true)
|
||||
));
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf(
|
||||
'Unknown helper: "%s"',
|
||||
var_export($name, true)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
unset($this->helpers[$name]);
|
||||
|
@ -75,17 +75,21 @@ class InlineLoader implements Loader
|
||||
public function __construct($fileName, $offset)
|
||||
{
|
||||
if (!is_file($fileName)) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'InlineLoader expects a valid filename, "%s" given.',
|
||||
$fileName
|
||||
));
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf(
|
||||
'InlineLoader expects a valid filename, "%s" given.',
|
||||
$fileName
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_int($offset) || $offset < 0) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'InlineLoader expects a valid file offset, "%s" given.',
|
||||
$offset
|
||||
));
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf(
|
||||
'InlineLoader expects a valid file offset, "%s" given.',
|
||||
$offset
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->fileName = $fileName;
|
||||
|
@ -78,10 +78,12 @@ class Parser
|
||||
do {
|
||||
$result = array_pop($stack);
|
||||
if ($result === null) {
|
||||
throw new \LogicException(sprintf(
|
||||
'Unexpected closing tag: /%s',
|
||||
var_export($token[Tokenizer::NAME], true)
|
||||
));
|
||||
throw new \LogicException(
|
||||
sprintf(
|
||||
'Unexpected closing tag: /%s',
|
||||
var_export($token[Tokenizer::NAME], true)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (!array_key_exists(Tokenizer::NODES, $result)
|
||||
|
@ -30,7 +30,8 @@ namespace Handlebars;
|
||||
*
|
||||
* @category Xamin
|
||||
* @package Handlebars
|
||||
* @author fzerorubigd <fzerorubigd@gmail.com>, Pascal Thormeier <pascal.thormeier@gmail.com>
|
||||
* @author fzerorubigd <fzerorubigd@gmail.com>
|
||||
* @author Pascal Thormeier <pascal.thormeier@gmail.com>
|
||||
* @copyright 2010-2012 (c) Justin Hileman
|
||||
* @copyright 2012 (c) ParsPooyesh Co
|
||||
* @license MIT <http://opensource.org/licenses/MIT>
|
||||
@ -404,10 +405,12 @@ class Template
|
||||
try {
|
||||
$sectionVar = $context->get($sectionName, true);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
throw new \RuntimeException(sprintf(
|
||||
'"%s" is not registered as a helper',
|
||||
var_export($sectionName, true)
|
||||
));
|
||||
throw new \RuntimeException(
|
||||
sprintf(
|
||||
'"%s" is not registered as a helper',
|
||||
var_export($sectionName, true)
|
||||
)
|
||||
);
|
||||
}
|
||||
$buffer = '';
|
||||
if (is_array($sectionVar) || $sectionVar instanceof \Traversable) {
|
||||
@ -462,10 +465,12 @@ class Template
|
||||
} elseif (trim($current[Tokenizer::ARGS]) == '') {
|
||||
return $this->_mustacheStyleSection($context, $current);
|
||||
} else {
|
||||
throw new \RuntimeException(sprintf(
|
||||
'"%s"" is not registered as a helper',
|
||||
var_export($sectionName, true)
|
||||
));
|
||||
throw new \RuntimeException(
|
||||
sprintf(
|
||||
'"%s"" is not registered as a helper',
|
||||
var_export($sectionName, true)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -508,7 +513,7 @@ class Template
|
||||
$args
|
||||
);
|
||||
|
||||
$context = new Context($this->_getPartialArguments($context, $args[0]));
|
||||
$context = new Context($this->_getPartialArgumentsValues($context, $args[0]));
|
||||
}
|
||||
|
||||
return $partial->render($context);
|
||||
@ -517,12 +522,12 @@ class Template
|
||||
/**
|
||||
* Prepare the arguments of a partial to actual array values to be used in a new context
|
||||
*
|
||||
* @param Context $context
|
||||
* @param array $args
|
||||
* @param Context $context Current context
|
||||
* @param array $args Arguments given by tokenizer, splitted to key=>value pairs
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function _getPartialArguments(Context $context, array $args)
|
||||
private function _getPartialArgumentsValues(Context $context, array $args)
|
||||
{
|
||||
$partialArgs = array();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user