junstyle / vscode-php-cs-fixer

PHP CS Fixer extension for VS Code
https://marketplace.visualstudio.com/items?itemName=junstyle.php-cs-fixer
MIT License
357 stars 45 forks source link

Extension crashes on undefined functions #210

Open Zankaria opened 10 months ago

Zankaria commented 10 months ago

If the extension finds an undefined function anywhere in the code, it crashes. A formatting extension should still be able to format the callsite without crashing.

[
  "fix",
  "--using-cache=no",
  "--format=json",
  "--config=/home/zankaria/Projects/vichan/.php-cs-fixer.php",
  "--path-mode=override",
  "/tmp/pcf-tmp0.9215133895888903/.php-cs-fixer.php"
]
PHP Fatal error:  Uncaught Error: Call to undefined function _() in /home/zankaria/Projects/vichan/inc/config.php:565
Stack trace:
#0 /home/zankaria/Projects/vichan/inc/functions.php(145): require()
#1 /home/zankaria/Projects/vichan/inc/functions.php(20): loadConfig()
#2 /home/zankaria/Projects/vichan/vendor/composer/autoload_real.php(41): require('...')
#3 /home/zankaria/Projects/vichan/vendor/composer/autoload_real.php(45): {closure}()
#4 /home/zankaria/Projects/vichan/vendor/autoload.php(25): ComposerAutoloaderInit9ab809f218224ff51233bb0f471eb557::getLoader()
#5 /home/zankaria/Projects/vichan/vendor/friendsofphp/php-cs-fixer/php-cs-fixer(89): require_once('...')
#6 /home/zankaria/Projects/vichan/vendor/friendsofphp/php-cs-fixer/php-cs-fixer(91): {closure}()
#7 {main}
  thrown in /home/zankaria/Projects/vichan/inc/config.php on line 565
junstyle commented 10 months ago

how to reproduce this issue?

Zankaria commented 10 months ago

I downloaded vichan mainline, installed php-cs-fixer with composer require --dev friendsofphp/php-cs-fixer --ignore-platform-req=ext-gd --ignore-platform-req=ext-bcmath, configured the VSCode extension to point to the installation in vichan/vendor/friendsofphp/php-cs-fixer/php-cs-fixer, and tried to run it on any project file.

Should I perhaps reopen this issue in the php-cs-fixer repo?