Skip to content

Commit 5ee02ee

Browse files
authored
[1.x] Console commands improvements (#434)
1 parent 57ca130 commit 5ee02ee

19 files changed

+392
-528
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ vendor/
33
.idea/
44

55
.phpunit.cache
6+
.phpunit.result.cache
7+
68
.php_cs.cache
79
.php-cs-fixer.cache
810
.psalm-cache

.php-cs-fixer.dist.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
$finder = PhpCsFixer\Finder::create()
56
->in(__DIR__)
6-
->exclude('vendor');
7+
->exclude(['vendor']);
78

89
$ruleSet = [
910
'@Symfony' => true,

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
"laravel/framework": ">=8.0"
2626
},
2727
"require-dev": {
28-
"roave/security-advisories": "dev-latest",
2928
"friendsofphp/php-cs-fixer": "^3.14",
3029
"orchestra/testbench": "^6.24",
3130
"psalm/plugin-laravel": "^2.0",
31+
"psalm/plugin-phpunit": "^0.19.0",
32+
"roave/security-advisories": "dev-latest",
3233
"vimeo/psalm": "^5.11"
3334
},
3435
"autoload": {

composer.lock

+134-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

psalm.xml

+1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818

1919
<plugins>
2020
<pluginClass class="Psalm\LaravelPlugin\Plugin"/>
21+
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
2122
</plugins>
2223
</psalm>

src/Console/LiapConfigPublishCommand.php

+5-15
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@
1111
/**
1212
* This command is used to publish LIAP configuration file.
1313
*/
14-
class LiapConfigPublishCommand extends Command
14+
final class LiapConfigPublishCommand extends Command
1515
{
16-
public const MESSAGE_ALREADY_INSTALLED = 'liap.php is already published.';
17-
public const MESSAGE_SUCCESS = 'liap.php published successfully';
18-
1916
protected $signature = 'liap:config:publish {--f|force}';
20-
2117
protected $description = 'Publishes the LIAP configuration file.';
2218

2319
public function handle(): int
@@ -26,16 +22,13 @@ public function handle(): int
2622
return $this->publishConfig(true);
2723
}
2824

29-
if ($this->isInstalled()) {
25+
if ($this->isPublished()) {
3026
return $this->publishFailed();
3127
}
3228

3329
return $this->publishConfig();
3430
}
3531

36-
/**
37-
* Checks if the command should force publish the configs.
38-
*/
3932
private function shouldForce(): bool
4033
{
4134
return (bool)$this->option('force');
@@ -52,20 +45,17 @@ private function publishConfig(bool $force = false): int
5245
$params['--force'] = true;
5346
}
5447

55-
$result = $this->call('vendor:publish', $params);
56-
$this->info(self::MESSAGE_SUCCESS);
57-
58-
return $result;
48+
return $this->call('vendor:publish', $params);
5949
}
6050

61-
private function isInstalled(): bool
51+
private function isPublished(): bool
6252
{
6353
return File::exists(config_path(LiapServiceProvider::CONFIG_KEY.'.php'));
6454
}
6555

6656
private function publishFailed(): int
6757
{
68-
$this->error(self::MESSAGE_ALREADY_INSTALLED);
58+
$this->error('liap.php is already published.');
6959

7060
return self::FAILURE;
7161
}

0 commit comments

Comments
 (0)