Skip to content

Commit

Permalink
Merge branch 'refs/heads/2.3.0-LTS'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/main.yml
#	composer.json
#	src/EventListener/RequestResponseListener.php
#	src/Resources/doc/legacy-versions.md
  • Loading branch information
digifa committed Oct 16, 2024
2 parents 0dc536f + f20f740 commit b668a56
Show file tree
Hide file tree
Showing 18 changed files with 193 additions and 213 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- stable
symfony-require:
# Test latest stable version
- 7.*
- 6.4
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ lint:
php vendor/bin/phpcs --report=code
php vendor/bin/phpstan analyse

refactor:
php vendor/bin/php-cs-fixer fix
php vendor/bin/rector

test: lint phpunit
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
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 6.4.x / PHP 8.2 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)
[![Github Actions Status](https://github.com/digifa/MobileDetectBundle/actions/workflows/main.yml/badge.svg?branch=main
)](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)

*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).*
*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).*

Introduction
------------
Expand Down Expand Up @@ -76,4 +76,4 @@ License and credits

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

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)
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)
29 changes: 17 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tattali/mobile-detect-bundle",
"description": "Symfony 5.x-7.x bundle to detect mobile devices, manage mobile view and redirect to the mobile and tablet version.",
"name": "digifa/mobile-detect-bundle",
"description": "Symfony 6.4 / PHP 8.2 bundle to detect mobile devices, manage mobile view and redirect to the mobile and tablet version.",
"keywords": [
"mobile detect",
"device detect",
Expand All @@ -12,10 +12,14 @@
"symfony mobiledetect",
"symfony"
],
"homepage": "https://github.com/tattali/MobileDetectBundle",
"homepage": "https://github.com/digifa/MobileDetectBundle",
"type": "symfony-bundle",
"license": "MIT",
"authors": [
{
"name": "Guido Faust",
"email": "gfaust@digifa.de"
},
{
"name": "Théo Attali",
"email": "theoattali@gmail.com"
Expand All @@ -35,23 +39,24 @@
],
"require": {
"php": ">=8.2",
"mobiledetect/mobiledetectlib": "^2.8.15",
"symfony/dependency-injection": "^7.0",
"symfony/event-dispatcher": "^7.0",
"symfony/framework-bundle": "^7.0",
"symfony/yaml": "^7.0",
"mobiledetect/mobiledetectlib": "^4.8",
"symfony/dependency-injection": "^6.4",
"symfony/event-dispatcher": "^6.4",
"symfony/framework-bundle": "^6.4",
"symfony/yaml": "^6.4",
"twig/twig": "^2.0 || ^3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.8",
"friendsofphp/php-cs-fixer": "^3.4 || ^3.8",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-nette": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan": "^1.0",
"phpunit/phpunit": "^9.5",
"rector/rector": "^1.2",
"squizlabs/php_codesniffer": "^3.6",
"symfony/dotenv": "^7.0",
"symfony/phpunit-bridge": "^7.0"
"symfony/dotenv": "^6.4",
"symfony/phpunit-bridge": "^6.4"
},
"config": {
"sort-packages": true,
Expand Down
30 changes: 30 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withPhpSets(php82: true)
->withAttributesSets(symfony: true, doctrine: true)
->withSets([
Rector\Symfony\Set\SymfonySetList::SYMFONY_50,
Rector\Symfony\Set\SymfonySetList::SYMFONY_50_TYPES,
Rector\Symfony\Set\SymfonySetList::SYMFONY_51,
Rector\Symfony\Set\SymfonySetList::SYMFONY_52,
Rector\Symfony\Set\SymfonySetList::SYMFONY_52_VALIDATOR_ATTRIBUTES,
Rector\Symfony\Set\SymfonySetList::SYMFONY_53,
Rector\Symfony\Set\SymfonySetList::SYMFONY_60,
Rector\Symfony\Set\SymfonySetList::SYMFONY_61,
Rector\Symfony\Set\SymfonySetList::SYMFONY_62,
Rector\Symfony\Set\SymfonySetList::SYMFONY_63,
Rector\Symfony\Set\SymfonySetList::SYMFONY_64,
Rector\Symfony\Set\SymfonySetList::SYMFONY_CODE_QUALITY,
Rector\Symfony\Set\SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION,
])
->withDeadCodeLevel(10)
->withTypeCoverageLevel(10);
6 changes: 3 additions & 3 deletions src/DataCollector/DeviceDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = [
Expand Down Expand Up @@ -127,7 +127,7 @@ protected function canUseView(string $view, ?string $host): bool
&& !empty($this->redirectConfig[$view]['host'])
&& \in_array($this->redirectConfig[$view]['action'], [RequestResponseListener::REDIRECT, RequestResponseListener::REDIRECT_WITHOUT_PATH], true)
) {
$parseHost = parse_url($this->redirectConfig[$view]['host']);
$parseHost = parse_url((string) $this->redirectConfig[$view]['host']);
$redirectHost = $parseHost['scheme'].'://'.$parseHost['host'];
if (!empty($parseHost['port'])) {
$redirectHost .= ':'.$parseHost['port'];
Expand All @@ -143,7 +143,7 @@ protected function canUseView(string $view, ?string $host): bool

private function generateSwitchLink(
Request $request,
string $view
string $view,
): ?string {
$requestSwitchView = $request->duplicate();
$requestSwitchView->query->set($this->deviceView->getSwitchParam(), $view);
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/MobileDetectExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

class MobileDetectExtension extends Extension
{
Expand Down
17 changes: 16 additions & 1 deletion src/DeviceDetector/MobileDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,24 @@

namespace MobileDetectBundle\DeviceDetector;

use Detection\MobileDetect;

/**
* @author suncat2000 <nikolay.kotovsky@gmail.com>
*/
class MobileDetector extends \Mobile_Detect implements MobileDetectorInterface
class MobileDetector extends MobileDetect implements MobileDetectorInterface
{
public const VERSION_TYPE_STRING = 'text';

public const VERSION_TYPE_FLOAT = 'float';

public static function getUserAgents(): array
{
return self::getBrowsers();
}

public function getCfHeaders(): array
{
return $this->getCloudFrontHttpHeaders();
}
}
Loading

0 comments on commit b668a56

Please sign in to comment.