diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2024-01-31 06:11:00 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2024-01-31 20:45:40 +0300 |
commit | c0dc531ebefd8912819f3b6c8bda1fed3c7e750c (patch) | |
tree | 2c75aa9df182260aef09faf4befd81a4c2b9c5e2 /lib/cli.php | |
parent | 48d688cdf7f9eae1bf11b8a6f0e5b98687c604cb (diff) |
make it simple, but not simpler
Diffstat (limited to 'lib/cli.php')
-rw-r--r-- | lib/cli.php | 8 |
1 files changed, 4 insertions, 4 deletions
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) |