Skip to content

Commit

Permalink
Fix some wpcom rector complaints (#34053)
Browse files Browse the repository at this point in the history
In the daily deploy in D128439-code, it complained about calling static
methods with `$this->` in device-detection, and a place where `end()`
needs to be passed a variable to avoid a PHP notice.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/6851258296
  • Loading branch information
anomiex authored and matticbot committed Nov 13, 2023
1 parent 49aa260 commit 72be771
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 66 deletions.
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -147,63 +147,63 @@ public function __construct( $ua = '' ) {
* @return string The matched User Agent name, false otherwise.
*/
public function get_mobile_user_agent_name() {
if ( $this->is_chrome_for_iOS() ) { // Keep this check before the safari rule.
if ( static::is_chrome_for_iOS() ) { // Keep this check before the safari rule.
return 'chrome-for-ios';
} elseif ( $this->is_iphone_or_ipod( 'iphone-safari' ) ) {
} elseif ( static::is_iphone_or_ipod( 'iphone-safari' ) ) {
return 'iphone';
} elseif ( $this->is_ipad( 'ipad-safari' ) ) {
} elseif ( static::is_ipad( 'ipad-safari' ) ) {
return 'ipad';
} elseif ( $this->is_android_tablet() ) { // Keep this check before the android rule.
} elseif ( static::is_android_tablet() ) { // Keep this check before the android rule.
return 'android_tablet';
} elseif ( $this->is_android() ) {
} elseif ( static::is_android() ) {
return 'android';
} elseif ( $this->is_blackberry_10() ) {
} elseif ( static::is_blackberry_10() ) {
return 'blackberry_10';
} elseif ( $this->is_blackbeberry() ) {
} elseif ( static::is_blackbeberry() ) {
return 'blackberry';
} elseif ( $this->is_WindowsPhone7() ) {
} elseif ( static::is_WindowsPhone7() ) {
return 'win7';
} elseif ( $this->is_windows_phone_8() ) {
} elseif ( static::is_windows_phone_8() ) {
return 'winphone8';
} elseif ( $this->is_opera_mini() ) {
} elseif ( static::is_opera_mini() ) {
return 'opera-mini';
} elseif ( $this->is_opera_mini_dumb() ) {
} elseif ( static::is_opera_mini_dumb() ) {
return 'opera-mini-dumb';
} elseif ( $this->is_opera_mobile() ) {
} elseif ( static::is_opera_mobile() ) {
return 'opera-mobi';
} elseif ( $this->is_blackberry_tablet() ) {
} elseif ( static::is_blackberry_tablet() ) {
return 'blackberry_tablet';
} elseif ( $this->is_kindle_fire() ) {
} elseif ( static::is_kindle_fire() ) {
return 'kindle-fire';
} elseif ( $this->is_PalmWebOS() ) {
} elseif ( static::is_PalmWebOS() ) {
return 'webos';
} elseif ( $this->is_S60_OSSBrowser() ) {
} elseif ( static::is_S60_OSSBrowser() ) {
return 'series60';
} elseif ( $this->is_firefox_os() ) {
} elseif ( static::is_firefox_os() ) {
return 'firefoxOS';
} elseif ( $this->is_firefox_mobile() ) {
} elseif ( static::is_firefox_mobile() ) {
return 'firefox_mobile';
} elseif ( $this->is_MaemoTablet() ) {
} elseif ( static::is_MaemoTablet() ) {
return 'maemo';
} elseif ( $this->is_MeeGo() ) {
} elseif ( static::is_MeeGo() ) {
return 'meego';
} elseif ( $this->is_TouchPad() ) {
} elseif ( static::is_TouchPad() ) {
return 'hp_tablet';
} elseif ( $this->is_facebook_for_iphone() ) {
} elseif ( static::is_facebook_for_iphone() ) {
return 'facebook-for-iphone';
} elseif ( $this->is_facebook_for_ipad() ) {
} elseif ( static::is_facebook_for_ipad() ) {
return 'facebook-for-ipad';
} elseif ( $this->is_twitter_for_iphone() ) {
} elseif ( static::is_twitter_for_iphone() ) {
return 'twitter-for-iphone';
} elseif ( $this->is_twitter_for_ipad() ) {
} elseif ( static::is_twitter_for_ipad() ) {
return 'twitter-for-ipad';
} elseif ( $this->is_wordpress_for_ios() ) {
} elseif ( static::is_wordpress_for_ios() ) {
return 'ios-app';
} elseif ( $this->is_iphone_or_ipod( 'iphone-not-safari' ) ) {
} elseif ( static::is_iphone_or_ipod( 'iphone-not-safari' ) ) {
return 'iphone-unknown';
} elseif ( $this->is_ipad( 'ipad-not-safari' ) ) {
} elseif ( static::is_ipad( 'ipad-not-safari' ) ) {
return 'ipad-unknown';
} elseif ( $this->is_Nintendo_3DS() ) {
} elseif ( static::is_Nintendo_3DS() ) {
return 'nintendo-3ds';
} else {
$agent = $this->useragent;
Expand Down Expand Up @@ -245,26 +245,26 @@ public function get_platform() {
} elseif ( strpos( $this->useragent, 'iphone' ) !== false ) {
$this->platform = self::PLATFORM_IPHONE;
} elseif ( strpos( $this->useragent, 'android' ) !== false ) {
if ( $this->is_android_tablet() ) {
if ( static::is_android_tablet() ) {
$this->platform = self::PLATFORM_ANDROID_TABLET;
} else {
$this->platform = self::PLATFORM_ANDROID;
}
} elseif ( $this->is_kindle_fire() ) {
} elseif ( static::is_kindle_fire() ) {
$this->platform = self::PLATFORM_ANDROID_TABLET;
} elseif ( $this->is_blackberry_10() ) {
} elseif ( static::is_blackberry_10() ) {
$this->platform = self::PLATFORM_BLACKBERRY_10;
} elseif ( strpos( $this->useragent, 'blackberry' ) !== false ) {
$this->platform = self::PLATFORM_BLACKBERRY;
} elseif ( $this->is_blackberry_tablet() ) {
} elseif ( static::is_blackberry_tablet() ) {
$this->platform = self::PLATFORM_BLACKBERRY;
} elseif ( $this->is_symbian_platform() ) {
} elseif ( static::is_symbian_platform() ) {
$this->platform = self::PLATFORM_SYMBIAN;
} elseif ( $this->is_symbian_s40_platform() ) {
} elseif ( static::is_symbian_s40_platform() ) {
$this->platform = self::PLATFORM_SYMBIAN_S40;
} elseif ( $this->is_J2ME_platform() ) {
} elseif ( static::is_J2ME_platform() ) {
$this->platform = self::PLATFORM_J2ME_MIDP;
} elseif ( $this->is_firefox_os() ) {
} elseif ( static::is_firefox_os() ) {
$this->platform = self::PLATFORM_FIREFOX_OS;
} else {
$this->platform = false;
Expand All @@ -286,77 +286,77 @@ public function isTierIphone() {
$this->isTierIphone = true;
$this->isTierRichCss = false;
$this->isTierGenericMobile = false;
} elseif ( $this->is_android() ) {
} elseif ( static::is_android() ) {
$this->matched_agent = 'android';
$this->isTierIphone = true;
$this->isTierRichCss = false;
$this->isTierGenericMobile = false;
} elseif ( $this->is_windows_phone_8() ) {
} elseif ( static::is_windows_phone_8() ) {
$this->matched_agent = 'winphone8';
$this->isTierIphone = true;
$this->isTierRichCss = false;
$this->isTierGenericMobile = false;
} elseif ( $this->is_WindowsPhone7() ) {
} elseif ( static::is_WindowsPhone7() ) {
$this->matched_agent = 'win7';
$this->isTierIphone = true;
$this->isTierRichCss = false;
$this->isTierGenericMobile = false;
} elseif ( $this->is_blackberry_10() ) {
} elseif ( static::is_blackberry_10() ) {
$this->matched_agent = 'blackberry-10';
$this->isTierIphone = true;
$this->isTierRichCss = false;
$this->isTierGenericMobile = false;
} elseif ( $this->is_blackbeberry() && 'blackberry-webkit' === $this->detect_blackberry_browser_version() ) {
} elseif ( static::is_blackbeberry() && 'blackberry-webkit' === static::detect_blackberry_browser_version() ) {
$this->matched_agent = 'blackberry-webkit';
$this->isTierIphone = true;
$this->isTierRichCss = false;
$this->isTierGenericMobile = false;
} elseif ( $this->is_blackberry_tablet() ) {
} elseif ( static::is_blackberry_tablet() ) {
$this->matched_agent = 'blackberry_tablet';
$this->isTierIphone = true;
$this->isTierRichCss = false;
$this->isTierGenericMobile = false;
} elseif ( $this->is_PalmWebOS() ) {
} elseif ( static::is_PalmWebOS() ) {
$this->matched_agent = 'webos';
$this->isTierIphone = true;
$this->isTierRichCss = false;
$this->isTierGenericMobile = false;
} elseif ( $this->is_TouchPad() ) {
} elseif ( static::is_TouchPad() ) {
$this->matched_agent = 'hp_tablet';
$this->isTierIphone = true;
$this->isTierRichCss = false;
$this->isTierGenericMobile = false;
} elseif ( $this->is_firefox_os() ) {
} elseif ( static::is_firefox_os() ) {
$this->matched_agent = 'firefoxOS';
$this->isTierIphone = true;
$this->isTierRichCss = false;
$this->isTierGenericMobile = false;
} elseif ( $this->is_firefox_mobile() ) {
} elseif ( static::is_firefox_mobile() ) {
$this->matched_agent = 'fennec';
$this->isTierIphone = true;
$this->isTierRichCss = false;
$this->isTierGenericMobile = false;
} elseif ( $this->is_opera_mobile() ) {
} elseif ( static::is_opera_mobile() ) {
$this->matched_agent = 'opera-mobi';
$this->isTierIphone = true;
$this->isTierRichCss = false;
$this->isTierGenericMobile = false;
} elseif ( $this->is_MaemoTablet() ) {
} elseif ( static::is_MaemoTablet() ) {
$this->matched_agent = 'maemo';
$this->isTierIphone = true;
$this->isTierRichCss = false;
$this->isTierGenericMobile = false;
} elseif ( $this->is_MeeGo() ) {
} elseif ( static::is_MeeGo() ) {
$this->matched_agent = 'meego';
$this->isTierIphone = true;
$this->isTierRichCss = false;
$this->isTierGenericMobile = false;
} elseif ( $this->is_kindle_touch() ) {
} elseif ( static::is_kindle_touch() ) {
$this->matched_agent = 'kindle-touch';
$this->isTierIphone = true;
$this->isTierRichCss = false;
$this->isTierGenericMobile = false;
} elseif ( $this->is_Nintendo_3DS() ) {
} elseif ( static::is_Nintendo_3DS() ) {
$this->matched_agent = 'nintendo-3ds';
$this->isTierIphone = true;
$this->isTierRichCss = false;
Expand All @@ -381,18 +381,18 @@ public function isTierRichCss() {
}

// The following devices are explicitly ok.
if ( $this->is_S60_OSSBrowser() ) {
if ( static::is_S60_OSSBrowser() ) {
$this->matched_agent = 'series60';
$this->isTierIphone = false;
$this->isTierRichCss = true;
$this->isTierGenericMobile = false;
} elseif ( $this->is_opera_mini() ) {
} elseif ( static::is_opera_mini() ) {
$this->matched_agent = 'opera-mini';
$this->isTierIphone = false;
$this->isTierRichCss = true;
$this->isTierGenericMobile = false;
} elseif ( $this->is_blackbeberry() ) {
$detectedDevice = $this->detect_blackberry_browser_version();
} elseif ( static::is_blackbeberry() ) {
$detectedDevice = static::detect_blackberry_browser_version();
if (
'blackberry-5' === $detectedDevice
|| 'blackberry-4.7' === $detectedDevice
Expand Down
6 changes: 3 additions & 3 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"packages": [
{
"name": "automattic/jetpack-device-detection",
"version": "1.5.0-alpha.1699529620",
"version_normalized": "1.5.0.0-alpha1699529620",
"version": "1.5.0-alpha.1699885257",
"version_normalized": "1.5.0.0-alpha1699885257",
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-device-detection",
"reference": "52476ca9243ed7704eead4b005fe868098f62a4c"
"reference": "5c3681d320dcedec693fc9b57d0c7ee4fdd92d98"
},
"require-dev": {
"automattic/jetpack-changelogger": "^3.3.11",
Expand Down
6 changes: 3 additions & 3 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
),
'versions' => array(
'automattic/jetpack-device-detection' => array(
'pretty_version' => '1.5.0-alpha.1699529620',
'version' => '1.5.0.0-alpha1699529620',
'reference' => '52476ca9243ed7704eead4b005fe868098f62a4c',
'pretty_version' => '1.5.0-alpha.1699885257',
'version' => '1.5.0.0-alpha1699885257',
'reference' => '5c3681d320dcedec693fc9b57d0c7ee4fdd92d98',
'type' => 'jetpack-library',
'install_path' => __DIR__ . '/../automattic/jetpack-device-detection',
'aliases' => array(),
Expand Down

0 comments on commit 72be771

Please sign in to comment.