From c0dc531ebefd8912819f3b6c8bda1fed3c7e750c Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Wed, 31 Jan 2024 06:11:00 +0300 Subject: make it simple, but not simpler --- lib/cli.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/cli.php') diff --git a/lib/cli.php b/lib/cli.php index a860871..910f4c1 100644 --- a/lib/cli.php +++ b/lib/cli.php @@ -4,7 +4,7 @@ class cli { protected ?array $commandsCache = null; - public function __construct( + function __construct( protected string $ns ) {} @@ -21,7 +21,7 @@ class cli { exit(is_null($error) ? 0 : 1); } - public function getCommands(): array { + function getCommands(): array { if (is_null($this->commandsCache)) { $funcs = array_filter(get_defined_functions()['user'], fn(string $f) => str_starts_with($f, $this->ns)); $funcs = array_map(fn(string $f) => str_replace('_', '-', substr($f, strlen($this->ns.'\\'))), $funcs); @@ -30,10 +30,10 @@ class cli { return $this->commandsCache; } - public function run(): void { + function run(): void { global $argv, $argc; - if (PHP_SAPI != 'cli') + if (!is_cli()) cli::die('SAPI != cli'); if ($argc < 2) -- cgit v1.2.3