mirror of
https://github.com/friendica/friendica
synced 2025-04-26 08:30:10 +00:00
Replace x() by isset(), !empty() or defaults()
- Remove extraneous parentheses around empty() calls - Remove duplicate calls to intval(), count() or strlen() after empty() - Replace ternary operators outputting binary value with empty() return value - Rewrite defaults() without x()
This commit is contained in:
parent
ea4e772b1e
commit
458981f75c
101 changed files with 896 additions and 914 deletions
|
@ -130,12 +130,12 @@ class BBCode extends BaseObject
|
|||
|
||||
$type = "";
|
||||
preg_match("/type='(.*?)'/ism", $attributes, $matches);
|
||||
if (x($matches, 1)) {
|
||||
if (!empty($matches[1])) {
|
||||
$type = strtolower($matches[1]);
|
||||
}
|
||||
|
||||
preg_match('/type="(.*?)"/ism', $attributes, $matches);
|
||||
if (x($matches, 1)) {
|
||||
if (!empty($matches[1])) {
|
||||
$type = strtolower($matches[1]);
|
||||
}
|
||||
|
||||
|
@ -153,12 +153,12 @@ class BBCode extends BaseObject
|
|||
|
||||
$url = "";
|
||||
preg_match("/url='(.*?)'/ism", $attributes, $matches);
|
||||
if (x($matches, 1)) {
|
||||
if (!empty($matches[1])) {
|
||||
$url = $matches[1];
|
||||
}
|
||||
|
||||
preg_match('/url="(.*?)"/ism', $attributes, $matches);
|
||||
if (x($matches, 1)) {
|
||||
if (!empty($matches[1])) {
|
||||
$url = $matches[1];
|
||||
}
|
||||
|
||||
|
@ -168,12 +168,12 @@ class BBCode extends BaseObject
|
|||
|
||||
$title = "";
|
||||
preg_match("/title='(.*?)'/ism", $attributes, $matches);
|
||||
if (x($matches, 1)) {
|
||||
if (!empty($matches[1])) {
|
||||
$title = $matches[1];
|
||||
}
|
||||
|
||||
preg_match('/title="(.*?)"/ism', $attributes, $matches);
|
||||
if (x($matches, 1)) {
|
||||
if (!empty($matches[1])) {
|
||||
$title = $matches[1];
|
||||
}
|
||||
|
||||
|
@ -186,12 +186,12 @@ class BBCode extends BaseObject
|
|||
|
||||
$image = "";
|
||||
preg_match("/image='(.*?)'/ism", $attributes, $matches);
|
||||
if (x($matches, 1)) {
|
||||
if (!empty($matches[1])) {
|
||||
$image = $matches[1];
|
||||
}
|
||||
|
||||
preg_match('/image="(.*?)"/ism', $attributes, $matches);
|
||||
if (x($matches, 1)) {
|
||||
if (!empty($matches[1])) {
|
||||
$image = $matches[1];
|
||||
}
|
||||
|
||||
|
@ -201,12 +201,12 @@ class BBCode extends BaseObject
|
|||
|
||||
$preview = "";
|
||||
preg_match("/preview='(.*?)'/ism", $attributes, $matches);
|
||||
if (x($matches, 1)) {
|
||||
if (!empty($matches[1])) {
|
||||
$preview = $matches[1];
|
||||
}
|
||||
|
||||
preg_match('/preview="(.*?)"/ism', $attributes, $matches);
|
||||
if (x($matches, 1)) {
|
||||
if (!empty($matches[1])) {
|
||||
$preview = $matches[1];
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ class BBCode extends BaseObject
|
|||
*/
|
||||
|
||||
$has_title = !empty($item['title']);
|
||||
$plink = (!empty($item['plink']) ? $item['plink'] : '');
|
||||
$plink = defaults($item, 'plink', '');
|
||||
$post = self::getAttachmentData($body);
|
||||
|
||||
// if nothing is found, it maybe having an image.
|
||||
|
@ -1662,7 +1662,7 @@ class BBCode extends BaseObject
|
|||
// Summary (e.g. title) is required, earlier revisions only required description (in addition to
|
||||
// start which is always required). Allow desc with a missing summary for compatibility.
|
||||
|
||||
if ((x($ev, 'desc') || x($ev, 'summary')) && x($ev, 'start')) {
|
||||
if ((!empty($ev['desc']) || !empty($ev['summary'])) && !empty($ev['start'])) {
|
||||
$sub = Event::getHTML($ev, $simple_html);
|
||||
|
||||
$text = preg_replace("/\[event\-summary\](.*?)\[\/event\-summary\]/ism", '', $text);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue