-
Notifications
You must be signed in to change notification settings - Fork 179
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
Update PHP-Scoper to v0.16.2 #10407
Comments
So is the recommendation here to use these packages? Then removing this ? Lines 176 to 258 in d16f28f
|
First of all we should remove all our That should be trivial. Just an array of functions and constants and class names. Afterwards, most likely in its own ticket, we can look into automating it somehow. It needs more thinking on how best to solve that part. I would like to avoid using these packages you mentioned. They are not really well maintained and not up-to-date, just proof-of-concepts. However, the underlying https://github.com/sniccowp/php-scoper-excludes utility shows how it could be done. |
@swissspidy Hey there, I'm the creator of these packages. We'll maintain them for a good time to come, php-scoper is very vital to a big framework we are going to release for WordPress. I'd like to automate the release of the stubs, but I don't know quite now what the best approach would be since it requires php-stubs/wordpress-stubs. |
@calvinalkan hey there, thanks for chiming in! Since it requires A GiHub actions sounds interesting too, but then I'd probably set one up for ourselves in this repo, so that we don't have to require an extra composer package for it. |
Okay so there two use cases.
with whatever version tag you need for your project. IMO this should always be the latest stable tag of WordPress itself that's why Id like to automate this to the maximum degree possible so that your plugin can require it as "require-dev": {
"sniccowp/php-scoper-wordpress-excludes" : "^5.0|^6.0"
}
And then in your scoper.inc.php you just require: 'exclude_classes' => array_merge(
require $path_to_vendor.'/sniccowp/php-scoper-excludes/generated/wordpress-classes.php',
... other classes
) Now, in your build step, you always exclude against the latest version of WP.
|
See here how the exclusion lists for WordPress itself are generated. But yeah, for the core/wp-cli excludes I don't see why you wouldn't just require the list of generated files as a dev dependency. The package is basically just 5 files. |
If you're gonna automate maintenance of your |
My initial idea was:
Do you have any other idea? |
You wouldn't need |
@swissspidy Implemented now. We run a daily check against php-stubs/wordpress stubs and tag a new release automatically. Available at packagist now aswell. We changed from .php to .json because with .php git would go mad on the numerically indexed array. It would show 6000 additions and deletions basically. With JSON it's much clearer now what got updated and what got removed. |
Awesome! That definitely makes me more confident that we can use this in this project. |
Task Description
The current version of PHP-Scoper is 0.16.2.
In version 0.16.0, there were lots of improvements to the config, making it a lot simpler for us to configure PHP-Scoper in a WP plugin context.
It means we can get rid of all the manual
str_replace
calls in the scoper config thanks toexpose-global-{constants, classes, functions}
andexpose-{namespaces, constants, classes, functions}
We could even automate this by setting the config based on the WP stubs, see humbug/php-scoper#303 (comment)
Though we could split that up in its own ticket.
Implementation Brief
str_replace
calls in the PHP-Scoper configsniccwp/php-scoper-wordpress-excludes
as a dev dependency and configure theexclude-classes
,exclude-functions
, andexclude-constants
options accordinglyThe text was updated successfully, but these errors were encountered: