Skip to content

Commit 0dade8f

Browse files
committed
Prevent PHP 7.4+ errors in user agent trait
1 parent 88be767 commit 0dade8f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/App/Http/Traits/UserAgentDetails.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static function details($ua)
1515
{
1616
$ua = is_null($ua) ? $_SERVER['HTTP_USER_AGENT'] : $ua;
1717
// Enumerate all common platforms, this is usually placed in braces (order is important! First come first serve..)
18-
$platforms = 'Windows|iPad|iPhone|Macintosh|Android|BlackBerry|Unix|Linux';
18+
$platforms = 'Windows|iPad|iPhone|Macintosh|Android|BlackBerry|Unix|Linux|X11';
1919

2020
// All browsers except MSIE/Trident and..
2121
// NOT for browsers that use this syntax: Version/0.xx Browsername
@@ -53,7 +53,11 @@ public static function details($ua)
5353
$return['version'] = $ua_array[4];
5454
}
5555
} else {
56-
return false;
56+
$return['platform'] = '-';
57+
$return['type'] = '-';
58+
$return['renderer'] = '-';
59+
$return['browser'] = '-';
60+
$return['version'] = '-';
5761
}
5862

5963
// Replace some browsernames e.g. MSIE -> Internet Explorer
@@ -98,7 +102,7 @@ public static function localeLang($locale)
98102
}
99103

100104
$a = explode(',', $locale);
101-
$a = explode(';', $a[1]);
105+
$a ??= explode(';', $a[1]);
102106

103107
return $a[0];
104108
}

0 commit comments

Comments
 (0)