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

Release 7.x #35

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fab030f
Update composer.json
xpanel Dec 6, 2023
fca3d83
Update MobileDetector.php
xpanel Dec 6, 2023
861b2e6
Update MobileDetectorInterface.php
xpanel Dec 6, 2023
ac40225
Update README.md
xpanel Dec 6, 2023
302797a
Update composer.json
xpanel Dec 6, 2023
293d22b
Update composer.json
xpanel Dec 6, 2023
7a0f972
docs should reflect Symfony 7
tacman Mar 6, 2024
722ec42
chore: fix ci deprecations
Chris53897 Apr 29, 2024
594df4e
Update composer.json
xpanel Oct 9, 2024
2f7f105
Update MobileDetectExtension.php
xpanel Oct 9, 2024
7f93a2f
Update DeviceView.php
xpanel Nov 18, 2024
64f237b
Update DeviceDataCollector.php
xpanel Nov 18, 2024
b42e6b0
Merge branch 'main' into main
tattali Dec 20, 2024
4c90b8e
Merge pull request #24 from xpanel/main
tattali Dec 20, 2024
75ed7bb
Merge pull request #31 from Chris53897/patch-1
tattali Dec 20, 2024
a360e72
Merge branch 'upgrade' into patch-1
tattali Dec 20, 2024
50f64ea
Merge pull request #30 from tacman/patch-1
tattali Dec 20, 2024
adc72c0
Merge branch 'main' of github.com:tattali/MobileDetectBundle into upg…
tattali Dec 20, 2024
08e9a71
Remove MobileDetectorInterface and modernize code
tattali Dec 20, 2024
112e03f
Upgrade PHPStan from level 1 to level 7
tattali Dec 21, 2024
56c244e
Fix yaml error
tattali Dec 21, 2024
0dddd4a
Remove prefer-dist
tattali Dec 21, 2024
7a902ee
Explicitly add symfony/http-kernel
tattali Dec 21, 2024
132082d
Explicitly add dependencies
tattali Dec 21, 2024
29ddf20
Update github actions
tattali Dec 21, 2024
f679cb8
Update github actions
tattali Dec 21, 2024
538e1ac
Update github actions
tattali Dec 21, 2024
9ab6e64
Update github actions
tattali Dec 21, 2024
1a6902d
PHPUnit config file
tattali Dec 21, 2024
563ad90
Move license to root folder
tattali Dec 21, 2024
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
112 changes: 49 additions & 63 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,90 +14,76 @@ on:
workflow_dispatch:

jobs:
phpunit:
name: Test on PHP ${{ matrix.php }} and Symfony ${{ matrix.symfony-require }}
tests:
environment: main
runs-on: ubuntu-latest
env:
SYMFONY_REQUIRE: ${{ matrix.symfony-require }}

strategy:
fail-fast: false
matrix:
php:
- 8.2
dependencies:
- highest
stability:
- stable
symfony-require:
# Test latest stable version
- 7.*
php: ['8.2']
stability: [prefer-stable]
minimum-stability: [stable]
symfony-version: [7.2.*]
is-current: [true]
include:
- php: '8.3'
symfony-version: 7.2.*
stability: prefer-stable
- php: '8.4'
symfony-version: 7.2.*
stability: prefer-stable

name: PHP ${{ matrix.php }} and Symfony ${{ matrix.symfony-require }}
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.composer/cache/files
key: composer-packages-${{ hashFiles('composer.lock') }}

- name: Install PHP with PCOV
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: pcov
ini-values: zend.assertions=1
coverage: xdebug

- name: Globally install symfony/flex
- name: Install dependencies
env:
SYMFONY_REQUIRE: ${{ matrix.symfony-version }}
run: |
composer global config --no-plugins allow-plugins.symfony/flex true
composer global require --no-progress --no-scripts --no-plugins symfony/flex

- name: Configure minimum stability of dependencies
run: composer config minimum-stability ${{ matrix.stability }}
composer global config --no-plugins allow-plugins.symfony/flex true
composer global require --no-progress --no-scripts --no-plugins symfony/flex
composer config minimum-stability ${{ matrix.minimum-stability }}
composer update --no-interaction --prefer-dist

- name: Install dependencies with Composer
uses: ramsey/composer-install@v2
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: --prefer-dist
- name: PHP-CS-Fixer
continue-on-error: ${{ !matrix.is-current }}
run: vendor/bin/php-cs-fixer fix --dry-run --ansi -vvv

- name: Lint via PHP Coding Standards Fixer and PHP_CodeSniffer
run: |
vendor/bin/php-cs-fixer fix --dry-run --diff --ansi -vvv
vendor/bin/phpcs --report=code
- name: PHP_CodeSniffer
continue-on-error: ${{ !matrix.is-current }}
run: vendor/bin/phpcs --report=code

- name: Static Analysis via PHPStan
run: vendor/bin/phpstan analyse
- name: PHPStan
continue-on-error: ${{ !matrix.is-current }}
run: vendor/bin/phpstan analyse src tests --level 7

- name: Unit and Feature tests via PHPUnit
run: php vendor/bin/phpunit
env:
SYMFONY_DEPRECATIONS_HELPER: weak
run: vendor/bin/phpunit

- name: Upload coverage file
uses: actions/upload-artifact@v3
with:
name: phpunit-${{ matrix.php }}-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}.coverage
path: build/coverage.xml
- name: SonarCloud Scan
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
uses: sonarsource/sonarcloud-github-action@v2

- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true

upload_coverage:
name: Upload coverage to Codecov
runs-on: ubuntu-latest
needs:
- phpunit

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Download coverage files
uses: actions/download-artifact@v3
with:
path: reports

- name: Upload to Codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
uses: codecov/codecov-action@v2
with:
directory: reports
33 changes: 7 additions & 26 deletions .php-cs-fixer.dist.php → .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,13 @@
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@DoctrineAnnotation' => true,
'@PhpCsFixer:risky' => true,
'@PhpCsFixer' => true,
'@PHPUnit84Migration:risky' => true,
'@PSR1' => true,
'@PSR12:risky' => true,
'@PSR12' => true,
'@PSR2' => true,
'@Symfony:risky' => true,
'@PER-CS:risky' => true,
'@PER-CS' => true,
'@PHP82Migration:risky' => true,
'@PHP84Migration' => true,
'@PHPUnit100Migration:risky' => true,
'@Symfony' => true,
'array_indentation' => true,
'array_syntax' => [
'syntax' => 'short',
],
'doctrine_annotation_array_assignment' => [
'operator' => '=',
],
'doctrine_annotation_spaces' => [
'after_array_assignments_equals' => false,
'before_array_assignments_equals' => false,
],
'linebreak_after_opening_tag' => true,
'list_syntax' => [
'syntax' => 'short',
],
'@Symfony:risky' => true,
'no_extra_blank_lines' => [
'tokens' => [
'break',
Expand All @@ -48,7 +30,6 @@
'use',
],
],
'no_superfluous_phpdoc_tags' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
Expand All @@ -68,7 +49,7 @@
'single_line_comment_style' => true,
'strict_comparison' => true,
'strict_param' => true,
'void_return' => false,
'php_unit_test_class_requires_covers' => false,
])
->setFinder($finder)
;
File renamed without changes.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
all: test

phpunit:
php vendor/bin/phpunit
XDEBUG_MODE=coverage | php vendor/bin/phpunit --display-phpunit-deprecations

lint:
php vendor/bin/php-cs-fixer fix --diff
php vendor/bin/phpcs --report=code
php vendor/bin/phpstan analyse
php vendor/bin/phpstan analyse src tests --level 7 --memory-limit=-1

test: lint phpunit
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
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 5.4.x-7.0 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)
)](https://github.com/tattali/MobileDetectBundle/actions/workflows/main.yml?query=branch%3Amain) [![Latest Stable Version](https://poser.pugx.org/tattali/mobile-detect-bundle/v)](https://packagist.org/packages/tattali/mobile-detect-bundle) [![Total Downloads](https://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](https://poser.pugx.org/tattali/mobile-detect-bundle/license)](https://packagist.org/packages/tattali/mobile-detect-bundle) [![PHP Version Require](https://poser.pugx.org/tattali/mobile-detect-bundle/require/php)](https://packagist.org/packages/tattali/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).*

Introduction
------------

This Bundle use [Mobile_Detect](https://github.com/serbanghita/Mobile-Detect) class and provides the following features:
This Bundle use [MobileDetect](https://github.com/serbanghita/Mobile-Detect) class and provides the following features:

* Detect the various mobile devices by Name, OS, browser User-Agent
* Manages site views for the various mobile devices (`mobile`, `tablet`, `full`)
Expand All @@ -32,9 +32,9 @@ composer require tattali/mobile-detect-bundle
#### Checking device

```php
use MobileDetectBundle\DeviceDetector\MobileDetectorInterface;
use Detection\MobileDetect;

public function someaction(MobileDetectorInterface $mobileDetector)
public function someaction(MobileDetect $mobileDetector)
{
$mobileDetector->isMobile();
$mobileDetector->isTablet();
Expand All @@ -55,7 +55,7 @@ Available User-Agents (uaMatch) with the php `is()` and twig `is_device()` [here
For switch device view, use `device_view` GET parameter:

```url
http://localhost:8000?device_view={full/mobile/tablet}
https://localhost:8000?device_view={full/mobile/tablet}
```

Or using the Symfony toolbar
Expand All @@ -75,6 +75,6 @@ Any feedback and contribution will be very appreciated.
License and credits
-------

This bundle is under the MIT license. See the complete [license](src/Resources/meta/LICENSE) in the bundle
This bundle is under the MIT license. See the complete [license](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)
8 changes: 0 additions & 8 deletions codecov.yml

This file was deleted.

32 changes: 17 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,25 @@
],
"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",
"twig/twig": "^2.0 || ^3.0"
"mobiledetect/mobiledetectlib": "^4.8",
"symfony/config": "^7.2",
"symfony/dependency-injection": "^7.2",
"symfony/event-dispatcher": "^7.2",
"symfony/http-kernel": "^7.2",
"symfony/routing": "^7.2",
"symfony/yaml": "^7.2",
"twig/twig": "^3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.8",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan-nette": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan": "^1.0",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.6",
"symfony/dotenv": "^7.0",
"symfony/phpunit-bridge": "^7.0"
"friendsofphp/php-cs-fixer": "^3.65",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-symfony": "^2.0",
"phpunit/phpunit": "^11.5",
"squizlabs/php_codesniffer": "^3.11",
"symfony/dotenv": "^7.2",
"symfony/phpunit-bridge": "^7.2"
},
"config": {
"sort-packages": true,
Expand Down
6 changes: 0 additions & 6 deletions phpstan.neon.dist

This file was deleted.

58 changes: 30 additions & 28 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.readthedocs.io/en/9.5/configuration.html -->
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.1/phpunit.xsd"
backupGlobals="false"
bootstrap="./vendor/autoload.php"
colors="true">
<coverage includeUncoveredFiles="true">
<include>
<directory>src</directory>
</include>
<report>
<clover outputFile="build/coverage.xml"/>
<html outputDirectory="build/coverage"/>
<xml outputDirectory="build/coverage-xml"/>
</report>
</coverage>
<php>
<ini name="error_reporting" value="-1"/>
<ini name="memory_limit" value="-1"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[total]=0"/>
</php>
<testsuites>
<testsuite name="MobileDetectBundle Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging/>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>
colors="true"
bootstrap="vendor/autoload.php"
failOnRisky="true"
failOnWarning="true">
<php>
<ini name="error_reporting" value="-1"/>
<ini name="memory_limit" value="-1"/>
</php>

<testsuites>
<testsuite name="Project Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>

<source>
<include>
<directory>./src/</directory>
</include>
</source>

<coverage>
<report>
<clover outputFile="build/coverage.xml"/>
<html outputDirectory="build/coverage"/>
<xml outputDirectory="build/coverage-xml"/>
</report>
</coverage>
</phpunit>
15 changes: 15 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
sonar.projectKey=tattali_MobileDetectBundle
sonar.organization=tattali

sonar.php.coverage.reportPaths=build/coverage.xml

# This is the name and version displayed in the SonarCloud UI.
#sonar.projectName=CalendarBundle
#sonar.projectVersion=1.0


# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
sonar.sources=./src

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
Loading
Loading