From 1add1065cf750d6c18b38ed574cab64007c217c9 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Sat, 9 Jul 2022 20:28:38 +0300 Subject: fix for template functions with default values --- lib/SkinContext.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/SkinContext.php b/lib/SkinContext.php index b4192c3..69a6f91 100644 --- a/lib/SkinContext.php +++ b/lib/SkinContext.php @@ -28,8 +28,12 @@ class SkinContext { continue; // skip $ctx $key = $plain_args ? $n-1 : $param->name; - if (!$plain_args && !array_key_exists($param->name, $arguments)) - throw new InvalidArgumentException('argument '.$param->name.' not found'); + if (!$plain_args && !array_key_exists($param->name, $arguments)) { + if (!$param->isDefaultValueAvailable()) + throw new InvalidArgumentException('argument '.$param->name.' not found'); + else + continue; + } if (is_string($arguments[$key]) || $arguments[$key] instanceof SkinString) { if (is_string($arguments[$key])) -- cgit v1.2.3