diff options
-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) |