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

Add error handler to convert PHP errors / warnings / notices into exceptions #5259

Closed
weirdan opened this issue Feb 21, 2021 · 2 comments · Fixed by #5260
Closed

Add error handler to convert PHP errors / warnings / notices into exceptions #5259

weirdan opened this issue Feb 21, 2021 · 2 comments · Fixed by #5260

Comments

@weirdan
Copy link
Collaborator

weirdan commented Feb 21, 2021

how do you feel about introducing an error handler to convert all notices/warnings/etc into exceptions?

I think that's a great idea! Normally a notice pre-empts a fatal error anyway.

Originally posted by @muglug in #5255 (comment)

@psalm-github-bot
Copy link

Hey @weirdan, can you reproduce the issue on https://psalm.dev ?

@mr-feek
Copy link
Contributor

mr-feek commented Mar 30, 2021

Hey @weirdan @muglug -- this actually had a breaking change for me! Granted, I have a probably uncommon use case.

I have legacy code in which all warnings are silenced -- as a result, we have lots of these problems ignored in our baseline file.


Upon upgrading to psalm 4 which has this change in it, there are runtime exceptions thrown by psalm that are surfacing these warnings. This problem is surfaced when referencing a class in the universalObjectCrates config area, which subsequently autoloads the class

[root@docker local]# ./vendor/bin/psalm.phar --debug
Uncaught RuntimeException: PHP Error: Declaration of {redacted method} should be compatible with {redacted method with different params} in /var/www/{redacted} phar:///var/www/{redacted}/vendor/psalm/phar/psalm.phar/src/Psalm/Internal/ErrorHandler.php:53
Stack trace:
#0 {redacted} Psalm\Internal\ErrorHandler::Psalm\Internal\{closure}(2, 'Declaration of ...', '{redacted}', 127, Array)
#1 phar:///var/www/{redacted}vendor/psalm/phar/psalm.phar/.box/vendor/composer/ClassLoader.php(444): include('/var/www/{redacted}...')
#2 phar:///var/www/{redacted}vendor/psalm/phar/psalm.phar/.box/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile('/var/www/{redacted}...')
#3 [internal function]: Composer\Autoload\ClassLoader->loadClass({redacted}\\...')
#4 [internal function]: spl_autoload_call('{redacted}...')
#5 phar:///var/www/{redacted}vendor/psalm/phar/psalm.phar/src/Psalm/Config.php(1558): class_exists('{redacted}...', true)
#6 phar:///var/www/{redacted}/vendor/psalm/phar/psalm.phar/src/Psalm/Config.php(677): Psalm\Config->addUniversalObjectCrate('{redacted}...')
#7 phar:///var/www/{redacted}/vendor/psalm/phar/psalm.phar/src/Psalm/Config.php(507): 
...

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

Successfully merging a pull request may close this issue.

2 participants