Skip to content

Commit b668a56

Browse files
committed
Merge branch 'refs/heads/2.3.0-LTS'
# Conflicts: # .github/workflows/main.yml # composer.json # src/EventListener/RequestResponseListener.php # src/Resources/doc/legacy-versions.md
2 parents 0dc536f + f20f740 commit b668a56

File tree

18 files changed

+193
-213
lines changed

18 files changed

+193
-213
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- stable
3232
symfony-require:
3333
# Test latest stable version
34-
- 7.*
34+
- 6.4
3535
steps:
3636
- name: Checkout code
3737
uses: actions/checkout@v3

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ lint:
88
php vendor/bin/phpcs --report=code
99
php vendor/bin/phpstan analyse
1010

11+
refactor:
12+
php vendor/bin/php-cs-fixer fix
13+
php vendor/bin/rector
14+
1115
test: lint phpunit

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
MobileDetectBundle
44
==================
55

6-
Symfony 3.4.x-6.0.x bundle to detect mobile devices, manage mobile view and redirect to the mobile and tablet version.
6+
Symfony 6.4.x / PHP 8.2 bundle to detect mobile devices, manage mobile view and redirect to the mobile and tablet version.
77

8-
[![Github Actions Status](https://github.com/tattali/MobileDetectBundle/actions/workflows/main.yml/badge.svg?branch=main
9-
)](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)
8+
[![Github Actions Status](https://github.com/digifa/MobileDetectBundle/actions/workflows/main.yml/badge.svg?branch=main
9+
)](https://github.com/digifa/MobileDetectBundle/actions/workflows/main.yml?query=branch%3Amain) [![Latest Stable Version](http://poser.pugx.org/digifa/mobile-detect-bundle/v)](https://packagist.org/packages/digifa/mobile-detect-bundle) [![Total Downloads](http://poser.pugx.org/digifa/mobile-detect-bundle/downloads)](https://packagist.org/packages/digifa/mobile-detect-bundle) [![codecov](https://codecov.io/gh/digifa/MobileDetectBundle/branch/main/graph/badge.svg?token=HWV1OYRSD9)](https://codecov.io/gh/digifa/MobileDetectBundle) [![License](http://poser.pugx.org/digifa/mobile-detect-bundle/license)](https://packagist.org/packages/digifa/mobile-detect-bundle) [![PHP Version Require](http://poser.pugx.org/digifa/mobile-detect-bundle/require/php)](https://packagist.org/packages/digifa/mobile-detect-bundle)
1010

11-
*This bundle is a fork of [suncat2000/MobileDetectBundle](https://github.com/suncat2000/MobileDetectBundle). As this project doesn't look maintained anymore, we decided to create & maintain a fork. For more information read our [manifest](https://github.com/tattali/MobileDetectBundle/issues/8).*
11+
*This bundle is a fork of [tattali/MobileDetectBundle](https://github.com/tattali/MobileDetectBundle) that is a fork of [suncat2000/MobileDetectBundle](https://github.com/suncat2000/MobileDetectBundle). As this project doesn't look maintained anymore, we decided to create & maintain a fork. For more information read our [manifest](https://github.com/tattali/MobileDetectBundle/issues/8).*
1212

1313
Introduction
1414
------------
@@ -76,4 +76,4 @@ License and credits
7676

7777
This bundle is under the MIT license. See the complete [license](src/Resources/meta/LICENSE) in the bundle
7878

79-
Original authors: [suncat2000](https://github.com/suncat2000), [HenriVesala](https://github.com/HenriVesala), [netmikey](https://github.com/netmikey) and [all contributors](https://github.com/suncat2000/MobileDetectBundle/graphs/contributors)
79+
Original authors: [tattali](https://gihub.com/tattali), [suncat2000](https://github.com/suncat2000), [HenriVesala](https://github.com/HenriVesala), [netmikey](https://github.com/netmikey) and [all contributors](https://github.com/suncat2000/MobileDetectBundle/graphs/contributors)

composer.json

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "tattali/mobile-detect-bundle",
3-
"description": "Symfony 5.x-7.x bundle to detect mobile devices, manage mobile view and redirect to the mobile and tablet version.",
2+
"name": "digifa/mobile-detect-bundle",
3+
"description": "Symfony 6.4 / PHP 8.2 bundle to detect mobile devices, manage mobile view and redirect to the mobile and tablet version.",
44
"keywords": [
55
"mobile detect",
66
"device detect",
@@ -12,10 +12,14 @@
1212
"symfony mobiledetect",
1313
"symfony"
1414
],
15-
"homepage": "https://github.com/tattali/MobileDetectBundle",
15+
"homepage": "https://github.com/digifa/MobileDetectBundle",
1616
"type": "symfony-bundle",
1717
"license": "MIT",
1818
"authors": [
19+
{
20+
"name": "Guido Faust",
21+
"email": "gfaust@digifa.de"
22+
},
1923
{
2024
"name": "Théo Attali",
2125
"email": "theoattali@gmail.com"
@@ -35,23 +39,24 @@
3539
],
3640
"require": {
3741
"php": ">=8.2",
38-
"mobiledetect/mobiledetectlib": "^2.8.15",
39-
"symfony/dependency-injection": "^7.0",
40-
"symfony/event-dispatcher": "^7.0",
41-
"symfony/framework-bundle": "^7.0",
42-
"symfony/yaml": "^7.0",
42+
"mobiledetect/mobiledetectlib": "^4.8",
43+
"symfony/dependency-injection": "^6.4",
44+
"symfony/event-dispatcher": "^6.4",
45+
"symfony/framework-bundle": "^6.4",
46+
"symfony/yaml": "^6.4",
4347
"twig/twig": "^2.0 || ^3.0"
4448
},
4549
"require-dev": {
46-
"friendsofphp/php-cs-fixer": "^3.8",
50+
"friendsofphp/php-cs-fixer": "^3.4 || ^3.8",
4751
"phpstan/extension-installer": "^1.0",
52+
"phpstan/phpstan": "^1.0",
4853
"phpstan/phpstan-nette": "^1.0",
4954
"phpstan/phpstan-phpunit": "^1.0",
50-
"phpstan/phpstan": "^1.0",
5155
"phpunit/phpunit": "^9.5",
56+
"rector/rector": "^1.2",
5257
"squizlabs/php_codesniffer": "^3.6",
53-
"symfony/dotenv": "^7.0",
54-
"symfony/phpunit-bridge": "^7.0"
58+
"symfony/dotenv": "^6.4",
59+
"symfony/phpunit-bridge": "^6.4"
5560
},
5661
"config": {
5762
"sort-packages": true,

rector.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
7+
return RectorConfig::configure()
8+
->withPaths([
9+
__DIR__ . '/src',
10+
__DIR__ . '/tests',
11+
])
12+
->withPhpSets(php82: true)
13+
->withAttributesSets(symfony: true, doctrine: true)
14+
->withSets([
15+
Rector\Symfony\Set\SymfonySetList::SYMFONY_50,
16+
Rector\Symfony\Set\SymfonySetList::SYMFONY_50_TYPES,
17+
Rector\Symfony\Set\SymfonySetList::SYMFONY_51,
18+
Rector\Symfony\Set\SymfonySetList::SYMFONY_52,
19+
Rector\Symfony\Set\SymfonySetList::SYMFONY_52_VALIDATOR_ATTRIBUTES,
20+
Rector\Symfony\Set\SymfonySetList::SYMFONY_53,
21+
Rector\Symfony\Set\SymfonySetList::SYMFONY_60,
22+
Rector\Symfony\Set\SymfonySetList::SYMFONY_61,
23+
Rector\Symfony\Set\SymfonySetList::SYMFONY_62,
24+
Rector\Symfony\Set\SymfonySetList::SYMFONY_63,
25+
Rector\Symfony\Set\SymfonySetList::SYMFONY_64,
26+
Rector\Symfony\Set\SymfonySetList::SYMFONY_CODE_QUALITY,
27+
Rector\Symfony\Set\SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION,
28+
])
29+
->withDeadCodeLevel(10)
30+
->withTypeCoverageLevel(10);

src/DataCollector/DeviceDataCollector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(DeviceView $deviceView)
4545
public function collect(
4646
Request $request,
4747
Response $response,
48-
\Throwable $exception = null
48+
?\Throwable $exception = null,
4949
): void {
5050
$this->data['currentView'] = $this->deviceView->getViewType();
5151
$this->data['views'] = [
@@ -127,7 +127,7 @@ protected function canUseView(string $view, ?string $host): bool
127127
&& !empty($this->redirectConfig[$view]['host'])
128128
&& \in_array($this->redirectConfig[$view]['action'], [RequestResponseListener::REDIRECT, RequestResponseListener::REDIRECT_WITHOUT_PATH], true)
129129
) {
130-
$parseHost = parse_url($this->redirectConfig[$view]['host']);
130+
$parseHost = parse_url((string) $this->redirectConfig[$view]['host']);
131131
$redirectHost = $parseHost['scheme'].'://'.$parseHost['host'];
132132
if (!empty($parseHost['port'])) {
133133
$redirectHost .= ':'.$parseHost['port'];
@@ -143,7 +143,7 @@ protected function canUseView(string $view, ?string $host): bool
143143

144144
private function generateSwitchLink(
145145
Request $request,
146-
string $view
146+
string $view,
147147
): ?string {
148148
$requestSwitchView = $request->duplicate();
149149
$requestSwitchView->query->set($this->deviceView->getSwitchParam(), $view);

src/DependencyInjection/MobileDetectExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
use Symfony\Component\Config\FileLocator;
1717
use Symfony\Component\DependencyInjection\ContainerBuilder;
18+
use Symfony\Component\DependencyInjection\Extension\Extension;
1819
use Symfony\Component\DependencyInjection\Loader;
19-
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
2020

2121
class MobileDetectExtension extends Extension
2222
{

src/DeviceDetector/MobileDetector.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,24 @@
1313

1414
namespace MobileDetectBundle\DeviceDetector;
1515

16+
use Detection\MobileDetect;
17+
1618
/**
1719
* @author suncat2000 <nikolay.kotovsky@gmail.com>
1820
*/
19-
class MobileDetector extends \Mobile_Detect implements MobileDetectorInterface
21+
class MobileDetector extends MobileDetect implements MobileDetectorInterface
2022
{
23+
public const VERSION_TYPE_STRING = 'text';
24+
25+
public const VERSION_TYPE_FLOAT = 'float';
26+
27+
public static function getUserAgents(): array
28+
{
29+
return self::getBrowsers();
30+
}
31+
32+
public function getCfHeaders(): array
33+
{
34+
return $this->getCloudFrontHttpHeaders();
35+
}
2136
}

0 commit comments

Comments
 (0)