-
Notifications
You must be signed in to change notification settings - Fork 30
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
ENH PHP 8.1 compatibility #212
ENH PHP 8.1 compatibility #212
Conversation
6481f65
to
1f9fc6d
Compare
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.
There are some regex functions that are getting an empty string when an empty regex is needed instead or it'll emit a different warning. I've pointed one out as an example.
if (trim($negate)) { | ||
if (preg_match($regex, $actual)) { | ||
if (trim($negate ?? '')) { | ||
if (preg_match($regex ?? '', $actual ?? '')) { |
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.
if (preg_match($regex ?? '', $actual ?? '')) { | |
if (preg_match($regex ?? '//', $actual ?? '')) { |
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 was discussed in another PR - the warning emitted by the empty string is correct and we would be hiding an actual issue by using an empty regex. The intention here is just to avoid deprecation warnings.
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.
For posterity: See discussion in silverstripe/silverstripe-admin#1294 about the general approach. tl;dr:
the purposes of this PR is to avoid passing null (specifically null) from built-in functions that as of php 8.1 will throw deprecation warnings if null is passed in. The approach is necessarily heavy-handed, and while there are many situations where it isn't needed, it would be prohibitively laborious to find all of those situations by hand.
Looks good to me
Issue silverstripe/silverstripe-framework#10250