MDL-75388 lib: Update mustache to 2.14.1

MDL-67114 local change removed as it is now available upstream.
This commit is contained in:
Mark Johnson
2022-08-12 04:17:17 +02:00
committed by Jenkins
parent ee888615ea
commit 944455bcce
8 changed files with 21 additions and 19 deletions
-2
View File
@@ -18,5 +18,3 @@ Note: All this changes need to be reviewed on every upgrade and, if they have
been already applied upstream for the release being used, can be removed
from the list. If still not available upstream, they will need to be re-applied.
- MDL-67114: PHP 7.4 compatibility. Array operations on scalar value.
This corresponds to upstream https://github.com/bobthecow/mustache.php/pull/352
+7
View File
@@ -33,4 +33,11 @@ interface Mustache_Cache
* @param string $value
*/
public function cache($key, $value);
/**
* Set a logger instance.
*
* @param Mustache_Logger|Psr\Log\LoggerInterface $logger
*/
public function setLogger($logger = null);
}
@@ -47,7 +47,7 @@ abstract class Mustache_Cache_AbstractCache implements Mustache_Cache
/**
* Add a log record if logging is enabled.
*
* @param int $level The logging level
* @param string $level The logging level
* @param string $message The log message
* @param array $context The log context
*/
+5 -8
View File
@@ -286,7 +286,6 @@ class Mustache_Compiler
private function blockArg($nodes, $id, $start, $end, $otag, $ctag, $level)
{
$key = $this->block($nodes);
$keystr = var_export($key, true);
$id = var_export($id, true);
return sprintf($this->prepare(self::BLOCK_ARG, $level), $id, $key);
@@ -321,7 +320,6 @@ class Mustache_Compiler
}
const SECTION_CALL = '
// %s section
$value = $context->%s(%s);%s
$buffer .= $this->section%s($context, $indent, $value);
';
@@ -333,12 +331,12 @@ class Mustache_Compiler
if (%s) {
$source = %s;
$result = call_user_func($value, $source, %s);
$result = (string) call_user_func($value, $source, %s);
if (strpos($result, \'{{\') === false) {
$buffer .= $result;
} else {
$buffer .= $this->mustache
->loadLambda((string) $result%s)
->loadLambda($result%s)
->renderInternal($context);
}
} elseif (!empty($value)) {
@@ -392,11 +390,10 @@ class Mustache_Compiler
$id = var_export($id, true);
$filters = $this->getFilters($filters, $level);
return sprintf($this->prepare(self::SECTION_CALL, $level), $id, $method, $id, $filters, $key);
return sprintf($this->prepare(self::SECTION_CALL, $level), $method, $id, $filters, $key);
}
const INVERTED_SECTION = '
// %s inverted section
$value = $context->%s(%s);%s
if (empty($value)) {
%s
@@ -419,7 +416,7 @@ class Mustache_Compiler
$id = var_export($id, true);
$filters = $this->getFilters($filters, $level);
return sprintf($this->prepare(self::INVERTED_SECTION, $level), $id, $method, $id, $filters, $this->walk($nodes, $level));
return sprintf($this->prepare(self::INVERTED_SECTION, $level), $method, $id, $filters, $this->walk($nodes, $level));
}
const PARTIAL_INDENT = ', $indent . %s';
@@ -507,7 +504,7 @@ class Mustache_Compiler
const VARIABLE = '
$value = $this->resolveValue($context->%s(%s), $context);%s
$buffer .= %s%s;
$buffer .= %s($value === null ? \'\' : %s);
';
/**
+2 -2
View File
@@ -23,8 +23,8 @@
*/
class Mustache_Engine
{
const VERSION = '2.13.0';
const SPEC_VERSION = '1.1.2';
const VERSION = '2.14.0';
const SPEC_VERSION = '1.2.2';
const PRAGMA_FILTERS = 'FILTERS';
const PRAGMA_BLOCKS = 'BLOCKS';
@@ -38,7 +38,7 @@ class Mustache_Source_FilesystemSource implements Mustache_Source
/**
* Get the Source key (used to generate the compiled class name).
*
* @throws RuntimeException when a source file cannot be read
* @throws Mustache_Exception_RuntimeException when a source file cannot be read
*
* @return string
*/
@@ -54,7 +54,7 @@ class Mustache_Source_FilesystemSource implements Mustache_Source
}
if ($this->stat === false) {
throw new RuntimeException(sprintf('Failed to read source file "%s".', $this->fileName));
throw new Mustache_Exception_RuntimeException(sprintf('Failed to read source file "%s".', $this->fileName));
}
foreach ($this->statProps as $prop) {
+3 -3
View File
@@ -88,11 +88,11 @@ class Mustache_Tokenizer
* @throws Mustache_Exception_InvalidArgumentException when $delimiters string is invalid
*
* @param string $text Mustache template source to tokenize
* @param string $delimiters Optionally, pass initial opening and closing delimiters (default: null)
* @param string $delimiters Optionally, pass initial opening and closing delimiters (default: empty string)
*
* @return array Set of Mustache tokens
*/
public function scan($text, $delimiters = null)
public function scan($text, $delimiters = '')
{
// Setting mbstring.func_overload makes things *really* slow.
// Let's do everyone a favor and scan this string as ASCII instead.
@@ -107,7 +107,7 @@ class Mustache_Tokenizer
$this->reset();
if ($delimiters = trim($delimiters)) {
if (is_string($delimiters) && $delimiters = trim($delimiters)) {
$this->setDelimiters($delimiters);
}
+1 -1
View File
@@ -192,7 +192,7 @@
<location>mustache</location>
<name>Mustache</name>
<license>MIT</license>
<version>2.13.0</version>
<version>2.14.1</version>
</library>
<library>
<location>amd/src/mustache.js</location>