File tree 4 files changed +62
-5
lines changed
4 files changed +62
-5
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,17 @@ composer require --dev laravel-fans/lint
17
17
php artisan lint:publish
18
18
```
19
19
20
+ You will find ` phpcs.xml ` and ` phpmd.xml ` in your project, feel free to change it.
21
+
20
22
## usage
21
23
24
+ ### lint all
25
+
26
+ ```
27
+ php artisan lint
28
+ php artisan lint --fix
29
+ ```
30
+
22
31
### lint code
23
32
24
33
``` shell
@@ -31,8 +40,6 @@ php artisan lint:pmd
31
40
php artisan lint:staged
32
41
```
33
42
34
- The default standard is ` phpcs.xml ` , feel free to change it.
35
-
36
43
### lint route URI
37
44
38
45
``` shell
Original file line number Diff line number Diff line change @@ -34,9 +34,11 @@ public function handle()
34
34
$ code = $ this ->call ('lint:phpcs ' , [
35
35
'files ' => $ this ->argument ('files ' ), '--fix ' => $ this ->option ('fix ' )
36
36
]);
37
- $ code += $ this ->call ('lint:pmd ' , [
38
- 'files ' => $ this ->argument ('files ' )
39
- ]);
37
+ if (!$ this ->option ('fix ' )) {
38
+ $ code += $ this ->call ('lint:pmd ' , [
39
+ 'files ' => $ this ->argument ('files ' )
40
+ ]);
41
+ }
40
42
return $ code ;
41
43
}
42
44
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace LaravelFans \Lint ;
4
+
5
+ use FilesystemIterator ;
6
+ use Illuminate \Console \Command ;
7
+ use Illuminate \Support \Facades \File ;
8
+
9
+ class LintCommand extends Command
10
+ {
11
+ /**
12
+ * The name and signature of the console command.
13
+ *
14
+ * @var string
15
+ */
16
+ protected $ signature = 'lint
17
+ {files?*}
18
+ {--fix : automatic fix} ' ;
19
+
20
+ /**
21
+ * The console command description.
22
+ *
23
+ * @var string
24
+ */
25
+ protected $ description = 'Check code style of code(including tests and routes) ' ;
26
+
27
+ /**
28
+ * Execute the console command.
29
+ *
30
+ * @return void
31
+ */
32
+ public function handle ()
33
+ {
34
+ $ code = $ this ->call ('lint:phpcs ' , [
35
+ 'files ' => $ this ->argument ('files ' ), '--fix ' => $ this ->option ('fix ' )
36
+ ]);
37
+ if (!$ this ->option ('fix ' )) {
38
+ $ code += $ this ->call ('lint:pmd ' , [
39
+ 'files ' => $ this ->argument ('files ' )
40
+ ]);
41
+ $ code += $ this ->call ('lint:route ' , [
42
+ 'files ' => $ this ->argument ('files ' )
43
+ ]);
44
+ }
45
+ return $ code ;
46
+ }
47
+ }
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ public function boot()
15
15
{
16
16
if ($ this ->app ->runningInConsole ()) {
17
17
$ this ->commands ([
18
+ LintCommand::class,
18
19
LintCodeCommand::class,
19
20
LintPmdCommand::class,
20
21
LintPhpcsCommand::class,
You can’t perform that action at this time.
0 commit comments