-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
phpcbf does not report errors #3642
Comments
Too little information to go on. Also, not all errors are fixable. |
With PHP 8.1: PHPCS says:
PHPCBF says:
However with PHP 7.4 phpcbf does find and fix errors. phpcbf aborts due to the error in that sniff file, without any indication that it encountered an error. But without running phpcs you would never know about it. |
@kkmuffme This is not an issue in PHP_CodeSniffer, but this is a known issue with WordPressCS and has already been fixed. Unfortunately, the release has been delayed for reasons. Until the new release has been tagged, run WPCS on PHP 7.4. |
I know. This is just an example, I have about 20 more from different sniff providers. The problem is not with the WPCS sniff, but that phpcbf does not output this error when it aborts, due to an internal error in a sniff. |
Just like All the same, your point about improving the user facing information when a PHP error occurs in one of the sniffs running fixers is well taken and something, which I agree, should be looked into. |
I think you misunderstood me: |
@kkmuffme I didn't misunderstand you. |
I get what you're saying and it's pretty easy to replicate undesired behaviour with a poorly coded sniff. PHPCBF does throw an exception of type I definitely don't get a message that no fixable errors were found; PHPCBF dies well before that. I agree that improvement would be good here, but I feel like there might be a solution there somewhere with how the script is being run or your PHP settings. Is is possible that fatal errors are being suppressed in some way? |
I was getting a similar message. Downgrading to PHP 8.0 seemed to clear the issue for now. |
Where exactly? Could you send me a link to the specific line of the phpcbf sourcewhere that should happen in that case? bc I definitely doesn't happen for me for notices caused by PHP 8.1 specific issues.
just basic CLI "php /.../phpcbf ..."
Fatal errors cannot be suppressed to not stop code execution in PHP |
You may want to have a look at set_error_handler().... The fatals you are talking about are all catchable exceptions, so if PHPCS is run with a wrapper around it (like some IDEs do), this could well be happening. |
I think this was a misunderstanding: a "Fatal error" in my mind was an uncatchable exeption (or only catchable via register shutdown function last_error), like E_COMPILE_ERROR. But @gsherwood you are right: we have a custom Issue is found though. Should I leave this open for that phpcbf change or close it? |
Marking as duplicate of #2871 |
When a sniff has a PHP error, phpcbf just says "No fixable errors were found", whereas phpcs shows the sniff file + line + error message.
The text was updated successfully, but these errors were encountered: