diff options
author | Bruce Wells <brucekwells@gmail.com> | 2019-01-10 20:45:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-10 20:45:54 +0300 |
commit | 0729b6b9bc0e3cebb868f889e88676b95c121a50 (patch) | |
tree | 1562247fbd2c510343ad24d771c1c64f20519959 /src/NXP/Classes/TokenFactory.php | |
parent | 8e9c8508cbfaa944505f7d3a988bcfce1e4d7bba (diff) |
Syncing from origin (#3)
* Documentation fixes (#34)
Fixing typos in and clarifying documentation.
* MathExecutor allow override default operators, functions and vars (#36)
Diffstat (limited to 'src/NXP/Classes/TokenFactory.php')
-rw-r--r-- | src/NXP/Classes/TokenFactory.php | 11 |
1 files changed, 8 insertions, 3 deletions
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]; } |