From 1fcb150eeb0da41450c13a2467381360f836465c Mon Sep 17 00:00:00 2001 From: Inhere Date: Sun, 5 Dec 2021 23:52:23 +0800 Subject: [PATCH] fix: syntax error on < php 7.4 --- src/CliApp.php | 2 +- test/CliAppTest.php | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/CliApp.php b/src/CliApp.php index 45a5fee..04546cd 100644 --- a/src/CliApp.php +++ b/src/CliApp.php @@ -302,7 +302,7 @@ protected function initCommandFlags(string $command, $handler): FlagsParser * * @return mixed */ - public function runHandler($handler, FlagsParser $cFlags): mixed + public function runHandler($handler, FlagsParser $cFlags) { // function name if (is_string($handler) && function_exists($handler)) { diff --git a/test/CliAppTest.php b/test/CliAppTest.php index d4bb370..b526a39 100644 --- a/test/CliAppTest.php +++ b/test/CliAppTest.php @@ -4,7 +4,6 @@ use Toolkit\PFlag\CliApp; use Toolkit\Stdlib\Obj\DataObject; -use const PHP_VERSION_ID; /** * class CliAppTest @@ -17,18 +16,16 @@ private function initApp(CliApp $app): DataObject { $buf = DataObject::new(); - if (PHP_VERSION_ID > 70400) { - $app->add('test1', fn() => $buf->set('key', 'in test1')); - } else { - $app->add('test1', function() use($buf) { - $buf->set('key', 'in test2'); - }); - } + // php 7.4+ + // $app->add('test1', fn() => $buf->set('key', 'in test1')); + $app->add('test1', function () use ($buf) { + $buf->set('key', 'in test1'); + }); $app->addCommands([ 'test2' => [ - 'desc' => 'desc for test2 command', - 'handler' => function() use($buf) { + 'desc' => 'desc for test2 command', + 'handler' => function () use ($buf) { $buf->set('key', 'in test2'); }, 'options' => [