Skip to content

Commit 03b2234

Browse files
committed
Initiating first PHP 7.x compatible version.
1 parent fc9cccd commit 03b2234

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2458
-4136
lines changed

.github/workflows/devel.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,21 @@ name: Mobile-Detect
33
# Run this workflow every time a new commit pushed to your repository
44
on:
55
push:
6-
branches: ['devel']
6+
branches: ['7.x']
77
pull_request:
8-
branches: ['devel', 'master']
8+
branches: ['7.x']
99

1010
jobs:
1111
run:
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
matrix:
15-
php-version: ["5.3", "7.4"]
15+
php-version: [7.4"]
1616
os: ['ubuntu-latest']
1717
include:
18-
- os: 'ubuntu-latest'
19-
php-version: '5.3'
20-
phpunit-version: '4.8.36'
21-
composer-version: 'v1'
2218
- os: 'ubuntu-latest'
2319
php-version: '7.4'
24-
phpunit-version: '4.8.36'
20+
phpunit-version: '7.0.0'
2521
composer-version: 'latest'
2622
steps:
2723
- name: Checkout
@@ -37,7 +33,7 @@ jobs:
3733
tools: phpunit:${{ matrix.phpunit-version }}, composer:${{ matrix.composer-version }}
3834

3935
- name: Run tests
40-
run: phpunit -v -c tests/phpunit.xml --coverage-text --strict-coverage --stop-on-risky
36+
run: XDEBUG_MODE=coverage && phpunit -v -c tests/phpunit.xml --coverage-text --strict-coverage --stop-on-risky
4137
shell: bash
4238

4339
- name: Slack Notification

Mobile_Detect.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ The rest of the PRs about TVs, bots or optimizations will be closed and analyzed
4545
> Use this to quickly test the demo.
4646
4747
* [Download latest release](../../tags)
48-
* [Mobile_Detect.php](./Mobile_Detect.php)
48+
* [Mobile_Detect.php](src/MobileDetect.php)
4949

5050
```php
51-
require_once "libs/Mobile_Detect.php";
51+
require_once "libs/MobileDetect.php";
5252
```
5353

5454
**Install as a [composer package](https://packagist.org/packages/mobiledetect/mobiledetectlib)**

composer.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@
1414
}
1515
],
1616
"require": {
17-
"php": ">=5.0.0"
17+
"php": ">=7.4"
1818
},
1919
"require-dev": {
20-
"phpunit/phpunit": "~4.8.35||~5.7"
20+
"phpunit/phpunit": "^7.0.0",
21+
"squizlabs/php_codesniffer": "3.*",
22+
"friendsofphp/php-cs-fixer": "v2.19.3"
2123
},
2224
"autoload": {
23-
"classmap": ["Mobile_Detect.php"],
24-
"psr-0": {
25-
"Detection": "namespaced/"
25+
"classmap": [
26+
"src/MobileDetect.php"
27+
],
28+
"psr-4": {
29+
"Detection\\": "src/"
2630
}
2731
},
2832
"archive": {

examples/demo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*
3333
*/
3434

35-
require_once '../Mobile_Detect.php';
35+
require_once '../MobileDetect.php';
3636
$detect = new Mobile_Detect;
3737

3838
$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');

examples/session_example.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
session_start();
4949

5050
// It's mandatory to include the library.
51-
require_once '../Mobile_Detect.php';
51+
require_once '../MobileDetect.php';
5252

5353
/**
5454
* Begin helper functions.

examples/test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
require_once dirname(__FILE__) . '/../Mobile_Detect.php';
2+
require_once dirname(__FILE__) . '/../MobileDetect.php';
33
/*
44
$detect = new Mobile_Detect;
55
$detect->setUserAgent('Mozilla/5.0 (iPhone; CPU iPhone OS 8_0_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) CriOS/38.0.2125.59 Mobile/12A405 Safari/600.1.4');
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<?php
2-
$detect = new Mobile_Detect;
2+
3+
use Detection\MobileDetect;
4+
5+
$detect = new MobileDetect;
36

47
/**
58
* Dump all methods (+ extended)
69
* Use this script to generate comments like "@method bool isiPhone()"
710
* php -a examples/dump_magic_methods.php > methods.txt
811
*/
9-
$detect->setDetectionType(Mobile_Detect::DETECTION_TYPE_EXTENDED);
10-
foreach($detect->getRules() as $name => $regex) {
12+
foreach ($detect->getRules() as $name => $regex) {
1113
echo "is$name()\n";
12-
}
14+
}

export/exportToJSON.php

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,51 +17,50 @@
1717

1818
// Included nicejson function to beautify the result JSON file.
1919
// This library is not mandatory.
20-
if( file_exists(dirname(__FILE__).'/nicejson/nicejson.php') ) {
21-
include_once dirname(__FILE__).'/nicejson/nicejson.php';
20+
use Detection\MobileDetect;
21+
22+
if (file_exists(dirname(__FILE__).'/nicejson/nicejson.php')) {
23+
include_once dirname(__FILE__).'/nicejson/nicejson.php';
2224
}
2325

2426
// Include Mobile Detect.
25-
require_once dirname(__FILE__).'/../Mobile_Detect.php';
26-
$detect = new Mobile_Detect;
27+
require_once dirname(__FILE__) . '/../src/MobileDetect.php';
28+
$detect = new MobileDetect;
2729

28-
$json = array(
29-
// The current version of Mobile Detect class that
30-
// is being exported.
31-
'version' => $detect->getScriptVersion(),
30+
$json = [
31+
// The current version of Mobile Detect class that
32+
// is being exported.
33+
'version' => $detect->getScriptVersion(),
3234

33-
// All headers that trigger 'isMobile' to be 'true',
34-
// before reaching the User-Agent match detection.
35-
'headerMatch' => $detect->getMobileHeaders(),
35+
// All headers that trigger 'isMobile' to be 'true',
36+
// before reaching the User-Agent match detection.
37+
'headerMatch' => $detect->getMobileHeaders(),
3638

37-
// All possible User-Agent headers.
38-
'uaHttpHeaders' => $detect->getUaHttpHeaders(),
39+
// All possible User-Agent headers.
40+
'uaHttpHeaders' => $detect->getUaHttpHeaders(),
3941

40-
// All the regexes that trigger 'isMobile' or 'isTablet'
41-
// to be true.
42-
'uaMatch' => array(
43-
// If match is found, triggers 'isMobile' to be true.
44-
'phones' => $detect->getPhoneDevices(),
45-
// Triggers 'isTablet' to be true.
46-
'tablets' => $detect->getTabletDevices(),
47-
// If match is found, triggers 'isMobile' to be true.
48-
'browsers' => $detect->getBrowsers(),
49-
// If match is found, triggers 'isMobile' to be true.
50-
'os' => $detect->getOperatingSystems(),
51-
// Various utilities. To be further discussed.
52-
'utilities' => $detect->getUtilities()
53-
)
54-
);
42+
// All the regexes that trigger 'isMobile' or 'isTablet'
43+
// to be true.
44+
'uaMatch' => [
45+
// If match is found, triggers 'isMobile' to be true.
46+
'phones' => $detect->getPhoneDevices(),
47+
// Triggers 'isTablet' to be true.
48+
'tablets' => $detect->getTabletDevices(),
49+
// If match is found, triggers 'isMobile' to be true.
50+
'browsers' => $detect->getBrowsers(),
51+
// If match is found, triggers 'isMobile' to be true.
52+
'os' => $detect->getOperatingSystems()
53+
]
54+
];
5555

56-
$fileName = dirname(__FILE__).'/../Mobile_Detect.json';
56+
$fileName = dirname(__FILE__).'/../MobileDetect.json';
5757
// Write the JSON file to disk.11
5858
// You can import this file in your app.
5959
if (file_put_contents(
60-
$fileName,
61-
function_exists('json_format') ? json_format($json) : json_encode($json)
60+
$fileName,
61+
function_exists('json_format') ? json_format($json) : json_encode($json)
6262
)) {
63-
echo 'Done. Check '.realpath($fileName).' file.';
64-
}
65-
else {
66-
echo 'Failed to write '.realpath($fileName).' to disk.';
63+
echo 'Done. Check '.realpath($fileName).' file.';
64+
} else {
65+
echo 'Failed to write '.realpath($fileName).' to disk.';
6766
}

namespaced/Detection/MobileDetect.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

phpcs.xml

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)