Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implement GH-10024: support linting multiple files at once using php -l #10710

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

Closed
nielsdos wants to merge 5 commits into php:master from nielsdos:fix-10024

Conversation

Copy link
Member

@nielsdos nielsdos commented Feb 26, 2023

Closes GH-10024

This is supported in both the CLI and CGI modes. For CLI this required little changes.

For CGI, the tricky part was that the options parsing happens inside the loop. This means that options passed after the -l flag were previously simply ignored. As we now re-enter the loop we would parse the options again, and if they are handled but don't set the script name, then CGI will think you want to read from standard in. To keep the same "don't parse options" behaviour I simply wrapped the options handling inside an if.

staabm, wickedOne, and zeriyoshi reacted with hooray emoji staabm and williamdes reacted with heart emoji
Copy link
Contributor

staabm commented Feb 26, 2023

Thank you for working on it 🙏.

Could you give an indication what the perf difference is linting e.g. 2 or 3 (or a few) files in a row vs. in a single process?

The thesis of the initial issue was, that it should be way faster.

Copy link
Member Author

Sure.

For the root folder of Wordpress (15 files) I get 0.013s for linting them all at once, and I get 0.154s when linting them one by one.

For two files I get 0.009s for linting them all at once, and 0.018s for linting them one by one. It's not a coincidence that it's twice as much for linting one by one because the overhead outweighs everything else in this case.

So yeah, it's better for performance.

staabm and williamdes reacted with rocket emoji

Copy link
Contributor

staabm commented Mar 15, 2023

Can this PR land in PHP 8.2.x or can such a change only be done in 8.3.x

Copy link
Member Author

Can this PR land in PHP 8.2.x or can such a change only be done in 8.3.x

It's a new feature so unfortunately you'll have to wait as this will land in 8.3

staabm and iluuu1994 reacted with thumbs up emoji

Copy link
Contributor

staabm commented Jun 9, 2023

@nielsdos any chance this could slip into 8.3?

alfredbez reacted with thumbs up emoji

Copy link
Member Author

nielsdos commented Jun 9, 2023

@nielsdos any chance this could slip into 8.3?

I've re-requested a review.

staabm reacted with thumbs up emoji

Copy link
Contributor

staabm commented Jun 14, 2023

Anyone else could review the changes? Would be great this PR could be part of PHP 8.3, as it is the foundation for speeding up php linting tools which can potentially save a lot of CI time

Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM, thanks @nielsdos!

staabm reacted with hooray emoji staabm reacted with heart emoji
Array
(
[0] => No syntax errors detected in %s012_good.test.php
[1] => No input file specified.
Copy link
Member

@iluuu1994 iluuu1994 Jun 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error is a bit confusing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this comes from lines 2457-2460. Either we can change the error message for CGI in general, or special case the linting case. I think changing the message in general might be dangerous for BC though.

Array
(
[0] => No syntax errors detected in %s012_good.test.php
[1] => No input file specified.
Copy link
Member

@iluuu1994 iluuu1994 Jun 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This differs in behavior with CLI, in that it aborts when a file is not found. Is this a limitation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we'd need to change error handling in lines 2451-2488: if a file cannot be opened or accessed CGI aborts. But I'm not sure if we should special case it because it will make things more complicated and possibly slow down regular use of CGI. Let me know what you think.

Copy link
Member

@iluuu1994 iluuu1994 Jun 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt linting is often used with php-cgi, so this should be ok.

nielsdos reacted with thumbs up emoji
nielsdos added 4 commits June 29, 2023 21:06
...hp -l
This is supported in both the CLI and CGI modes. For CLI this required
little changes.
For CGI, the tricky part was that the options parsing happens inside the
loop. This means that options passed after the -l flag were previously
simply ignored. As we now re-enter the loop we would parse the options
again, and if they are handled but don't set the script name, then CGI
will think you want to read from standard in. To keep the same "don't
parse options" behaviour I simply wrapped the options handling inside an
if.
Copy link
Contributor

staabm commented Jul 5, 2023

thank you so much to anyone who made this possible!!

nielsdos reacted with hooray emoji

Reviewers

@iluuu1994 iluuu1994 iluuu1994 left review comments

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

support linting multiple files at once using php -l

AltStyle によって変換されたページ (->オリジナル) /