Skip to content

Commit

Permalink
feat: #33 php artisan lint
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunthegeek committed Nov 19, 2024
1 parent d88ea4e commit 6a4f669
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 5 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,17 @@ composer require --dev laravel-fans/lint
php artisan lint:publish
```

You will find `phpcs.xml` and `phpmd.xml` in your project, feel free to change it.

## usage

### lint all

```
php artisan lint
php artisan lint --fix
```

### lint code

```shell
Expand All @@ -31,8 +40,6 @@ php artisan lint:pmd
php artisan lint:staged
```

The default standard is `phpcs.xml`, feel free to change it.

### lint route URI

```shell
Expand Down
8 changes: 5 additions & 3 deletions src/LintCodeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ public function handle()
$code = $this->call('lint:phpcs', [
'files' => $this->argument('files'), '--fix' => $this->option('fix')
]);
$code += $this->call('lint:pmd', [
'files' => $this->argument('files')
]);
if (!$this->option('fix')) {
$code += $this->call('lint:pmd', [
'files' => $this->argument('files')
]);
}
return $code;
}
}
47 changes: 47 additions & 0 deletions src/LintCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace LaravelFans\Lint;

use FilesystemIterator;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;

class LintCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'lint
{files?*}
{--fix : automatic fix}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Check code style of code(including tests and routes)';

/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$code = $this->call('lint:phpcs', [
'files' => $this->argument('files'), '--fix' => $this->option('fix')
]);
if (!$this->option('fix')) {
$code += $this->call('lint:pmd', [
'files' => $this->argument('files')
]);
$code += $this->call('lint:route', [
'files' => $this->argument('files')
]);
}
return $code;
}
}
1 change: 1 addition & 0 deletions src/LintServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function boot()
{
if ($this->app->runningInConsole()) {
$this->commands([
LintCommand::class,
LintCodeCommand::class,
LintPmdCommand::class,
LintPhpcsCommand::class,
Expand Down

0 comments on commit 6a4f669

Please sign in to comment.