From fab030fad377b897abe277c984e7dfe6ba83b09f Mon Sep 17 00:00:00 2001 From: xpanel <5144826+xpanel@users.noreply.github.com> Date: Wed, 6 Dec 2023 17:00:10 +0200 Subject: [PATCH 01/11] Update composer.json Update composer.json to mobiledetectlib 4.8 --- composer.json | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index 59f7b2b..2147462 100644 --- a/composer.json +++ b/composer.json @@ -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.", + "description": "Symfony 7 bundle to detect mobile devices, manage mobile view and redirect to the mobile and tablet version.", "keywords": [ "mobile detect", "device detect", @@ -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.0", + "symfony/event-dispatcher": "^7.0", + "symfony/framework-bundle": "^7.0", + "symfony/yaml": "^7.0", + "twig/twig": "^3.8" }, "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.40", + "phpstan/extension-installer": "^1.3", + "phpstan/phpstan-nette": "^1.2", + "phpstan/phpstan-phpunit": "^1.3", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^10.5", + "squizlabs/php_codesniffer": "^3.7", + "symfony/dotenv": "^7.0", + "symfony/phpunit-bridge": "^7.0" }, "config": { "sort-packages": true, @@ -71,3 +71,10 @@ } } } + + "autoload-dev": { + "psr-4": { + "MobileDetectBundle\\Tests\\": "tests/" + } + } +} From fca3d831e1894fe6a37ebb4ddfdaa3dc948052ca Mon Sep 17 00:00:00 2001 From: xpanel <5144826+xpanel@users.noreply.github.com> Date: Wed, 6 Dec 2023 17:04:07 +0200 Subject: [PATCH 02/11] Update MobileDetector.php Update MobileDetector.php to mobiledetectlib 4.8 --- src/DeviceDetector/MobileDetector.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DeviceDetector/MobileDetector.php b/src/DeviceDetector/MobileDetector.php index 4634b08..3b4b479 100644 --- a/src/DeviceDetector/MobileDetector.php +++ b/src/DeviceDetector/MobileDetector.php @@ -12,10 +12,11 @@ */ namespace MobileDetectBundle\DeviceDetector; +use Detection\MobileDetect; /** * @author suncat2000 */ -class MobileDetector extends \Mobile_Detect implements MobileDetectorInterface +class MobileDetector extends MobileDetect implements MobileDetectorInterface { } From 861b2e6865eb51d9282c9c1cf00aca91cf9e9f19 Mon Sep 17 00:00:00 2001 From: xpanel <5144826+xpanel@users.noreply.github.com> Date: Wed, 6 Dec 2023 17:07:14 +0200 Subject: [PATCH 03/11] Update MobileDetectorInterface.php update compatibility --- .../MobileDetectorInterface.php | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/DeviceDetector/MobileDetectorInterface.php b/src/DeviceDetector/MobileDetectorInterface.php index 24241e0..d800fe8 100644 --- a/src/DeviceDetector/MobileDetectorInterface.php +++ b/src/DeviceDetector/MobileDetectorInterface.php @@ -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. @@ -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. @@ -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 @@ -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. @@ -313,14 +313,14 @@ 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. @@ -328,13 +328,13 @@ public function getHttpHeaders(); * @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 @@ -342,14 +342,14 @@ public function getMobileHeaders(); * * @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. @@ -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 @@ -368,7 +368,7 @@ 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. @@ -376,7 +376,7 @@ public function is($key); * * @return bool */ - public function isMobile(); + public function isMobile(): bool; /** * Check if the device is a tablet. @@ -384,7 +384,7 @@ public function isMobile(); * * @return bool */ - public function isTablet(); + public function isTablet(): bool; /** * Some detection rules are relative (not standard), @@ -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. @@ -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. @@ -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; } From ac40225c1b5a6de4cd48af4fa22cccfdcb708c3a Mon Sep 17 00:00:00 2001 From: xpanel <5144826+xpanel@users.noreply.github.com> Date: Wed, 6 Dec 2023 17:08:15 +0200 Subject: [PATCH 04/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cdbee8d..2fd859b 100644 --- a/README.md +++ b/README.md @@ -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) From 302797a62ab4f957dabb8d6e0ca97c2d02331e09 Mon Sep 17 00:00:00 2001 From: xpanel <5144826+xpanel@users.noreply.github.com> Date: Wed, 6 Dec 2023 17:11:46 +0200 Subject: [PATCH 05/11] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2147462..5bc7be1 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "tattali/mobile-detect-bundle", + "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", From 293d22bdd5f37363101d0bb4c3f26efa755fafd8 Mon Sep 17 00:00:00 2001 From: xpanel <5144826+xpanel@users.noreply.github.com> Date: Wed, 6 Dec 2023 17:15:55 +0200 Subject: [PATCH 06/11] Update composer.json --- composer.json | 7 ------- 1 file changed, 7 deletions(-) diff --git a/composer.json b/composer.json index 5bc7be1..fa57be8 100644 --- a/composer.json +++ b/composer.json @@ -71,10 +71,3 @@ } } } - - "autoload-dev": { - "psr-4": { - "MobileDetectBundle\\Tests\\": "tests/" - } - } -} From b9d157935952bf4d63c4e5419324bfa5bd51366a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Attali?= Date: Tue, 16 Jan 2024 22:00:13 +0100 Subject: [PATCH 07/11] Update legacy-versions.md --- src/Resources/doc/legacy-versions.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Resources/doc/legacy-versions.md b/src/Resources/doc/legacy-versions.md index c4c2f5f..50ebc8c 100644 --- a/src/Resources/doc/legacy-versions.md +++ b/src/Resources/doc/legacy-versions.md @@ -4,12 +4,18 @@ Installation Composer -------- -### Latest Symfony >= 5.1 || <= 6.4 +### Latest Symfony >=7.0 ```sh composer require tattali/mobile-detect-bundle ``` +### Latest Symfony >= 5.1 || <= 6.4 + +```sh +composer require 'tattali/mobile-detect-bundle:2.2.*' +``` + ### For Symfony >= 3.4 || <= 4.4 ```sh From 594df4e66270a8df39b2a5c739200e5b6c5bde27 Mon Sep 17 00:00:00 2001 From: xpanel <5144826+xpanel@users.noreply.github.com> Date: Wed, 9 Oct 2024 09:57:26 +0300 Subject: [PATCH 08/11] Update composer.json --- composer.json | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index fa57be8..0a81145 100644 --- a/composer.json +++ b/composer.json @@ -36,22 +36,22 @@ "require": { "php": ">=8.2.9", "mobiledetect/mobiledetectlib": "^4.8", - "symfony/dependency-injection": "^7.0", - "symfony/event-dispatcher": "^7.0", - "symfony/framework-bundle": "^7.0", - "symfony/yaml": "^7.0", - "twig/twig": "^3.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.40", - "phpstan/extension-installer": "^1.3", - "phpstan/phpstan-nette": "^1.2", - "phpstan/phpstan-phpunit": "^1.3", - "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^10.5", - "squizlabs/php_codesniffer": "^3.7", - "symfony/dotenv": "^7.0", - "symfony/phpunit-bridge": "^7.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, From 2f7f1055ad65f4e43b6984773ac67cbe37e73a20 Mon Sep 17 00:00:00 2001 From: xpanel <5144826+xpanel@users.noreply.github.com> Date: Wed, 9 Oct 2024 09:59:59 +0300 Subject: [PATCH 09/11] Update MobileDetectExtension.php --- src/DependencyInjection/MobileDetectExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DependencyInjection/MobileDetectExtension.php b/src/DependencyInjection/MobileDetectExtension.php index 016565b..62d9612 100644 --- a/src/DependencyInjection/MobileDetectExtension.php +++ b/src/DependencyInjection/MobileDetectExtension.php @@ -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 { From 7f93a2fc07cf1ccf47caaa3cea0e742cec6277c4 Mon Sep 17 00:00:00 2001 From: xpanel <5144826+xpanel@users.noreply.github.com> Date: Mon, 18 Nov 2024 11:51:38 +0200 Subject: [PATCH 10/11] Update DeviceView.php --- src/Helper/DeviceView.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Helper/DeviceView.php b/src/Helper/DeviceView.php index 198dffe..176fae4 100644 --- a/src/Helper/DeviceView.php +++ b/src/Helper/DeviceView.php @@ -103,7 +103,7 @@ class DeviceView */ protected $redirectConfig = []; - public function __construct(RequestStack $requestStack = null) + public function __construct(?RequestStack $requestStack = null) { if (!$requestStack || !$this->request = $requestStack->getMainRequest()) { $this->viewType = self::VIEW_NOT_MOBILE; From 64f237b5da1a5d218f8dd0c2e55ae0e7b7f442b4 Mon Sep 17 00:00:00 2001 From: xpanel <5144826+xpanel@users.noreply.github.com> Date: Mon, 18 Nov 2024 11:54:19 +0200 Subject: [PATCH 11/11] Update DeviceDataCollector.php --- src/DataCollector/DeviceDataCollector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DataCollector/DeviceDataCollector.php b/src/DataCollector/DeviceDataCollector.php index 071b28d..cbda2fc 100644 --- a/src/DataCollector/DeviceDataCollector.php +++ b/src/DataCollector/DeviceDataCollector.php @@ -45,7 +45,7 @@ public function __construct(DeviceView $deviceView) public function collect( Request $request, Response $response, - \Throwable $exception = null + ?\Throwable $exception = null ): void { $this->data['currentView'] = $this->deviceView->getViewType(); $this->data['views'] = [