Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uptdate to mobiledetectlib 4.8 #24

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
MobileDetectBundle
==================

Symfony 3.4.x-6.0.x bundle to detect mobile devices, manage mobile view and redirect to the mobile and tablet version.
Symfony 7 bundle to detect mobile devices, manage mobile view and redirect to the mobile and tablet version.

[![Github Actions Status](https://github.com/tattali/MobileDetectBundle/actions/workflows/main.yml/badge.svg?branch=main
)](https://github.com/tattali/MobileDetectBundle/actions/workflows/main.yml?query=branch%3Amain) [![Latest Stable Version](http://poser.pugx.org/tattali/mobile-detect-bundle/v)](https://packagist.org/packages/tattali/mobile-detect-bundle) [![Total Downloads](http://poser.pugx.org/tattali/mobile-detect-bundle/downloads)](https://packagist.org/packages/tattali/mobile-detect-bundle) [![codecov](https://codecov.io/gh/tattali/MobileDetectBundle/branch/main/graph/badge.svg?token=HWV1OYRSD9)](https://codecov.io/gh/tattali/MobileDetectBundle) [![License](http://poser.pugx.org/tattali/mobile-detect-bundle/license)](https://packagist.org/packages/tattali/mobile-detect-bundle) [![PHP Version Require](http://poser.pugx.org/tattali/mobile-detect-bundle/require/php)](https://packagist.org/packages/tattali/mobile-detect-bundle)
Expand Down
36 changes: 18 additions & 18 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tattali/mobile-detect-bundle",
"description": "Symfony 3.4-6.x bundle to detect mobile devices, manage mobile view and redirect to the mobile and tablet version.",
"name": "xpanel/mobile-detect-bundle",
"description": "Symfony 7 bundle to detect mobile devices, manage mobile view and redirect to the mobile and tablet version.",
"keywords": [
"mobile detect",
"device detect",
Expand Down Expand Up @@ -34,24 +34,24 @@
}
],
"require": {
"php": ">=7.2.5",
"mobiledetect/mobiledetectlib": "^2.8.15",
"symfony/dependency-injection": "^5.0 || ^6.0",
"symfony/event-dispatcher": "^5.0 || ^6.0",
"symfony/framework-bundle": "^5.0 || ^6.0",
"symfony/yaml": "^5.0 || ^6.0",
"twig/twig": "^2.0 || ^3.0"
"php": ">=8.2.9",
"mobiledetect/mobiledetectlib": "^4.8",
"symfony/dependency-injection": "^7.1",
"symfony/event-dispatcher": "^7.1",
"symfony/framework-bundle": "^7.1",
"symfony/yaml": "^7.1",
"twig/twig": "^3.14"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.4 || ^3.8",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan-nette": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan": "^1.0",
"phpunit/phpunit": "^8.5 || ^9.5",
"squizlabs/php_codesniffer": "^3.6",
"symfony/dotenv": "^5.0 || ^6.0",
"symfony/phpunit-bridge": "^5.0 || ^6.0"
"friendsofphp/php-cs-fixer": "^3.64",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan-nette": "^1.3",
"phpstan/phpstan-phpunit": "^1.4",
"phpstan/phpstan": "^1.12",
"phpunit/phpunit": "^11.4",
"squizlabs/php_codesniffer": "^3.10",
"symfony/dotenv": "^7.1",
"symfony/phpunit-bridge": "^7.1"
},
"config": {
"sort-packages": true,
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/MobileDetectExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Extension\Extension;

class MobileDetectExtension extends Extension
{
Expand Down
3 changes: 2 additions & 1 deletion src/DeviceDetector/MobileDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
*/

namespace MobileDetectBundle\DeviceDetector;
use Detection\MobileDetect;

/**
* @author suncat2000 <[email protected]>
*/
class MobileDetector extends \Mobile_Detect implements MobileDetectorInterface
class MobileDetector extends MobileDetect implements MobileDetectorInterface
{
}
54 changes: 27 additions & 27 deletions src/DeviceDetector/MobileDetectorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,35 +216,35 @@ interface MobileDetectorInterface
*
* @throws \BadMethodCallException when the method doesn't exist and doesn't start with 'is'
*/
public function __call($name, $arguments);
public function __call(string $name, array $arguments);

/**
* Retrieve the list of known browsers. Specifically, the user agents.
*
* @return array list of browsers / user agents
*/
public static function getBrowsers();
public static function getBrowsers(): array;

/**
* Retrieve the list of mobile operating systems.
*
* @return array the list of mobile operating systems
*/
public static function getOperatingSystems();
public static function getOperatingSystems(): array;

/**
* Retrieve the list of known phone devices.
*
* @return array list of phone devices
*/
public static function getPhoneDevices();
public static function getPhoneDevices(): array;

/**
* Get the properties array.
*
* @return array
*/
public static function getProperties();
public static function getProperties(): array;

/**
* Get the current script version.
Expand All @@ -254,28 +254,28 @@ public static function getProperties();
*
* @return string the version number in semantic version format
*/
public static function getScriptVersion();
//public static function getScriptVersion(): string;

/**
* Retrieve the list of known tablet devices.
*
* @return array list of tablet devices
*/
public static function getTabletDevices();
public static function getTabletDevices(): array;

/**
* Alias for getBrowsers() method.
*
* @return array list of user agents
*/
public static function getUserAgents();
//public static function getUserAgents(): array;

/**
* Retrieve the list of known utilities.
*
* @return array list of utilities
*/
public static function getUtilities();
//public static function getUtilities(): array;

/**
* Check the HTTP headers for signs of mobile.
Expand All @@ -284,14 +284,14 @@ public static function getUtilities();
*
* @return bool
*/
public function checkHttpHeadersForMobile();
public function checkHttpHeadersForMobile(): bool;

/**
* Retrieves the cloudfront headers.
*
* @return array
*/
public function getCfHeaders();
//public function getCfHeaders(): array;

/**
* Set CloudFront headers
Expand All @@ -301,7 +301,7 @@ public function getCfHeaders();
*
* @return bool If there were CloudFront headers to be set
*/
public function setCfHeaders($cfHeaders = null);
//public function setCfHeaders(array $cfHeaders = null): bool;

/**
* Retrieves a particular header. If it doesn't exist, no exception/error is caused.
Expand All @@ -313,43 +313,43 @@ public function setCfHeaders($cfHeaders = null);
*
* @return string|null the value of the header
*/
public function getHttpHeader($header);
public function getHttpHeader(string $header): ?string;

/**
* Retrieves the HTTP headers.
*
* @return array
*/
public function getHttpHeaders();
public function getHttpHeaders(): array;

/**
* Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers.
*
* @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract
* the headers. The default null is left for backwards compatibility.
*/
public function setHttpHeaders($httpHeaders = null);
public function setHttpHeaders(array $httpHeaders = []): void;

public function getMatchesArray();
public function getMatchesArray(): ?array;

public function getMatchingRegex();
public function getMatchingRegex(): ?string;

public function getMobileHeaders();
public function getMobileHeaders(): array;

/**
* Get all possible HTTP headers that
* can contain the User-Agent string.
*
* @return array list of HTTP headers
*/
public function getUaHttpHeaders();
public function getUaHttpHeaders(): array;

/**
* Retrieve the User-Agent.
*
* @return string|null the user agent if it's set
*/
public function getUserAgent();
public function getUserAgent(): ?string;

/**
* Set the User-Agent to be used.
Expand All @@ -358,7 +358,7 @@ public function getUserAgent();
*
* @return string|null
*/
public function setUserAgent($userAgent = null);
public function setUserAgent(string $userAgent): string;

/**
* This method checks for a certain property in the
Expand All @@ -368,23 +368,23 @@ public function setUserAgent($userAgent = null);
*
* @return bool|int|null
*/
public function is($key);
public function is(string $ruleName): bool;

/**
* Check if the device is mobile.
* Returns true if any type of mobile device detected, including special ones.
*
* @return bool
*/
public function isMobile();
public function isMobile(): bool;

/**
* Check if the device is a tablet.
* Return true if any type of tablet device is detected.
*
* @return bool
*/
public function isTablet();
public function isTablet(): bool;

/**
* Some detection rules are relative (not standard),
Expand All @@ -399,7 +399,7 @@ public function isTablet();
*
* @return bool
*/
public function match($regex, $userAgent = null);
public function match(string $regex, string $userAgent): bool;

/**
* Prepare the version number.
Expand All @@ -408,7 +408,7 @@ public function match($regex, $userAgent = null);
*
* @return float
*/
public function prepareVersionNo($ver);
public function prepareVersionNo(string $ver): float;

/**
* Check the version of the given property in the User-Agent.
Expand All @@ -423,5 +423,5 @@ public function prepareVersionNo($ver);
*
* @return string|float the version of the property we are trying to extract
*/
public function version($propertyName, $type = MobileDetector::VERSION_TYPE_STRING);
public function version(string $propertyName, string $type = self::VERSION_TYPE_STRING): float|bool|string;
}