phpstan-src icon indicating copy to clipboard operation
phpstan-src copied to clipboard

Fix inconsistent analysis on case-insensitive filesystems

Open staabm opened this issue 7 months ago • 1 comments

closes https://github.com/phpstan/phpstan/issues/12972

since on macos filesystem paths are case-insensitive before this PR we ran into the following error:

➜  bug-12972 git:(bug12972) ../../bin/phpstan analyse --debug 

 ! [NOTE] The Xdebug PHP extension is active, but "--xdebug" is not used.                                               
 !        The process was restarted and it will not halt at breakpoints.                                                
 !        Use "--xdebug" if you want to halt at breakpoints.                                                            

Note: Using configuration file /Users/m.staab/Documents/GitHub/phpstan-src/e2e/bug-12972/phpstan.dist.neon.
/Users/m.staab/Documents/GitHub/phpstan-src/e2e/bug-12972/src/folder/file2.php
/Users/m.staab/Documents/GitHub/phpstan-src/e2e/bug-12972/src/other/file.php
 ------ --------------------------------------------------------------------------------------------- 
  Line   other/file.php                                                                               
 ------ --------------------------------------------------------------------------------------------- 
  6      Method other12972\MyClass::doSomething() should return int but return statement is missing.  
 ------ --------------------------------------------------------------------------------------------- 

-> PHPStan is using the simple-parser instead of the rich-parser as it does not handle the analyzed path case-insentive as macOS would do (same for windows)

see

➜  phpstan-src git:(bug12972) ls -l e2e/bug-12972/src/                 
total 0
drwxr-xr-x@ 3 m.staab  staff  96 May 12 14:59 folder
drwxr-xr-x@ 3 m.staab  staff  96 May 12 14:52 other
➜  phpstan-src git:(bug12972) ls e2e/bug-12972/src/other/file.php                                                                           
e2e/bug-12972/src/other/file.php
➜  phpstan-src git:(bug12972) ls e2e/bug-12972/src/OTHER/file.php
e2e/bug-12972/src/OTHER/file.php
➜  phpstan-src git:(bug12972) php -r 'var_dump(is_file("e2e/bug-12972/src/OTHER/file.php"));'
bool(true)
➜  phpstan-src git:(bug12972) php -r 'var_dump(is_file("e2e/bug-12972/src/other/file.php"));'
bool(true)
➜  phpstan-src git:(bug12972) php -v                                                         
PHP 8.4.7 (cli) (built: May  6 2025 12:31:58) (NTS)
Copyright (c) The PHP Group
Built by Homebrew
Zend Engine v4.4.7, Copyright (c) Zend Technologies

staabm avatar May 12 '25 12:05 staabm

This pull request has been marked as ready for review.

phpstan-bot avatar May 12 '25 13:05 phpstan-bot