-
Notifications
You must be signed in to change notification settings - Fork 103
7.0.0 #78
base: master
Are you sure you want to change the base?
7.0.0 #78
Conversation
* Removed $isRobot, setIsRobot(), getIsRobot(), isRobot(), checkBrowserRobot() * Replaced above with detectScriptedAgent() * Added a new ScriptedAgent class with detection for bots, spiders, etc * Added isWebkit(), getIsWebkit(), setIsWebkit() NOTE: TODO: Should add proper browser engine detection (Webkit, Gecko, Trident, etc) * Added $isTwitterWebView, setIsTwitterWebView(), getIsTwitterWebView(), isTwitterWebView(); * Added browser detection for UC Browser * Added browser detection for NSPlayer (Windows Media Player) * Added OS detection for NSPlayer (Windows Media Player) * Added browser detection for Microsoft Office * Added browser detection for the Apple News app * Added browser detection for the Dalvik (Android) OS * Moved wkHTMLtoPDF to scripted agents and removed the test accordingly * Moved GoogleBot to scripted agents * Moved Slurp to scripted agents * Moved W3CValidator to scripted agents * Moved MSNBot to scripted agents * Renamed "Navigator" to "Android Navigator" for clarity * Strip linebreaks in setVersion (fixes a failng test) * Added .idea to the gitignore (I use PHPstorm, don't be a hater) TODO: Tests for new class
Instead of: Match everything except ^ ;\), Match: a-z, A-Z, 0-9, and . only. Remove dirty fudge added to remove the stray \n Now passes tests without said fudge
@@ -1,5 +1,9 @@ | |||
# CHANGELOG | |||
|
|||
## 7.0.0 (released 2017-xx-xx) | |||
|
|||
- ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add changelog
@@ -67,12 +64,12 @@ class Browser | |||
/** | |||
* @var bool | |||
*/ | |||
private $isRobot = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to know if is a scripted agent from here, maybe isScriptedAgent
src/Browser.php
Outdated
* @param bool $isRobot | ||
* @return ScriptedAgent|bool | ||
*/ | ||
public function detectScriptedAgent() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to the ScriptedAgent class like Browser, OS, Device, etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reasoning here is that detectScriptedAgent can provide a replacement for $isRobot in this class. This function provides a quick pre-scan to avoid in-depth substring searches in ScriptedAgent if not necessary.
{ | ||
public function testExample() | ||
{ | ||
$this->assertNotFalse(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add some tests to assert this is working
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
public function testExample() | ||
{ | ||
$this->assertNotFalse(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add some tests to assert this is working
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…rsion This adds a lookup table for Edge. This will require some maintenance. If the version cannot be resolved, the browser name "EdgeHTML" is returned rather than "Edge", so that the version number is not misleading. Also fixed regex for edge.
stripos($ua, 'msn') !== false || | ||
stripos($ua, 'Google Web Preview') !== false || | ||
stripos($ua, 'ips-agent') !== false || | ||
(stripos($ua, 'Chrome/51.0.2704.103') !== false && !isset($_SERVER['HTTP_UPGRADE_INSECURE_REQUESTS']) && stristr($_SERVER['HTTP_ACCEPT_LANGUAGE'], "ru-RU") !== false) //ICQ Preview |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't those checks be done in the ScriptedAgentDetector class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I anticipated this to be called from $browser in order to be a substitute of $isRobot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could still check from the browser class if it is a scripted agent by checking the result of ScriptedAgentDetector. I think it would be cleaner to separate the two and link them with methods instead of having this check in the browser class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'm on board with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, do you want to make the change?
…-detector into 7.0.0
src/Browser.php
Outdated
@@ -38,6 +38,7 @@ class Browser | |||
const GSA = 'Google Search Appliance'; | |||
const YANDEX = 'Yandex'; | |||
const EDGE = 'Edge'; | |||
const EDGE_HTML = 'EdgeHTML'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could lead to use error, I'd prefer to still have Edge as the browser and the version be unknown if it is unknown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I am working on engine detection also, so that fits.
src/BrowserDetector.php
Outdated
if (isset($version[1])) { | ||
self::$browser->setVersion((float)$version[1]); | ||
preg_match('/Edge[\\/ \\(]([a-zA-Z\\d\\.]*)/i', self::$userAgentString, $matches); | ||
if (sizeof($matches)>1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check if the version is between the range and provide the closest version if it is.
Example:
"12.10049" => "0.10.10049",
"12.10051" => "0.11.10051",
If we detect version 12.10050
, we should fallback to the latest available version which would be 0.10.10049
. This way, while it may not be 100% accurate, it will provide a fallback to the versions missing in the table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--
It looks like the StyleCI build is failed. That is, the coding style check is failed, and I think this should be fixed. |
*/ | ||
public static function checkBrowserUCBrowser() | ||
{ | ||
// Navigator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need this comment in each function?
@TomMettam Continuity of #76