-
Notifications
You must be signed in to change notification settings - Fork 101
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
Use static closures for minor performance improvement whenever instance access is not needed #729
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@westonruter LGTM, just one non-blocking question.
$this
is not used$this
is not used
@westonruter I've updated the label since this is more of an enhancement than a bug (nothing broken without this), plus changed the title slightly since that is used to auto-generate the eventual changelog for the release that this will be part of. |
$this
is not used$this
is not used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
I had a small nitpick and added a comment, but definitely not a blocker
composer.json
Outdated
@@ -15,6 +15,7 @@ | |||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7", | |||
"phpcompatibility/php-compatibility": "^9.3", | |||
"phpunit/phpunit": "^4|^5|^6|^7|^8|^9", | |||
"slevomat/coding-standard": "^8.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This coding standard requires php 7.2. Will would make this plugin break in 7.2- no.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would not break the plugin, because the composer autoloader is only used in tests.
It would just break tests running on PHP 5.6. However, right now tests are not running on this version on CI, so... 🤷
Edit: looks like there is #399 for updating tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please continue discussion at #730 (comment)
As I understand, there are three possible ways to about this:
- Have a separate composer file for PHP 7.2+
- In GHA workflow, just-in-time
composer require
this package before doingcomposer install
before running PHPCS - In GHA workflow, just-in-time
composer remove
this package before doingcomposer install
prior to running PHPUnit in PHP<7.2.
I think the third option is ideal, since all normal development environments would be running PHP 7.2+. It's only the exception case, specifically on GHA, where PHP 5.6 is needed. This would allow a developer to have all packages installed normally.
The first option doesn't seem ideal since there would be a separate composer file to maintain, and Dependabot wouldn't automatically be aware of it.
This comment was marked as duplicate.
This comment was marked as duplicate.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may not want this sniff after all. See WordPress/wordpress-develop#4457 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noting that we could still make a separate decision from core here, there are several plugins that have stricter requirements than core to enforce better coding practices. I don't feel strongly about this one, but I feel like if we can find a way that we can integrate it that remains compatible with PHP 5.6, I'd be happy to include it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not against using this rule set, but php 5.6 compat is the key here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the 5.6 compat be handled as part of #399? Without CI actually running anything in 5.6, it makes it a bit difficult to verify the compat is working, or at least it seems a bit premature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marking this as needing changes due to #730 (comment) which applies here too.
Co-authored-by: Ari Stathopoulos <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @westonruter. I left non-blocking feedback other than looks good to me.
Co-authored-by: Mukesh Panchal <[email protected]>
@felixarntz Considering your #730 (comment) I think this can move forward. |
@westonruter Can you refresh this PR please so we can hopefully merge it by tomorrow for the 2.4.0 release? |
… add/static-closures * 'trunk' of https://github.com/WordPress/performance: Wrap link around the entire third step instruction. Implement an admin notice and admin pointer to prompt admins using the SQLite module to migrate to the standalone plugin. Enhance interoperability between the SQLite module and the standalone plugin. Make Server-Timing header output more robust Reuse __return_null Replace deprecated RegExp assertions Require phpstan/phpstan-deprecation-rules Fix covers tags and a couple typos Require phpstan/phpstan-phpunit Add missing default value for message param in assertImageNotHasSource phpdoc Add missing return value null for void Fix composer script name in lint-staged Add missing parameter in phpdocc for perflab_disable_object_cache_dropin filter Add phpstan/extension-installer to allow-plugins Add phpstan config to branches.paths in php-lint workflow Run composer update Add phpstan config Add PHPStan to php-lint workflow Add package scripts and lint-staged for phpstan Require phpstan packages
@felixarntz Done ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @westonruter!
$this
is not used
Summary
Fixes #728
Relevant technical choices
SlevomatCodingStandard.Functions.StaticClosure
sniff to the PHPCS ruleset.static
where relevant.Checklist
[Focus]
orInfrastructure
label.[Type]
label.no milestone
label.