Skip to content

Commit

Permalink
Fixed BC break for PHP5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
matthes committed Oct 11, 2017
1 parent ce4778f commit e82572b
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/TextTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,17 +436,32 @@ function ($matches) use ($context, $softFail) {
$paramArr[$matches["name"]] = $this->_getItemValue($matches["sval"], $context);
}, $cmdParam);

if (isset ($this->mFunctions[$command])) {
$out = ($this->mFunctions[$command])($context, $command, $paramArr, $cmdParam);
}
$context["lastErr"] = null;

if ( ! isset ($this->mFunctions[$command])) {
if ($softFail === true)
return "!!ERR:Undefined function '$command'!!";
throw new Exception("Undefined function '$command'");
}

try {
$func = $this->mFunctions[$command];
$out = $func(
$context,
$command,
$paramArr,
$cmdParam
);
if (preg_match ("/\>\s*([a-z0-9\_]+)/i", $cmdParamRest, $matches)) {
$context[$matches[1]] = $out;
} else {
return $out;
}
} catch (Exception $e) {
$context["lastErr"] = $e->getMessage();

if (preg_match ("/\>\s*([a-z0-9\_]+)/i", $cmdParamRest, $matches)) {
$context[$matches[1]] = $out;
} else {
return $out;
}
return "";
}
}, $block);
if ($result === NULL) {
Expand Down

0 comments on commit e82572b

Please sign in to comment.