From 9289beadbe977a2dff358adcb33e6fba9429ac8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Po=C5=82a=C4=87?= Date: Thu, 5 May 2016 20:48:57 +0200 Subject: [PATCH] Change extension's methods to static --- LambdaExtension.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/LambdaExtension.php b/LambdaExtension.php index 3e19953..09448f7 100644 --- a/LambdaExtension.php +++ b/LambdaExtension.php @@ -31,7 +31,7 @@ public function getOperators() public function getFunctions() { return [ - new \Twig_SimpleFunction('call', [$this, 'call']), + new \Twig_SimpleFunction('call', '\DPolac\TwigLambda\LambdaExtension::call'), ]; } @@ -39,7 +39,7 @@ public function getTests() { return [ new \Twig_SimpleTest('every', '\Underscore\Types\Arrays::matches'), - new \Twig_SimpleTest('any', [$this, 'any']), + new \Twig_SimpleTest('any', '\DPolac\TwigLambda\LambdaExtension::any'), ]; } @@ -56,11 +56,11 @@ public function getFilters() new \Twig_SimpleFilter('group_by', '\Underscore\Types\Arrays::group'), new \Twig_SimpleFilter('sort_by', '\Underscore\Types\Arrays::sort'), - new \Twig_SimpleFilter('count_by', [$this, 'countBy']), + new \Twig_SimpleFilter('count_by', '\DPolac\TwigLambda\LambdaExtension::countBy'), ]; } - public function countBy(array $array, $callback) + public static function countBy(array $array, $callback) { $result = []; foreach ($array as $element) { @@ -79,7 +79,7 @@ public function countBy(array $array, $callback) return $result; } - public function any(array $array, $callback) + public static function any(array $array, $callback) { if (!is_callable($callback)) { throw new \InvalidArgumentException( @@ -93,7 +93,7 @@ public function any(array $array, $callback) return Arrays::matchesAny($array, $callback); } - public function call($callback, array $args = []) + public static function call($callback, array $args = []) { if (!is_callable($callback)) { throw new \InvalidArgumentException('First argument must be callable.');