1 | <?php |
||
17 | class Device_Detection { |
||
18 | |||
19 | /** |
||
20 | * Returns information about the current device accessing the page. |
||
21 | * |
||
22 | * @param string $ua (Optional) User-Agent string. |
||
23 | * |
||
24 | * @return array Device information. |
||
25 | * |
||
26 | * array( |
||
27 | * 'is_phone' => (bool) Whether the current device is a mobile phone. |
||
28 | * 'is_smartphone' => (bool) Whether the current device is a smartphone. |
||
29 | * 'is_tablet' => (bool) Whether the current device is a tablet device. |
||
30 | * 'is_handheld' => (bool) Whether the current device is a handheld device. |
||
31 | * 'is_desktop' => (bool) Whether the current device is a laptop / desktop device. |
||
32 | * 'platform' => (string) Detected platform. |
||
33 | * 'is_phone_matched_ua' => (string) Matched UA. |
||
34 | * ); |
||
35 | */ |
||
36 | public static function get_info( $ua = '' ) { |
||
64 | |||
65 | /** |
||
66 | * Detects phone devices. |
||
67 | * |
||
68 | * @param string $ua User-Agent string. |
||
69 | * |
||
70 | * @return bool |
||
71 | */ |
||
72 | public static function is_phone( $ua = '' ) { |
||
76 | |||
77 | /** |
||
78 | * Detects smartphone devices. |
||
79 | * |
||
80 | * @param string $ua User-Agent string. |
||
81 | * |
||
82 | * @return bool |
||
83 | */ |
||
84 | public static function is_smartphone( $ua = '' ) { |
||
88 | |||
89 | /** |
||
90 | * Detects tablet devices. |
||
91 | * |
||
92 | * @param string $ua User-Agent string. |
||
93 | * |
||
94 | * @return bool |
||
95 | */ |
||
96 | public static function is_tablet( $ua = '' ) { |
||
100 | |||
101 | /** |
||
102 | * Detects desktop devices. |
||
103 | * |
||
104 | * @param string $ua User-Agent string. |
||
105 | * |
||
106 | * @return bool |
||
107 | */ |
||
108 | public static function is_desktop( $ua = '' ) { |
||
112 | |||
113 | /** |
||
114 | * Detects handheld (i.e. phone + tablet) devices. |
||
115 | * |
||
116 | * @param string $ua User-Agent string. |
||
117 | * |
||
118 | * @return bool |
||
119 | */ |
||
120 | public static function is_handheld( $ua = '' ) { |
||
124 | |||
125 | /** |
||
126 | * Determine if the current User Agent matches the passed $kind. |
||
127 | * |
||
128 | * @param string $kind Category of mobile device to check for. Either: any, dumb, smart. |
||
129 | * @param bool $return_matched_agent Boolean indicating if the UA should be returned. |
||
130 | * @param User_Agent_Info $ua_info Boolean indicating if the UA should be returned. |
||
131 | * |
||
132 | * @return bool|string Boolean indicating if current UA matches $kind. If `$return_matched_agent` is true, returns the UA string. |
||
133 | */ |
||
134 | private static function is_mobile( $kind = 'any', $return_matched_agent = false, $ua_info ) { |
||
211 | } |
||
212 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.