Skip to content

Commit

Permalink
Merge pull request #41 from huangdijia/adds-phpstan
Browse files Browse the repository at this point in the history
Adds phpstan package and `box phpstan` proxy command
  • Loading branch information
huangzhhui authored Oct 5, 2022
2 parents 7c7cde3 + 7846278 commit fa446ff
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ Box 需要一个 Github 访问令牌来请求 Github API,以检索包的版本
- `box composer <argument>`通过当前 box 的 PHP 版本运行任何 Composer 命令,composer bin 的版本取决于最后执行的`get composer`命令
- `box php-cs-fixer <argument>` 通过当前 box 的 PHP 版本运行任何 `php-cs-fixer` 命令,composer bin 的版本取决于最后执行的 `get php-cs-fixer` 命令
- `box cs-fix <argument>` 通过当前 box 的 PHP 版本运行 `php-cs-fixer fix` 命令,composer bin 的版本取决于最后执行的 `get php-cs-fixer` 命令
- `box phpstan <argument>` 通过当前 box 的 PHP 版本运行任何 `phpstan` 命令,composer bin 的版本取决于最后执行的 `get phpstan` 命令,此命令仅在 box v0.3.0 及以上的版本中可用
- `box version` 输出当前 box bin 的版本号
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ Box needs a Github Access Token to request github api, to retrieve the versions
- `box composer <argument>` to run any Composer command via box, the version of the composer bin depends on the last executed `get composer` command
- `box php-cs-fixer <argument>` to run any php-cs-fixer command via box, the version of the composer bin depends on the last executed `get php-cs-fixer` command
- `box cs-fix <argument>` to run `php-cs-fix fix` command via box, the version of the composer bin depends on the last executed `get php-cs-fixer` command
- `box phpstan <argument>` to run any phpstan command via box, the version of the composer bin depends on the last executed `get phpstan` command, since box v0.3.0
- `box version` to dump the current version of the box bin
4 changes: 4 additions & 0 deletions pkgs.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"composer_name": "phpunit/phpunit",
"latest_fetch_type": "packagist"
},
"phpstan": {
"repo": "phpstan/phpstan",
"bin": "phpstan.phar"
},
"php": {
"repo": "dixyes/lwmbs",
"jobs": {
Expand Down
4 changes: 2 additions & 2 deletions src/app/Command/AbstractPhpCallProxyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function configure()
public function handle()
{
$bin = $this->buildBinCommand();
$command = Str::replaceFirst($this->proxyCommand . ' ', '', (string) $this->input);
$fullCommand = sprintf('%s %s', $bin, $command);
$command = Str::replaceFirst($this->proxyCommand, '', (string) $this->input);
$fullCommand = sprintf('%s %s', $bin, trim($command));
$this->liveCommand($fullCommand);
}

Expand Down
23 changes: 23 additions & 0 deletions src/app/Command/PhpstanProxyCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact [email protected]
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/

namespace App\Command;

use Hyperf\Command\Annotation\Command;

#[Command]
class PhpstanProxyCommand extends AbstractPhpCallProxyCommand
{
protected string $proxyCommand = 'phpstan';

protected string $proxyBin = 'phpstan.phar';
}

0 comments on commit fa446ff

Please sign in to comment.