Skip to content

Commit e415366

Browse files
committed
remove some help methods. use deps lib instead
1 parent cc00b79 commit e415366

13 files changed

+82
-383
lines changed

examples/Controller/HomeController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Inhere\Console\Util\Interact;
1212
use Inhere\Console\Util\ProgressBar;
1313
use Inhere\Console\Util\Show;
14+
use Toolkit\PhpUtil\Php;
1415

1516
/**
1617
* default command controller. there are some command usage examples(1)
@@ -463,10 +464,10 @@ public function paddingCommand()
463464
public function useArgCommand()
464465
{
465466
$this->write('input arguments:');
466-
echo Helper::dumpVars($this->input->getArgs());
467+
$this->output->dump($this->input->getArgs());
467468

468469
$this->write('input options:');
469-
echo Helper::dumpVars($this->input->getOpts());
470+
$this->output->dump($this->input->getOpts());
470471

471472
$this->write('raw argv:');
472473
$this->output->dump($this->input->getTokens());
@@ -488,7 +489,7 @@ public function envCommand()
488489

489490
Show::panel($info);
490491

491-
echo Helper::printVars($_SERVER);
492+
echo Php::printVars($_SERVER);
492493
}
493494

494495
/**

src/AbstractApplication.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Inhere\Console\Traits\SimpleEventTrait;
2222
use Inhere\Console\Util\FormatUtil;
2323
use Inhere\Console\Util\Helper;
24+
use Toolkit\PhpUtil\PhpHelper;
2425

2526
/**
2627
* Class AbstractApplication
@@ -224,7 +225,7 @@ public function stop(int $code = 0)
224225
if ($this->isProfile()) {
225226
$title = '------ Runtime Stats(use --profile) ------';
226227
$stats = $this->stats;
227-
$this->stats = FormatUtil::runtime($stats['startTime'], $stats['startMemory'], $stats);
228+
$this->stats = PhpHelper::runtime($stats['startTime'], $stats['startMemory'], $stats);
228229
$this->output->write('');
229230
$this->output->aList($this->stats, $title);
230231
}

src/AbstractCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
use Inhere\Console\IO\Output;
1616
use Inhere\Console\Traits\InputOutputAwareTrait;
1717
use Inhere\Console\Traits\UserInteractAwareTrait;
18-
use Inhere\Console\Util\Annotation;
1918
use Inhere\Console\Util\FormatUtil;
2019
use Inhere\Console\Util\Helper;
2120
use Swoole\Coroutine;
21+
use Toolkit\PhpUtil\PhpDoc;
2222

2323
/**
2424
* Class AbstractCommand
@@ -505,7 +505,7 @@ protected function showHelpByMethodAnnotations(string $method, string $action =
505505
}
506506

507507
$doc = $ref->getMethod($method)->getDocComment();
508-
$tags = Annotation::getTags($this->parseAnnotationVars($doc));
508+
$tags = PhpDoc::getTags($this->parseAnnotationVars($doc));
509509
$isAlone = $ref->isSubclassOf(CommandInterface::class);
510510
$help = [];
511511

src/Controller.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
use Inhere\Console\IO\Output;
1414
use Inhere\Console\Util\FormatUtil;
1515
use Inhere\Console\Util\Helper;
16-
use Inhere\Console\Util\Annotation;
16+
use Toolkit\PhpUtil\PhpDoc;
17+
use Toolkit\StrUtil\Str;
1718

1819
/**
1920
* Class Controller
@@ -94,7 +95,7 @@ public function run(string $command = '')
9495
$command = $this->defaultAction;
9596
}
9697

97-
$this->action = FormatUtil::camelCase($this->getRealCommandName($command));
98+
$this->action = Str::camelCase($this->getRealCommandName($command));
9899

99100
if (!$this->action) {
100101
return $this->showHelp();
@@ -211,7 +212,7 @@ final public function helpCommand(): int
211212
return 0;
212213
}
213214

214-
$action = FormatUtil::camelCase($action);
215+
$action = Str::camelCase($action);
215216
$method = $this->actionSuffix ? $action . \ucfirst($this->actionSuffix) : $action;
216217
$aliases = self::getCommandAliases($action);
217218

@@ -236,7 +237,7 @@ final public function showCommandList()
236237
$sName = \lcfirst(self::getName() ?: $ref->getShortName());
237238

238239
if (!($classDes = self::getDescription())) {
239-
$classDes = Annotation::description($ref->getDocComment()) ?: 'No description for the console controller';
240+
$classDes = PhpDoc::description($ref->getDocComment()) ?: 'No description for the console controller';
240241
}
241242

242243
$commands = [];
@@ -248,7 +249,7 @@ final public function showCommandList()
248249
continue;
249250
}
250251

251-
$desc = Annotation::firstLine($m->getDocComment()) ?: $defaultDes;
252+
$desc = PhpDoc::firstLine($m->getDocComment()) ?: $defaultDes;
252253

253254
// is a annotation tag
254255
if (\strpos($desc, '@') === 0) {
@@ -318,7 +319,7 @@ protected function getAllCommandMethods(\ReflectionClass $ref = null, $onlyName
318319
$ref = $ref ?: new \ReflectionObject($this);
319320

320321
$suffix = $this->actionSuffix;
321-
$suffixLen = Helper::strLen($suffix);
322+
$suffixLen = Str::len($suffix);
322323

323324
foreach ($ref->getMethods() as $m) {
324325
$mName = $m->getName();
@@ -404,7 +405,7 @@ public function getAction(): string
404405
public function setAction(string $action): self
405406
{
406407
if ($action) {
407-
$this->action = FormatUtil::camelCase($action);
408+
$this->action = Str::camelCase($action);
408409
}
409410

410411
return $this;

src/Traits/ApplicationHelpTrait.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@
1414
*/
1515
trait ApplicationHelpTrait
1616
{
17-
17+
public function listCommand(): int
18+
{
19+
return 0;
20+
}
1821
}

src/Traits/FormatOutputAwareTrait.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Inhere\Console\Component\Style\Style;
1212
use Inhere\Console\Util\Helper;
1313
use Inhere\Console\Util\Show;
14+
use Toolkit\PhpUtil\Php;
1415

1516
/**
1617
* Class FormatOutputAwareTrait
@@ -242,14 +243,14 @@ public function json(
242243
*/
243244
public function dump(...$vars)
244245
{
245-
Show::write(Helper::dumpVars(...$vars));
246+
Show::write(Php::dumpVars(...$vars));
246247
}
247248

248249
/**
249250
* @param array ...$vars
250251
*/
251252
public function prints(...$vars)
252253
{
253-
Show::write(Helper::printVars(...$vars));
254+
Show::write(Php::printVars(...$vars));
254255
}
255256
}

src/Traits/RuntimeProfileTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Inhere\Console\Traits;
1010

1111
use Inhere\Console\Util\FormatUtil;
12+
use Toolkit\PhpUtil\PhpHelper;
1213

1314
/**
1415
* Trait RuntimeProfileTrait
@@ -80,7 +81,7 @@ public static function profileEnd(string $msg = null, array $context = [])
8081
$data = self::$profiles[$category][$name];
8182

8283
$old = $data['_profile_stats'];
83-
$data['_profile_stats'] = FormatUtil::runtime($old['startTime'], $old['startMem']);
84+
$data['_profile_stats'] = PhpHelper::runtime($old['startTime'], $old['startMem']);
8485
$data['_profile_end'] = $context;
8586
$data['_profile_msg'] = $msg;
8687

src/Util/Annotation.php

Lines changed: 0 additions & 127 deletions
This file was deleted.

0 commit comments

Comments
 (0)