Open arekm opened 2 years ago
@arekm Couple of points here:
It's version installed via "brew install php-code-sniffer" on macos, they could broke something packaging it. Anyway these errors were just examples of php errors printed to stdout.
Is #1612 for 4.x also telling php to print php own errors (like deprecation errors and other) to stderr? If yes then nice and this issue can be just closed. Otherwise still room for improvement on phpcs side.
@jrfnl interestingly, I’m seeing these same PHP errors, installed via Homebrew:
♠ phpcs --version
PHP_CodeSniffer version 3.6.2 (stable) by Squiz (http://www.squiz.net)
I’ll take a look at what’s up with the Homebrew formula, seems like it’s not really v3.6.2.
I downloaded the .phar
files from the 3.6.2 release, and I’m still seeing this deprecation errors. Perhaps something else has changed?
@jeffbyrnes In that case, yes, more information would be needed and it is most likely either a Homebrew snafu or a PATH issue on your computer. Could there be multi installs on your computer, with the global phpcs
command going to an older version ?
@jrfnl so I think I tracked it down, but I’m flying a little blind.
The errors reported originally in this issue, and that I see, specify #[\ReturnTypeWillChange]
to be added.
Your commit, be8fe7250adbdb7023822f7d39f3cd5721064301, mentions #[ReturnTypeWillChange]
in the commit message, and that’s also what you added to FileList.php
and Filter.php
.
I updated those files to use #[\ReturnTypeWillChange]
instead, and the errors no longer appear when I run from my local clone.
I’ll open a PR for your consideration.
Hmm.. just did some testing with the latest PHAR files and am seeing these notices as well... I'll go do some digging in the PHAR generation to see if there's something wrong there.
Found it. The PHARs for the release are (were) being generated with PHP 7.4, which strips attributes as if they were comments.
PR #3442 already splits off the PHAR building in CI and if it had been merged, we probably would have detected this issue in CI.
I've updated that PR now to make sure the PHAR generation in CI will be done in PHP 8.0.
Other than that, @gsherwood will need to make sure to generate the PHAR files on PHP 8.0 (or higher) when doing the actual release. (or use the artifacts as generated via PR #3442 for the tagged commit)
Argh.. things are even worse... see my comment here: https://github.com/squizlabs/PHP_CodeSniffer/pull/3442#issuecomment-996072459
@jeffbyrnes You want to give the PHPCS Phar via Homebrew another try ? The PHAR files for PHPCS 3.6.2 have been regenerated and uploaded anew. Would be good to get confirmation that Homebrew picks up on that correctly.
Sure thing! I’ll give it a spin first thing tomorrow.
-- Jeff Byrnes my.pronoun.is/he/him @thejeffbyrnes thejeffbyrnes.com On Dec 16, 2021, 7:23 PM -0500, Juliette @.***>, wrote:
@jeffbyrnes You want to give the PHPCS Phar via Homebrew another try ? The PHAR files for PHPCS 3.6.2 have been regenerated and uploaded anew. Would be good to get confirmation that Homebrew picks up on that correctly. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
It seems not, and that’s probably b/c of how versioning & packaging are done with Homebrew. I’ll take a look to see if I can give it a “kick” to pick up the new phars.
Ok, I remember how this all works w/ Homebrew now; they have a packaging functionality that needs a prod to get it to re-package things if the version number hasn’t changed.
Somebody beat me to it 😆 Check Homebrew/homebrew-core#91499, that should fix things up.
@jeffbyrnes Thanks for checking this and making sure it is (going to be) picked up!
@jrfnl you’re welcome, thanks for such prompt attention to figuring out what was busted! An essential tool, esp. for those of us who only write PHP every now & then 😄
All squared up over on Homebrew, and I can confirm it installs the fixed binary, so this can be closed!
This bug isn't about that. It's about telling php to redirect errors to stderr.
This bug isn't about that. It's about telling php to redirect errors to stderr.
@arekm Well, I've been thinking about that one too and I'm not sure that's really an option for PHPCS.
Some examples of situations which I believe will need investigation before it could even be contemplated:
Generic.PHP.Syntax
sniff which lints PHP files and reports the errors in a PHPCS report. It would need investigation to see if that sniff would still work with the change you are proposing.stderr
, it will leave end-users of PHPCS with the impression that the file was scanned correctly and completely (which it was not) and that these type of bugs in sniffs would never get reported, nor fixed.I have to admit that I'd need to brush up on how error handling vs stderr
/stdout
works again, so the above may not be problematic, but IMO it will need investigating before considering this proposed change.
Describe the bug PHP errors should also go to stderr not stdout.
Current behaviour breaks external tools calling phpcs - these expect json and not mix of json with errors
Code sample + To reproduce
Current behaviour::
Fortunately PHP supports displaying errors to stderr:
which will help these tools since they parse stdout only:
so please set display errors to stderr in phpcs. Would complete #1612
Versions (please complete the following information):