Skip to content

Commit

Permalink
fix: syntax error on < php 7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Dec 5, 2021
1 parent 6bf883c commit 1fcb150
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/CliApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
17 changes: 7 additions & 10 deletions test/CliAppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Toolkit\PFlag\CliApp;
use Toolkit\Stdlib\Obj\DataObject;
use const PHP_VERSION_ID;

/**
* class CliAppTest
Expand All @@ -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' => [
Expand Down

0 comments on commit 1fcb150

Please sign in to comment.