diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2024-10-22 20:10:48 +0000 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2024-10-22 20:10:48 +0000 |
commit | 44982d22c9265e7022a97191e1f0b5c5e2332255 (patch) | |
tree | bc3de7563420b2c8ba9759d930eabbd8b2d3148e /engine/skin.php | |
parent | af1044821c155221a316e0fe0ee9bdc5d4c5ac1d (diff) |
skin: fix for php 8.3
Diffstat (limited to 'engine/skin.php')
-rw-r--r-- | engine/skin.php | 9 |
1 files changed, 8 insertions, 1 deletions
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) |