1- <?php namespace Jenssegers \Agent ;
1+ <?php
2+
3+ namespace Jenssegers \Agent ;
24
35use BadMethodCallException ;
46use Mobile_Detect ;
@@ -10,84 +12,84 @@ class Agent extends Mobile_Detect {
1012 *
1113 * @var array
1214 */
13- protected static $ additionalDevices = array (
14- 'Macintosh ' => 'Macintosh ' ,
15- ) ;
15+ protected static $ additionalDevices = [
16+ 'Macintosh ' => 'Macintosh ' ,
17+ ] ;
1618
1719 /**
1820 * List of additional operating systems.
1921 *
2022 * @var array
2123 */
22- protected static $ additionalOperatingSystems = array (
23- 'Windows ' => 'Windows ' ,
24- 'Windows NT ' => 'Windows NT ' ,
25- 'OS X ' => 'Mac OS X ' ,
26- 'Debian ' => 'Debian ' ,
27- 'Ubuntu ' => 'Ubuntu ' ,
28- 'Macintosh ' => 'PPC ' ,
29- 'OpenBSD ' => 'OpenBSD ' ,
30- 'Linux ' => 'Linux ' ,
31- 'ChromeOS ' => 'CrOS ' ,
32- ) ;
24+ protected static $ additionalOperatingSystems = [
25+ 'Windows ' => 'Windows ' ,
26+ 'Windows NT ' => 'Windows NT ' ,
27+ 'OS X ' => 'Mac OS X ' ,
28+ 'Debian ' => 'Debian ' ,
29+ 'Ubuntu ' => 'Ubuntu ' ,
30+ 'Macintosh ' => 'PPC ' ,
31+ 'OpenBSD ' => 'OpenBSD ' ,
32+ 'Linux ' => 'Linux ' ,
33+ 'ChromeOS ' => 'CrOS ' ,
34+ ] ;
3335
3436 /**
3537 * List of additional browsers.
36- * Note: 'Vivaldi' must be above Chrome, otherwise it'll fail
38+ * Note: 'Vivaldi' must be above Chrome, otherwise it'll fail.
3739 *
3840 * @var array
3941 */
40- protected static $ additionalBrowsers = array (
41- 'Opera ' => 'Opera|OPR ' ,
42- 'Edge ' => 'Edge ' ,
43- 'Vivaldi ' => 'Vivaldi ' ,
44- 'Chrome ' => 'Chrome ' ,
45- 'Firefox ' => 'Firefox ' ,
46- 'Safari ' => 'Safari ' ,
47- 'IE ' => 'MSIE|IEMobile|MSIEMobile|Trident/[.0-9]+ ' ,
48- 'Netscape ' => 'Netscape ' ,
49- 'Mozilla ' => 'Mozilla ' ,
50- ) ;
42+ protected static $ additionalBrowsers = [
43+ 'Opera ' => 'Opera|OPR ' ,
44+ 'Edge ' => 'Edge ' ,
45+ 'Vivaldi ' => 'Vivaldi ' ,
46+ 'Chrome ' => 'Chrome ' ,
47+ 'Firefox ' => 'Firefox ' ,
48+ 'Safari ' => 'Safari ' ,
49+ 'IE ' => 'MSIE|IEMobile|MSIEMobile|Trident/[.0-9]+ ' ,
50+ 'Netscape ' => 'Netscape ' ,
51+ 'Mozilla ' => 'Mozilla ' ,
52+ ] ;
5153
5254 /**
5355 * List of additional properties.
5456 *
5557 * @var array
5658 */
57- protected static $ additionalProperties = array (
59+ protected static $ additionalProperties = [
5860 // Operating systems
59- 'Windows ' => 'Windows NT [VER] ' ,
60- 'Windows NT ' => 'Windows NT [VER] ' ,
61- 'OS X ' => 'OS X [VER] ' ,
62- 'BlackBerryOS ' => array ( 'BlackBerry[\w]+/[VER] ' , 'BlackBerry.*Version/[VER] ' , 'Version/[VER] ' ) ,
63- 'AndroidOS ' => 'Android [VER] ' ,
64- 'ChromeOS ' => 'CrOS x86_64 [VER] ' ,
61+ 'Windows ' => 'Windows NT [VER] ' ,
62+ 'Windows NT ' => 'Windows NT [VER] ' ,
63+ 'OS X ' => 'OS X [VER] ' ,
64+ 'BlackBerryOS ' => [ 'BlackBerry[\w]+/[VER] ' , 'BlackBerry.*Version/[VER] ' , 'Version/[VER] ' ] ,
65+ 'AndroidOS ' => 'Android [VER] ' ,
66+ 'ChromeOS ' => 'CrOS x86_64 [VER] ' ,
6567
6668 // Browsers
67- 'Opera ' => array ( ' OPR/[VER] ' , 'Opera Mini/[VER] ' , 'Version/[VER] ' , 'Opera [VER] ' ) ,
68- 'Netscape ' => 'Netscape/[VER] ' ,
69- 'Mozilla ' => 'rv:[VER] ' ,
70- 'IE ' => array ( 'IEMobile/[VER]; ' , 'IEMobile [VER] ' , 'MSIE [VER]; ' , 'rv:[VER] ' ) ,
71- 'Edge ' => 'Edge/[VER] ' ,
72- 'Vivaldi ' => 'Vivaldi/[VER] ' ,
73- ) ;
69+ 'Opera ' => [ ' OPR/[VER] ' , 'Opera Mini/[VER] ' , 'Version/[VER] ' , 'Opera [VER] ' ] ,
70+ 'Netscape ' => 'Netscape/[VER] ' ,
71+ 'Mozilla ' => 'rv:[VER] ' ,
72+ 'IE ' => [ 'IEMobile/[VER]; ' , 'IEMobile [VER] ' , 'MSIE [VER]; ' , 'rv:[VER] ' ] ,
73+ 'Edge ' => 'Edge/[VER] ' ,
74+ 'Vivaldi ' => 'Vivaldi/[VER] ' ,
75+ ] ;
7476
7577 /**
7678 * List of robots.
7779 *
7880 * @var array
7981 */
80- protected static $ robots = array (
81- 'Google ' => 'googlebot ' ,
82- 'MSNBot ' => 'msnbot ' ,
83- 'Baiduspider ' => 'baiduspider ' ,
84- 'Bing ' => 'bingbot ' ,
85- 'Yahoo ' => 'yahoo ' ,
86- 'Lycos ' => 'lycos ' ,
87- 'Facebook ' => 'facebookexternalhit ' ,
88- 'Twitter ' => 'Twitterbot ' ,
89- 'Yandex ' => 'Yandex ' ,
90- ) ;
82+ protected static $ robots = [
83+ 'Google ' => 'googlebot ' ,
84+ 'MSNBot ' => 'msnbot ' ,
85+ 'Baiduspider ' => 'baiduspider ' ,
86+ 'Bing ' => 'bingbot ' ,
87+ 'Yahoo ' => 'yahoo ' ,
88+ 'Lycos ' => 'lycos ' ,
89+ 'Facebook ' => 'facebookexternalhit ' ,
90+ 'Twitter ' => 'Twitterbot ' ,
91+ 'Yandex ' => 'Yandex ' ,
92+ ] ;
9193
9294 /**
9395 * Get all detection rules. These rules include the additional
@@ -147,7 +149,7 @@ public function languages($acceptLanguage = null)
147149
148150 if ($ acceptLanguage )
149151 {
150- $ languages = array () ;
152+ $ languages = [] ;
151153
152154 // Parse accept language string.
153155 foreach (explode (', ' , $ acceptLanguage ) as $ piece )
@@ -167,7 +169,7 @@ public function languages($acceptLanguage = null)
167169 return array_keys ($ languages );
168170 }
169171
170- return array () ;
172+ return [] ;
171173 }
172174
173175 /**
@@ -254,7 +256,7 @@ public function device($userAgent = null)
254256 */
255257 public function isDesktop ($ userAgent = null , $ httpHeaders = null )
256258 {
257- return ( ! $ this ->isMobile () && ! $ this ->isTablet () && ! $ this ->isRobot () );
259+ return ! $ this ->isMobile () && ! $ this ->isTablet () && ! $ this ->isRobot ();
258260 }
259261
260262 /**
@@ -266,7 +268,7 @@ public function isDesktop($userAgent = null, $httpHeaders = null)
266268 */
267269 public function isPhone ($ userAgent = null , $ httpHeaders = null )
268270 {
269- return ( $ this ->isMobile () && ! $ this ->isTablet () );
271+ return $ this ->isMobile () && ! $ this ->isTablet ();
270272 }
271273
272274 /**
@@ -280,8 +282,8 @@ public function robot($userAgent = null)
280282 // Get bot rules
281283 $ rules = $ this ->mergeRules (
282284 static ::$ robots , // NEW
283- array ( static ::$ utilities ['Bot ' ]) ,
284- array ( static ::$ utilities ['MobileBot ' ])
285+ [ static ::$ utilities ['Bot ' ]] ,
286+ [ static ::$ utilities ['MobileBot ' ]]
285287 );
286288
287289 return $ this ->findDetectionRulesAgainstUA ($ rules , $ userAgent );
@@ -297,8 +299,8 @@ public function isRobot($userAgent = null)
297299 {
298300 // Get bot rules
299301 $ rules = $ this ->mergeRules (
300- array ( static ::$ utilities ['Bot ' ]) ,
301- array ( static ::$ utilities ['MobileBot ' ]) ,
302+ [ static ::$ utilities ['Bot ' ]] ,
303+ [ static ::$ utilities ['MobileBot ' ]] ,
302304 static ::$ robots // NEW
303305 );
304306
@@ -340,7 +342,7 @@ public function version($propertyName, $type = self::VERSION_TYPE_STRING)
340342 */
341343 protected function mergeRules ()
342344 {
343- $ merged = array () ;
345+ $ merged = [] ;
344346
345347 foreach (func_get_args () as $ rules )
346348 {
0 commit comments