mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-04 06:30:57 +00:00
The deprecated null value for the method round has been changed to zero.
This commit is contained in:
committed by
Fabien Potencier
parent
4c225d504f
commit
7d0e5d6a1e
@@ -581,6 +581,8 @@ function twig_replace_filter($str, $from)
|
||||
*/
|
||||
function twig_round($value, $precision = 0, $method = 'common')
|
||||
{
|
||||
$value = (float) $value;
|
||||
|
||||
if ('common' === $method) {
|
||||
return round($value, $precision);
|
||||
}
|
||||
@@ -589,8 +591,6 @@ function twig_round($value, $precision = 0, $method = 'common')
|
||||
throw new RuntimeError('The round filter only supports the "common", "ceil", and "floor" methods.');
|
||||
}
|
||||
|
||||
$value = (float) $value;
|
||||
|
||||
return $method($value * 10 ** $precision) / 10 ** $precision;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
{{ ''|round(-1, 'floor')}}
|
||||
{{ null|round(-1, 'floor')}}
|
||||
{{ null|round }}
|
||||
{{ null|round(2, 'ceil') }}
|
||||
--DATA--
|
||||
return []
|
||||
--EXPECT--
|
||||
@@ -28,3 +30,5 @@ return []
|
||||
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
|
||||
Reference in New Issue
Block a user