aboutsummaryrefslogtreecommitdiffstats
path: root/core/namespace/Parsers/FunctionParser.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/namespace/Parsers/FunctionParser.php')
-rw-r--r--core/namespace/Parsers/FunctionParser.php19
1 files changed, 5 insertions, 14 deletions
diff --git a/core/namespace/Parsers/FunctionParser.php b/core/namespace/Parsers/FunctionParser.php
index 94a4c92..02570a0 100644
--- a/core/namespace/Parsers/FunctionParser.php
+++ b/core/namespace/Parsers/FunctionParser.php
@@ -3,7 +3,7 @@ namespace Parsers;
use ReflectionFunction;
class FunctionParser implements ParserInterface {
- private $functions = [];
+ private static $functions = [];
#===============================================================================
# Main regex for matching the whole function call
@@ -39,28 +39,19 @@ class FunctionParser implements ParserInterface {
#===============================================================================
# Register function
#===============================================================================
- public function register(string $name, callable $callback): void {
+ public static function register(string $name, callable $callback): void {
$Function = new ReflectionFunction($callback);
- $this->functions[$name] = [
+ self::$functions[$name] = [
'callback' => $callback,
'required' => $Function->getNumberOfRequiredParameters()
];
}
#===============================================================================
- # Register multiple functions from array
- #===============================================================================
- public function registerFromArray(array $functions): void {
- foreach($functions as $name => $callback) {
- $this->register($name, $callback);
- }
- }
-
- #===============================================================================
# Parse functions
#===============================================================================
public function parse(string $text): array {
- $functionNames = array_keys($this->functions);
+ $functionNames = array_keys(self::$functions);
$functionNames = implode('|', $functionNames);
$pattern = self::FUNCTION_PATTERN;
@@ -81,7 +72,7 @@ class FunctionParser implements ParserInterface {
# Transform functions
#===============================================================================
public function transform(string $text): string {
- $functionData = $this->functions;
+ $functionData = self::$functions;
$functionNames = array_keys($functionData);
$functionNames = implode('|', $functionNames);