Skip to content
This repository has been archived by the owner on Jul 19, 2018. It is now read-only.

Commit

Permalink
Ensure all public properties are set. Fixes #77.
Browse files Browse the repository at this point in the history
* Fixes E_NOTICE errors.
  • Loading branch information
Krinkle committed Nov 15, 2012
1 parent c1edaec commit f74dc6f
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions php/UAParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,39 @@ public static function parse($ua = null) {
exit;
}
}



// Defaults
$result = (object) array(
'family' => '',
'major' => '',
'minor' => '',
'patch' => '',
'version' => '',
'browserFull' => '',
'os' => '',
'osMajor' => '',
'osMinor' => '',
'osPatch' => '',
'osFull' => '',
'full' => '',
'device' => '',
'deviceMajor' => '',
'deviceMinor' => '',
'deviceVersion' => '',
'deviceFull' => '',
'isMobileDevice' => false,
'isMobile' => false,
'isSpider' => false,
'isTablet' => false,
'isComputer' => true,
);
$result->uaOriginal = self::$ua;

// run the regexes to match things up
$uaRegexes = self::$regexes['user_agent_parsers'];
foreach ($uaRegexes as $uaRegex) {
if ($result = self::uaParser($uaRegex)) {
$result->uaOriginal = self::$ua;
if ($uaObj = self::uaParser($uaRegex)) {
$result = (object) array_merge((array) $result, (array) $uaObj);
break;
}
}
Expand Down

0 comments on commit f74dc6f

Please sign in to comment.