Permalink
Browse files

Set deviceParser $matches defaults to avoid notices when used as fall…

…backs
  • Loading branch information...
1 parent ce81668 commit 2ffd45c02ba5b9121d4816c391df85446a101884 @bshelton229 bshelton229 committed Feb 10, 2012
Showing with 5 additions and 0 deletions.
  1. +5 −0 UAParser.php
View
@@ -259,6 +259,11 @@ private function deviceParser() {
foreach ($deviceRegexes as $deviceRegex) {
if (preg_match("/".str_replace("/","\/",$deviceRegex['regex'])."/i",self::$ua,$matches)) {
+ // Make sure matches 2 and 3 are at least set to null for setting
+ // Major and Minor defaults
+ if (!isset($matches[2])) { $matches[2] = null; }
+ if (!isset($matches[3])) { $matches[3] = null; }
+
// basic properties
$deviceObj->deviceMajor = isset($deviceRegex['device_v1_replacement']) ? $deviceRegex['device_v1_replacement'] : $matches[2];
$deviceObj->deviceMinor = isset($deviceRegex['device_v2_replacement']) ? $deviceRegex['device_v2_replacement'] : $matches[3];

0 comments on commit 2ffd45c

Please sign in to comment.