diff -ru src/Extension/CoreExtension.php src/Extension/CoreExtension.php --- src/Extension/CoreExtension.php 2024-02-10 09:36:15.915878535 +0000 +++ src/Extension/CoreExtension.php 2024-02-10 09:36:21.407064888 +0000 @@ -84,7 +84,7 @@ { private $dateFormats = ['F j, Y H:i', '%d days']; private $numberFormat = [0, '.', ',']; - private $timezone = null; + private $timezone; /** * Sets the default format to be used by the date filter. @@ -458,7 +458,6 @@ * Returns a formatted string. * * @param string|null $format - * @param ...$values * * @return string * @@ -543,7 +542,7 @@ public static function replaceFilter($str, $from) { if (!is_iterable($from)) { - throw new RuntimeError(sprintf('The "replace" filter expects an array or "Traversable" as replace values, got "%s".', \is_object($from) ? \get_class($from) : \gettype($from))); + throw new RuntimeError(sprintf('The "replace" filter expects an array or "Traversable" as replace values, got "%s".', \is_object($from) ? $from::class : \gettype($from))); } return strtr($str ?? '', self::toArray($from)); @@ -1451,10 +1450,10 @@ { if (null !== $object) { if ('class' === $constant) { - return \get_class($object); + return $object::class; } - $constant = \get_class($object).'::'.$constant; + $constant = $object::class.'::'.$constant; } if (!\defined($constant)) { @@ -1485,7 +1484,7 @@ return true; } - $constant = \get_class($object).'::'.$constant; + $constant = $object::class.'::'.$constant; } return \defined($constant); @@ -1505,7 +1504,7 @@ public static function arrayBatch($items, $size, $fill = null, $preserveKeys = true) { if (!is_iterable($items)) { - throw new RuntimeError(sprintf('The "batch" filter expects an array or "Traversable", got "%s".', \is_object($items) ? \get_class($items) : \gettype($items))); + throw new RuntimeError(sprintf('The "batch" filter expects an array or "Traversable", got "%s".', \is_object($items) ? $items::class : \gettype($items))); } $size = ceil($size); @@ -1567,9 +1566,9 @@ } if ($object instanceof \ArrayAccess) { - $message = sprintf('Key "%s" in object with ArrayAccess of class "%s" does not exist.', $arrayItem, \get_class($object)); + $message = sprintf('Key "%s" in object with ArrayAccess of class "%s" does not exist.', $arrayItem, $object::class); } elseif (\is_object($object)) { - $message = sprintf('Impossible to access a key "%s" on an object of class "%s" that does not implement ArrayAccess interface.', $item, \get_class($object)); + $message = sprintf('Impossible to access a key "%s" on an object of class "%s" that does not implement ArrayAccess interface.', $item, $object::class); } elseif (\is_array($object)) { if (empty($object)) { $message = sprintf('Key "%s" does not exist as the array is empty.', $arrayItem); @@ -1633,7 +1632,7 @@ static $cache = []; - $class = \get_class($object); + $class = $object::class; // object method // precedence: getXxx() > isXxx() > hasXxx() @@ -1754,7 +1753,7 @@ public static function arrayFilter(Environment $env, $array, $arrow) { if (!is_iterable($array)) { - throw new RuntimeError(sprintf('The "filter" filter expects an array or "Traversable", got "%s".', \is_object($array) ? \get_class($array) : \gettype($array))); + throw new RuntimeError(sprintf('The "filter" filter expects an array or "Traversable", got "%s".', \is_object($array) ? $array::class : \gettype($array))); } self::checkArrowInSandbox($env, $arrow, 'filter', 'filter');