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
Fixed: ?? didn't work here as bool won't be seen as null #11673
Fixed: ?? didn't work here as bool won't be seen as null #11673
Conversation
…or and that needs to be reflected here, too.
src/Content/Text/BBCode.php
Outdated
@@ -111,7 +111,7 @@ private static function getOldAttachmentData($body) | |||
|
|||
$picturedata = Images::getInfoFromURLCached($matches[1]); | |||
|
|||
if ($picturedata) { | |||
if (!empty($picturedata)) { |
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.
Empty array gets casted as false in a condition, what is the purpose of empty()
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.
I normally don't like this "magic casting" thing and try to make it clean (with no casting). Plus also in other occurrences I found the empty($array)
calls. Should I then rewrite all to one way?
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's not wrong, just superfluous regarding the basic capabilities of the language. I'd say leave existing instances alone but don't add any more.
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 would like to make each handling of returned variables from Imagess::getInfoFromURL[Cached]()
the same way, that we know this is everywhere the same and don't have to check each case.
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 have now removed empty()
from each check to make it be the same on all such occurrences.
??
didn't catchfalse
here, needs to check explicitly because the returned type is alwaysarray
.PS: I just checked all occurrences. And some needed fixing.