Skip to content

Commit d95005a

Browse files
authored
Allow dot-prefixed config files
1 parent 562b730 commit d95005a

File tree

10 files changed

+51
-7
lines changed

10 files changed

+51
-7
lines changed

src/Command/CommandHelper.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,15 @@ public static function begin(
179179
})($autoloadFile);
180180
}
181181
if ($projectConfigFile === null) {
182-
foreach (['phpstan.neon', 'phpstan.neon.dist', 'phpstan.dist.neon'] as $discoverableConfigName) {
182+
$discoverableConfigNames = [
183+
'.phpstan.neon',
184+
'.phpstan.neon.dist',
185+
'.phpstan.dist.neon',
186+
'phpstan.neon',
187+
'phpstan.neon.dist',
188+
'phpstan.dist.neon',
189+
];
190+
foreach ($discoverableConfigNames as $discoverableConfigName) {
183191
$discoverableConfigFile = $currentWorkingDirectory . DIRECTORY_SEPARATOR . $discoverableConfigName;
184192
if (is_file($discoverableConfigFile)) {
185193
$projectConfigFile = $discoverableConfigFile;

tests/PHPStan/Command/AnalyseCommandTest.php

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,28 @@ public static function autoDiscoveryPathsProvider(): array
7878
{
7979
return [
8080
[
81-
__DIR__ . '/test-autodiscover',
82-
__DIR__ . DIRECTORY_SEPARATOR . 'test-autodiscover' . DIRECTORY_SEPARATOR . 'phpstan.neon',
81+
__DIR__ . '/test-autodiscover-dot',
82+
__DIR__ . DIRECTORY_SEPARATOR . 'test-autodiscover-dot' . DIRECTORY_SEPARATOR . '.phpstan.neon',
8383
],
8484
[
85-
__DIR__ . '/test-autodiscover-dist',
86-
__DIR__ . DIRECTORY_SEPARATOR . 'test-autodiscover-dist' . DIRECTORY_SEPARATOR . 'phpstan.neon.dist',
85+
__DIR__ . '/test-autodiscover-dot-dist',
86+
__DIR__ . DIRECTORY_SEPARATOR . 'test-autodiscover-dot-dist' . DIRECTORY_SEPARATOR . '.phpstan.neon.dist',
8787
],
8888
[
89-
__DIR__ . '/test-autodiscover-dist-dot-neon',
90-
__DIR__ . DIRECTORY_SEPARATOR . 'test-autodiscover-dist-dot-neon' . DIRECTORY_SEPARATOR . 'phpstan.dist.neon',
89+
__DIR__ . '/test-autodiscover-dot-dist-dot-neon',
90+
__DIR__ . DIRECTORY_SEPARATOR . 'test-autodiscover-dot-dist-dot-neon' . DIRECTORY_SEPARATOR . '.phpstan.dist.neon',
91+
],
92+
[
93+
__DIR__ . '/test-autodiscover-no-dot',
94+
__DIR__ . DIRECTORY_SEPARATOR . 'test-autodiscover-no-dot' . DIRECTORY_SEPARATOR . 'phpstan.neon',
95+
],
96+
[
97+
__DIR__ . '/test-autodiscover-no-dot-dist',
98+
__DIR__ . DIRECTORY_SEPARATOR . 'test-autodiscover-no-dot-dist' . DIRECTORY_SEPARATOR . 'phpstan.neon.dist',
99+
],
100+
[
101+
__DIR__ . '/test-autodiscover-no-dot-dist-dot-neon',
102+
__DIR__ . DIRECTORY_SEPARATOR . 'test-autodiscover-no-dot-dist-dot-neon' . DIRECTORY_SEPARATOR . 'phpstan.dist.neon',
91103
],
92104
[
93105
__DIR__ . '/test-autodiscover-priority',
@@ -97,6 +109,10 @@ public static function autoDiscoveryPathsProvider(): array
97109
__DIR__ . '/test-autodiscover-priority-dist-dot-neon',
98110
__DIR__ . DIRECTORY_SEPARATOR . 'test-autodiscover-priority-dist-dot-neon' . DIRECTORY_SEPARATOR . 'phpstan.neon',
99111
],
112+
[
113+
__DIR__ . '/test-autodiscover-priority-dot',
114+
__DIR__ . DIRECTORY_SEPARATOR . 'test-autodiscover-priority-dot' . DIRECTORY_SEPARATOR . '.phpstan.neon',
115+
],
100116
];
101117
}
102118

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
includes:
2+
- ../../../../conf/bleedingEdge.neon
3+
4+
parameters:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
includes:
2+
- ../../../../conf/bleedingEdge.neon
3+
4+
parameters:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
includes:
2+
- ../../../../conf/bleedingEdge.neon
3+
4+
parameters:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
includes:
2+
- ../../../../conf/bleedingEdge.neon
3+
4+
parameters:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
includes:
2+
- ../../../../conf/bleedingEdge.neon
3+
4+
parameters:

0 commit comments

Comments
 (0)