aboutsummaryrefslogtreecommitdiff
path: root/src/NXP/Classes
diff options
context:
space:
mode:
authorTimur <icq-475204@ya.ru>2019-01-10 01:51:21 +0300
committerBruce Wells <brucekwells@gmail.com>2019-01-10 01:51:21 +0300
commit808593bacfe50cb25d2edfd814135172295a884c (patch)
tree1562247fbd2c510343ad24d771c1c64f20519959 /src/NXP/Classes
parente8ede3d6a56fdef00f14de7ae8699ed4ca890712 (diff)
MathExecutor allow override default operators, functions and vars (#36)
Diffstat (limited to 'src/NXP/Classes')
-rw-r--r--src/NXP/Classes/TokenFactory.php11
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];
}