diff --git a/index.php b/index.php deleted file mode 100644 index d1235d8..0000000 --- a/index.php +++ /dev/null @@ -1,13 +0,0 @@ -setBasePath($basePath) ->loadEnv(); @@ -534,6 +537,7 @@ private function loadResources(): void $files = array_filter(scandir($directory), function ($file) use ($directory) { return is_file($directory . DIRECTORY_SEPARATOR . $file); }); + foreach ($files as $file) { require_once $directory . DIRECTORY_SEPARATOR . $file; } diff --git a/src/Listener/Matcher.php b/src/Listener/Matcher.php index 33df75e..04ad78f 100644 --- a/src/Listener/Matcher.php +++ b/src/Listener/Matcher.php @@ -2,8 +2,11 @@ namespace LaraGram\Listener; +use LaraGram\Request\Request; + class Matcher { + /** @var Request $request */ private mixed $request; public function match(string $type, callable $action, string|array|null $pattern) @@ -26,7 +29,7 @@ private function execute_regex($pattern, $action, $input = null) $matches = array_filter($matches, function ($value, $key) { return !is_numeric($key) && $value !== "" && $value !== null; }, ARRAY_FILTER_USE_BOTH); - return call_user_func_array($action, [$this->request, $matches]); + return call_user_func_array($action, [$this->request, ...$matches]); } return false; @@ -36,8 +39,9 @@ private function match_text(callable $action, string|array $pattern) { if (is_array($pattern)) { foreach ($pattern as $value) { - return $this->execute_regex($value, $action); + $result = $this->execute_regex($value, $action); } + return $result; } else { return $this->execute_regex($pattern, $action); }