File tree Expand file tree Collapse file tree 2 files changed +9
-21
lines changed
Expand file tree Collapse file tree 2 files changed +9
-21
lines changed Original file line number Diff line number Diff line change 4848use function spl_object_id ;
4949use function sprintf ;
5050use function str_ends_with ;
51+ use function strtoupper ;
5152use function substr ;
5253
5354/**
@@ -191,7 +192,8 @@ public static function postInitializeContainer(Container $container): void
191192 $ container ->getService ('typeSpecifier ' );
192193
193194 BleedingEdgeToggle::setBleedingEdge ($ container ->getParameter ('featureToggles ' )['bleedingEdge ' ]);
194- FilesystemHelper::checkIsCaseSensitive ($ container ->getParameter ('tmpDir ' ));
195+ // filename intentional in wrong case
196+ FilesystemHelper::setIsCaseSensitive (is_file (__DIR__ . '/ ' . strtoupper (__FILE__ )));
195197 }
196198
197199 public function getCurrentWorkingDirectory (): string
Original file line number Diff line number Diff line change 22
33namespace PHPStan \File ;
44
5- use function file_get_contents ;
6- use function file_put_contents ;
7- use function strtoupper ;
5+ use PHPStan \ShouldNotHappenException ;
86
97final class FilesystemHelper
108{
119
12- private const SIGNATURE_CONTENT = 'PHPStan case-sensitivity check ' ;
13-
1410 private static ?bool $ isCaseSensitive = null ;
1511
1612 public static function isCaseSensitive (): bool
1713 {
14+ if (self ::$ isCaseSensitive === null ) {
15+ throw new ShouldNotHappenException ();
16+ }
1817 return self ::$ isCaseSensitive ;
1918 }
2019
21- public static function checkIsCaseSensitive ( string $ tmpDir ): void
20+ public static function setIsCaseSensitive ( bool $ isCaseSensitive ): void
2221 {
23- if (self ::$ isCaseSensitive !== null ) {
24- return ;
25- }
26-
27- $ fileName = 'test-file-system-case-sensitivity.tmp ' ;
28- @file_put_contents ($ tmpDir . '/ ' . $ fileName , self ::SIGNATURE_CONTENT );
29-
30- if (@file_get_contents ($ tmpDir . '/ ' . strtoupper ($ fileName )) === self ::SIGNATURE_CONTENT ) {
31- self ::$ isCaseSensitive = false ;
32-
33- return ;
34- }
35-
36- self ::$ isCaseSensitive = true ;
22+ self ::$ isCaseSensitive = $ isCaseSensitive ;
3723 }
3824
3925}
You can’t perform that action at this time.
0 commit comments