mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 11:56:50 +00:00
minor #2469 Length filter non-mb_string on 7.x fix. (SpacePossum)
This PR was merged into the 1.x branch.
Discussion
----------
Length filter non-mb_string on 7.x fix.
follow up on https://github.com/twigphp/Twig/pull/2462
after https://github.com/twigphp/Twig/issues/2464#issuecomment-301014241
Commits
-------
3aa2e884 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)
|
||||
{
|
||||
if (null === $thing) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (is_scalar($thing)) {
|
||||
return strlen($thing);
|
||||
}
|
||||
@@ -1371,7 +1375,11 @@ else {
|
||||
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