You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The config system allows for conditional config on environment types, environment variables, module presence, classes existing, and PHP extensions being loaded. (This is implemented in CoreConfigFactory.php)
It would be valuable to add config that is conditionally applied when PHP version is less than or greater than a given value.
One key use case is to allow the continued support of older versions of PHP by retaining "legacy implementations" of services, rather than a bunch of conditional code in the service.
There are couple of of approaches to take.
Syntax A
First is that the argument takes a version number and is always a >= comparison:
Personally I'd go with the first option as it's more consistent with the other only/except flags, which don't have any support for comparison operators.
Looking at the code in CoreConfigFactory.php, this should be quite straightforward to implement.
Does the feature make sense to people? Do you prefer Syntax A or B?
The text was updated successfully, but these errors were encountered:
I like it, but I also prefer syntax B, as most changes will apply to an arbitrary range of versions. I think the comparison operators aren't inconsistent here as none of the other "rules" are numeric. I played around a little with trying to tie some regex into version_compare but it's not great:
Yeah I think you would need to strip the current version so that it's got the same precision as the version in the config. And you'd want a test around that logic of course, to work through these edge cases.
The config system allows for conditional config on environment types, environment variables, module presence, classes existing, and PHP extensions being loaded. (This is implemented in CoreConfigFactory.php)
It would be valuable to add config that is conditionally applied when PHP version is less than or greater than a given value.
One key use case is to allow the continued support of older versions of PHP by retaining "legacy implementations" of services, rather than a bunch of conditional code in the service.
There are couple of of approaches to take.
Syntax A
First is that the argument takes a version number and is always a
>=
comparison:Syntax B
The other approach is that we allow inequalities
Personally I'd go with the first option as it's more consistent with the other only/except flags, which don't have any support for comparison operators.
Looking at the code in CoreConfigFactory.php, this should be quite straightforward to implement.
Does the feature make sense to people? Do you prefer Syntax A or B?
The text was updated successfully, but these errors were encountered: