Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for not stopping the execution of psalm even when a error occurs. #141

Merged
merged 2 commits into from
Apr 17, 2021
Merged

Added support for not stopping the execution of psalm even when a error occurs. #141

merged 2 commits into from
Apr 17, 2021

Conversation

yaegassy
Copy link
Contributor

Description

Close #140

In some cases, psalm-plugin-laravel will stop psalm parsing if a error occurs.

I've addressed this issue by using try/catch to early return.

Before

sample$ ./vendor/bin/psalm --no-cache
Scanning files...

   Psalm\Exception\ConfigException

  Failed to load plugin Psalm\LaravelPlugin\Plugin

  at vendor/vimeo/psalm/src/Psalm/Config.php:1158
    1154▕                  */
    1155▕                 $plugin_object = new $plugin_class_name;
    1156▕                 $plugin_object($socket, $plugin_config);
    1157▕             } catch (\Throwable $e) {
  ➜ 1158▕                 throw new ConfigException('Failed to load plugin ' . $plugin_class_name, 0, $e);
    1159▕             }
    1160▕
    1161▕             $project_analyzer->progress->debug('Loaded plugin ' . $plugin_class_name . ' successfully' . PHP_EOL);
    1162▕         }

  1   app/Models/User.php:4
      ParseError::("syntax error, unexpected token "namespace"")

      +1 vendor frames
  3   [internal]:0
      Composer\Autoload\ClassLoader::loadClass("App\Models\User")

After

The psalm analysis will complete correctly.

sample$ ./vendor/bin/psalm --no-cache
Scanning files...
Analyzing files...

░░░░░░░░░░░░░░░░░░░E

ERROR: UndefinedConstant - app/Models/User.php:2:1 - Const dummy is not defined (see https://psalm.dev/020)
dummy


ERROR: ParseError - app/Models/User.php:4:1 - Syntax error, unexpected T_NAMESPACE on line 4 (see https://psalm.dev/173)
namespace App\Models;


------------------------------
2 errors found
------------------------------
8 other issues found.
You can display them with --show-info=true
------------------------------

Checks took 8.51 seconds and used 393.066MB of memory
Psalm was able to infer types for 93.9394% of the codebase

@mr-feek
Copy link
Collaborator

mr-feek commented Apr 17, 2021

Might catching Throwable be better here?

@yaegassy
Copy link
Contributor Author

@mr-feek Thank you for the review, I changed it to Throwable.

@mr-feek
Copy link
Collaborator

mr-feek commented Apr 17, 2021

awesome, thanks for the pr!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants