From 16d036e76bed4857fc514167868248bffd7231db Mon Sep 17 00:00:00 2001 From: Antoine Makdessi Date: Thu, 16 Dec 2021 12:40:44 +0100 Subject: [PATCH] Update twig_extension.rst --- templating/twig_extension.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templating/twig_extension.rst b/templating/twig_extension.rst index 03fcd7a9471..ad6e6cda31b 100644 --- a/templating/twig_extension.rst +++ b/templating/twig_extension.rst @@ -42,7 +42,7 @@ Create a class that extends ``AbstractExtension`` and fill in the logic:: ]; } - public function formatPrice($number, $decimals = 0, $decPoint = '.', $thousandsSep = ',') + public function formatPrice(float $number, int $decimals = 0, string $decPoint = '.', string $thousandsSep = ','): string { $price = number_format($number, $decimals, $decPoint, $thousandsSep); $price = '$'.$price; @@ -69,7 +69,7 @@ If you want to create a function instead of a filter, define the ]; } - public function calculateArea(int $width, int $length) + public function calculateArea(int $width, int $length): int { return $width * $length; } @@ -157,7 +157,7 @@ previous ``formatPrice()`` method:: // extensions, you'll need to inject services using this constructor } - public function formatPrice($number, $decimals = 0, $decPoint = '.', $thousandsSep = ',') + public function formatPrice(float $number, int $decimals = 0, string $decPoint = '.', string $thousandsSep = ','): string { $price = number_format($number, $decimals, $decPoint, $thousandsSep); $price = '$'.$price;