From 0729b6b9bc0e3cebb868f889e88676b95c121a50 Mon Sep 17 00:00:00 2001 From: Bruce Wells Date: Thu, 10 Jan 2019 12:45:54 -0500 Subject: Syncing from origin (#3) * Documentation fixes (#34) Fixing typos in and clarifying documentation. * MathExecutor allow override default operators, functions and vars (#36) --- src/NXP/Classes/TokenFactory.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/NXP/Classes') diff --git a/src/NXP/Classes/TokenFactory.php b/src/NXP/Classes/TokenFactory.php index 6956f31..4ed55af 100644 --- a/src/NXP/Classes/TokenFactory.php +++ b/src/NXP/Classes/TokenFactory.php @@ -50,12 +50,17 @@ class TokenFactory /** * Add function - * @param string $name + * @param string $name * @param callable $function - * @param int $places + * @param int $places + * @throws \ReflectionException */ - public function addFunction($name, callable $function, $places = 1) + public function addFunction($name, callable $function, $places = null) { + if ($places === null) { + $reflector = new \ReflectionFunction($function); + $places = $reflector->getNumberOfParameters(); + } $this->functions[$name] = [$places, $function]; } -- cgit v1.2.3