From 44982d22c9265e7022a97191e1f0b5c5e2332255 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Tue, 22 Oct 2024 20:10:48 +0000 Subject: skin: fix for php 8.3 --- engine/skin.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/engine/skin.php b/engine/skin.php index a589370..ca5fe61 100644 --- a/engine/skin.php +++ b/engine/skin.php @@ -105,7 +105,14 @@ class SkinContext { $fn = $this->ns.'\\'.$name; $refl = new ReflectionFunction($fn); $fparams = $refl->getParameters(); - assert(count($fparams) == count($arguments) + 1, "$fn: invalid number of arguments (".count($fparams)." != ".(count($arguments) + 1).")"); + $fparams_required_count = 0; + foreach ($fparams as $param) { + if (!$param->isDefaultValueAvailable()) + $fparams_required_count++; + } + $given_count = count($arguments)+1; + assert($given_count >= $fparams_required_count && $given_count <= count($fparams), + "$fn: invalid number of arguments (function has ".$fparams_required_count." required arguments".(count($fparams) != $fparams_required_count ? ' and '.count($fparams).' total argumments' : '').", received ".(count($arguments) + 1).")"); foreach ($fparams as $n => $param) { if ($n == 0) -- cgit v1.2.3