X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Ftwig%2Ftwig%2Flib%2FTwig%2FExtension%2FCore.php;fp=vendor%2Ftwig%2Ftwig%2Flib%2FTwig%2FExtension%2FCore.php;h=6e5569a28f646b4c3a896f27f0d17c1d9b18bd31;hp=383a727133d5d77feeb855b4c668a283292d3bf0;hb=5e458ff8cb4924fd5fa03b80d8edfcc52fe43479;hpb=9917807b03b64faf00f6a1f29dcb6eafc454efa5 diff --git a/vendor/twig/twig/lib/Twig/Extension/Core.php b/vendor/twig/twig/lib/Twig/Extension/Core.php index 383a72713..6e5569a28 100644 --- a/vendor/twig/twig/lib/Twig/Extension/Core.php +++ b/vendor/twig/twig/lib/Twig/Extension/Core.php @@ -661,7 +661,7 @@ function twig_slice(Twig_Environment $env, $item, $start, $length = null, $prese if ($start >= 0 && $length >= 0 && $item instanceof Iterator) { try { - return iterator_to_array(new LimitIterator($item, $start, $length === null ? -1 : $length), $preserveKeys); + return iterator_to_array(new LimitIterator($item, $start, null === $length ? -1 : $length), $preserveKeys); } catch (OutOfBoundsException $exception) { return array(); } @@ -1216,7 +1216,7 @@ function _twig_escape_html_attr_callback($matches) * The following replaces characters undefined in HTML with the * hex entity for the Unicode replacement character. */ - if (($ord <= 0x1f && $chr != "\t" && $chr != "\n" && $chr != "\r") || ($ord >= 0x7f && $ord <= 0x9f)) { + if (($ord <= 0x1f && "\t" != $chr && "\n" != $chr && "\r" != $chr) || ($ord >= 0x7f && $ord <= 0x9f)) { return '�'; } @@ -1224,7 +1224,7 @@ function _twig_escape_html_attr_callback($matches) * Check if the current character to escape has a name entity we should * replace it with while grabbing the hex value of the character. */ - if (strlen($chr) == 1) { + if (1 == strlen($chr)) { $hex = strtoupper(substr('00'.bin2hex($chr), -2)); } else { $chr = twig_convert_encoding($chr, 'UTF-16BE', 'UTF-8'); @@ -1263,6 +1263,10 @@ if (function_exists('mb_get_info')) { return mb_strlen($thing, $env->getCharset()); } + if ($thing instanceof \SimpleXMLElement) { + return count($thing); + } + if (is_object($thing) && method_exists($thing, '__toString') && !$thing instanceof \Countable) { return mb_strlen((string) $thing, $env->getCharset()); } @@ -1270,7 +1274,7 @@ if (function_exists('mb_get_info')) { if ($thing instanceof \Countable || is_array($thing)) { return count($thing); } - + if ($thing instanceof \IteratorAggregate) { return iterator_count($thing); } @@ -1366,6 +1370,10 @@ else { return strlen($thing); } + if ($thing instanceof \SimpleXMLElement) { + return count($thing); + } + if (is_object($thing) && method_exists($thing, '__toString') && !$thing instanceof \Countable) { return strlen((string) $thing); } @@ -1373,7 +1381,7 @@ else { if ($thing instanceof \Countable || is_array($thing)) { return count($thing); } - + if ($thing instanceof \IteratorAggregate) { return iterator_count($thing); }