Skip to content

Commit ee5bdd6

Browse files
committed
Handle exclusions correctly
1 parent 78eb04a commit ee5bdd6

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/phpcs.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
use Phpcq\PluginApi\Version10\Configuration\PluginConfigurationBuilderInterface;
46
use Phpcq\PluginApi\Version10\Configuration\PluginConfigurationInterface;
57
use Phpcq\PluginApi\Version10\DiagnosticsPluginInterface;
@@ -43,6 +45,16 @@ public function describeConfiguration(PluginConfigurationBuilderInterface $confi
4345
)
4446
->isRequired()
4547
->withDefaultValue(false);
48+
$configOptionsBuilder
49+
->describeStringListOption(
50+
'excluded',
51+
'List of excluded paths.'
52+
);
53+
$configOptionsBuilder
54+
->describeStringListOption(
55+
'excluded_sniffs',
56+
'List of excluded sniffs.'
57+
);
4658
}
4759

4860
public function createDiagnosticTasks(
@@ -82,8 +94,16 @@ private function buildArguments(
8294
$arguments[] = '--standard=' . $config->getString('standard');
8395
}
8496

85-
if ([] !== ($excluded = $config->getStringList('excluded'))) {
86-
$arguments[] = '--exclude=' . implode(',', $excluded);
97+
if ($config->has('excluded')) {
98+
if ([] !== ($excluded = $config->getStringList('excluded'))) {
99+
$arguments[] = '--ignore=' . implode(',', $excluded);
100+
}
101+
}
102+
103+
if ($config->has('excluded_sniffs')) {
104+
if ([] !== ($excluded = $config->getStringList('excluded_sniffs'))) {
105+
$arguments[] = '--exclude=' . implode(',', $excluded);
106+
}
87107
}
88108

89109
if ($config->has('custom_flags')) {

0 commit comments

Comments
 (0)