aboutsummaryrefslogtreecommitdiffstats
path: root/core/namespace
diff options
context:
space:
mode:
Diffstat (limited to 'core/namespace')
-rw-r--r--core/namespace/Application.php10
-rw-r--r--core/namespace/Parsers/FunctionParser.php19
2 files changed, 6 insertions, 23 deletions
diff --git a/core/namespace/Application.php b/core/namespace/Application.php
index 1f1e6f6..8346248 100644
--- a/core/namespace/Application.php
+++ b/core/namespace/Application.php
@@ -11,7 +11,6 @@ class Application {
private static $Language;
private static $Migrator;
private static $repositories = [];
- private static $contentFunctions = [];
#===============================================================================
# Configuration array
@@ -224,14 +223,7 @@ class Application {
contain only numbers, uppercase letters and underscores!');
}
- self::$contentFunctions[$name] = $callback;
- }
-
- #===============================================================================
- # Return all known content functions
- #===============================================================================
- public static function getContentFunctions(): array {
- return self::$contentFunctions;
+ FunctionParser::register($name, $callback);
}
#===============================================================================
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);