mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-19 05:46:41 +00:00
Length filter non-mb_string on 7.x fix.
This commit is contained in:
@@ -1363,6 +1363,10 @@ else {
|
|||||||
*/
|
*/
|
||||||
function twig_length_filter(Twig_Environment $env, $thing)
|
function twig_length_filter(Twig_Environment $env, $thing)
|
||||||
{
|
{
|
||||||
|
if (null === $thing) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (is_scalar($thing)) {
|
if (is_scalar($thing)) {
|
||||||
return strlen($thing);
|
return strlen($thing);
|
||||||
}
|
}
|
||||||
@@ -1371,7 +1375,11 @@ else {
|
|||||||
return strlen((string) $thing);
|
return strlen((string) $thing);
|
||||||
}
|
}
|
||||||
|
|
||||||
return count($thing);
|
if ($thing instanceof \Countable || is_array($thing)) {
|
||||||
|
return count($thing);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user