-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
ValueError
class not available in PHP < 8
#499
Comments
Indeed, this looks like a bug. As a workaround, you can require the What shall we do here, @nicolas-grekas? The easy way would of course be to register the PHP 8.0 polyfill as a dependency of the mbstring polyfill. |
ValueError
class not available in PHP < 8
I'm aware that these new methods were only added in PHP 8 and therefore have always thrown Therefore, my recommendation would be to update the locations that are throwing I guess, if you wanted to, you could use Another thought: If using tl;dr I'd prefer it if the solution didn't add an additional dependency, whatever it is. |
Another alternative is to define the specific polyfill for this exception class in the Mbstring polyfill codebase, that way behaviour is unchanged and there are no additional dependencies. I'm not sure how that sits re: code duplication, but this looks like a pretty trivial class to shim, so perhaps it's not really an issue at this scale. It would certainly be the simplest/safest solution, imho. |
I'd say the polyfill shouldn't throw if it doesn't run on PHP 8. That'd also be the correct polyfilling behavior on PHP7. |
So, oldschool |
💯 |
I can look into it tonight. |
The MBString polyfill supports PHP >= 7.2 but it makes use of the
ValueError
exception class, which was only introduced in PHP 8.In a lot of instances, there is a version check before it is used, and in these cases there is no problem.
However, there are three unguarded locations that refer to the class, which will result in fatal errors on PHP 7:
polyfill/src/Mbstring/Mbstring.php
Lines 837 to 841 in 731f6e1
polyfill/src/Mbstring/Mbstring.php
Lines 849 to 851 in 731f6e1
polyfill/src/Mbstring/Mbstring.php
Lines 1040 to 1043 in 731f6e1
The text was updated successfully, but these errors were encountered: