diff options
author | Timur <icq-475204@ya.ru> | 2019-01-10 01:51:21 +0300 |
---|---|---|
committer | Bruce Wells <brucekwells@gmail.com> | 2019-01-10 01:51:21 +0300 |
commit | 808593bacfe50cb25d2edfd814135172295a884c (patch) | |
tree | 1562247fbd2c510343ad24d771c1c64f20519959 /src/NXP/Classes | |
parent | e8ede3d6a56fdef00f14de7ae8699ed4ca890712 (diff) |
MathExecutor allow override default operators, functions and vars (#36)
Diffstat (limited to 'src/NXP/Classes')
-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]; } |