File tree 5 files changed +45
-2
lines changed
5 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -143,11 +143,33 @@ private function resolvePaths(InputInterface $input): array
143
143
144
144
// give priority to command line
145
145
if ($ commandLinePaths !== []) {
146
+ $ this ->setFilesWithoutExtensionParameter ($ commandLinePaths );
146
147
return $ commandLinePaths ;
147
148
}
148
149
149
150
// fallback to parameter
150
- return SimpleParameterProvider::provideArrayParameter (Option::PATHS );
151
+ $ configPaths = SimpleParameterProvider::provideArrayParameter (Option::PATHS );
152
+ $ this ->setFilesWithoutExtensionParameter ($ configPaths );
153
+
154
+ return $ configPaths ;
155
+ }
156
+
157
+ /**
158
+ * @param string[] $paths
159
+ */
160
+ private function setFilesWithoutExtensionParameter (array $ paths ): void
161
+ {
162
+ foreach ($ paths as $ path ) {
163
+ if (is_file ($ path ) && pathinfo ($ path , PATHINFO_EXTENSION ) === '' ) {
164
+ $ path = realpath ($ path );
165
+
166
+ if ($ path === false ) {
167
+ continue ;
168
+ }
169
+
170
+ SimpleParameterProvider::addParameter (Option::FILES_WITHOUT_EXTENSION , $ path );
171
+ }
172
+ }
151
173
}
152
174
153
175
private function resolveMemoryLimit (InputInterface $ input ): string | null
Original file line number Diff line number Diff line change @@ -307,4 +307,9 @@ final class Option
307
307
* @internal The other half of ROOT_STANDALONE_REGISTERED_RULES to compare
308
308
*/
309
309
public const SET_REGISTERED_RULES = 'set_registered_rules ' ;
310
+
311
+ /**
312
+ * @internal to allow process file without extension if explicitly registered
313
+ */
314
+ public const FILES_WITHOUT_EXTENSION = 'files_without_extension ' ;
310
315
}
Original file line number Diff line number Diff line change @@ -70,6 +70,12 @@ public function findInDirectoriesAndFiles(
70
70
71
71
$ filteredFilePaths = array_filter ($ filteredFilePaths , $ fileWithSuffixFilter );
72
72
73
+ // add file without extension after file extension filter
74
+ $ filteredFilePaths = array_merge (
75
+ $ filteredFilePaths ,
76
+ SimpleParameterProvider::provideArrayParameter (Option::FILES_WITHOUT_EXTENSION )
77
+ );
78
+
73
79
$ filteredFilePaths = array_filter (
74
80
$ filteredFilePaths ,
75
81
function (string $ file ): bool {
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ echo 'hi';
Original file line number Diff line number Diff line change @@ -15,15 +15,17 @@ public function test(): void
15
15
$ configurationFactory = $ this ->make (ConfigurationFactory::class);
16
16
$ configuration = $ configurationFactory ->createForTests ([
17
17
__DIR__ . '/../../tests-paths/path/*/some_directory/* ' ,
18
+ __DIR__ . '/../../tests-paths/path/NoExtensionFile ' ,
18
19
]);
19
20
20
21
$ filesFinder = $ this ->make (FilesFinder::class);
21
22
22
23
$ filePaths = $ filesFinder ->findInDirectoriesAndFiles ($ configuration ->getPaths ());
23
- $ this ->assertCount (2 , $ filePaths );
24
+ $ this ->assertCount (3 , $ filePaths );
24
25
25
26
$ firstFilePath = $ filePaths [0 ];
26
27
$ secondFilePath = $ filePaths [1 ];
28
+ $ thirdFilePath = $ filePaths [2 ];
27
29
28
30
$ this ->assertSame (
29
31
realpath (__DIR__ . '/../../tests-paths/path/wildcard-nested/some_directory/AnotherFile.php ' ),
@@ -34,5 +36,10 @@ public function test(): void
34
36
realpath (__DIR__ . '/../../tests-paths/path/wildcard-next/some_directory/YetAnotherFile.php ' ),
35
37
realpath ($ secondFilePath ),
36
38
);
39
+
40
+ $ this ->assertSame (
41
+ realpath (__DIR__ . '/../../tests-paths/path/NoExtensionFile ' ),
42
+ realpath ($ thirdFilePath ),
43
+ );
37
44
}
38
45
}
You can’t perform that action at this time.
0 commit comments