@@ -39,7 +39,6 @@ class LintCommand extends Command
39
39
private $ displayCorrectFiles ;
40
40
private $ directoryIteratorProvider ;
41
41
private $ isReadableProvider ;
42
- private $ config ;
43
42
44
43
public function __construct (string $ name = null , callable $ directoryIteratorProvider = null , callable $ isReadableProvider = null )
45
44
{
@@ -95,9 +94,31 @@ protected function execute(InputInterface $input, OutputInterface $output)<
10000
/div>
95
94
{
96
95
$ io = new SymfonyStyle ($ input , $ output );
97
96
$ filenames = (array ) $ input ->getArgument ('filename ' );
97
+ $ config = $ input ->getOption ('config ' );
98
98
$ excludes = $ input ->getOption ('exclude ' );
99
99
$ this ->format = $ input ->getOption ('format ' );
100
- $ this ->config = $ input ->getOption ('config ' );
100
+ $ flags = $ input ->getOption ('parse-tags ' );
101
+
102
+ if ($ config ) {
103
+ if (!file_exists ($ config )) {
104
+ throw new RuntimeException (sprintf ('Lint config "%s" not found. ' , $ config ));
105
+ }
106
+
107
+ $ lintConfig = $ this ->parseLintConfig ($ config );
108
+
109
+ if (null === $ this ->format && isset ($ lintConfig ['format ' ])) {
110
+ $ this ->format = $ lintConfig ['format ' ];
111
+ }
112
+ if (false === $ flags && isset ($ lintConfig ['parse-tags ' ])) {
113
+ $ flags = $ lintConfig ['parse-tags ' ];
114
+ }
115
+ if (!\count ($ filenames ) && isset ($ lintConfig ['includes ' ])) {
116
+ $ filenames = $ lintConfig ['includes ' ];
117
+ }
118
+ if (!\count ($ excludes ) && isset ($ lintConfig ['excludes ' ])) {
119
+ $ excludes = $ lintConfig ['excludes ' ];
120
+ }
121
+ }
101
122
102
123
if ('github ' === $ this ->format && !class_exists (GithubActionReporter::class)) {
103
124
throw new \InvalidArgumentException ('The "github" format is only available since "symfony/console" >= 5.3. ' );
@@ -108,21 +129,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
108
129
$ this ->format = class_exists (GithubActionReporter::class) && GithubActionReporter::isGithubActionEnvironment () ? 'github ' : 'txt ' ;
109
130
}
110
131
111
- $ this ->displayCorrectFiles = $ output ->isVerbose ();
112
- $ flags = $ input ->getOption ('parse-tags ' ) ? Yaml::PARSE_CUSTOM_TAGS : 0 ;
113
-
114
- if ($ this ->config ) {
115
- if (!file_exists ($ this ->config )) {
116
- throw new RuntimeException (sprintf ('Lint config "%s" not found. ' , $ this ->config ));
117
- }
132
+ $ flags = $ flags ? Yaml::PARSE_CUSTOM_TAGS : 0 ;
118
133
119
- $ lintConfig = $ this ->parseLintConfig ($ this ->config );
120
-
121
- $ this ->format = $ lintConfig ['format ' ] ?? $ this ->format ;
122
- $ flags = $ lintConfig ['parse-tags ' ] ?? $ flags ;
123
- $ filenames = $ lintConfig ['includes ' ] ?? [];
124
- $ excludes = $ lintConfig ['excludes ' ] ?? $ excludes ;
125
- }
134
+ $ this ->displayCorrectFiles = $ output ->isVerbose ();
126
135
127
136
if (['- ' ] === $ filenames ) {
128
137
return $ this ->display ($ io , [$ this ->validate (file_get_contents ('php://stdin ' ), $ flags )]);
0 commit comments