Skip to content

Commit fcc5685

Browse files
authored
Merge pull request #215 from mlocati/php-8.0
PHP 8.0 compatibility
2 parents 12d178a + b64b489 commit fcc5685

File tree

7 files changed

+276
-38
lines changed

7 files changed

+276
-38
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
- "7.2"
1414
- "7.3"
1515
- "7.4"
16+
- "8.0"
1617
runs-on: ${{ matrix.os }}
1718
steps:
1819
- name: Setup PHP
@@ -38,12 +39,16 @@ jobs:
3839
- name: Install Composer dependencies (including dev, preferring dist)
3940
run: composer install --optimize-autoloader --ansi --no-interaction
4041
- name: Run Behat
41-
run: PICKLE_BEHAT_PROCESS_TIMEOUT=0 vendor/bin/behat --format=progress
42+
env:
43+
PICKLE_BEHAT_PROCESS_TIMEOUT: 0
44+
run: vendor/bin/behat --format=progress
45+
# We need a new release of Ocular that supports PHP 8 - see https://github.com/scrutinizer-ci/ocular/pull/52
4246
- name: Download Ocular
47+
if: always() && !startsWith(matrix.php-version, '8.')
4348
run: curl -sSLf -o ocular.phar https://scrutinizer-ci.com/ocular.phar
4449
- name: Upload code coverage
45-
if: ${{ always() }}
50+
if: always()
4651
run: |
4752
if test -f ocular.phar && test -f clover.xml; then
48-
php ocular.phar code-coverage:upload --format=php-clover clover.xml
53+
php ocular.phar code-coverage:upload --format=php-clover --ansi --no-interaction -vvv clover.xml
4954
fi

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ composer.phar
22
pickle*.phar
33
vendor/
44
*.test
5+
/clover.xml
6+
/ocular.phar

composer.json

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,25 @@
1717
],
1818
"require": {
1919
"php": ">=7.2",
20-
"ext-zlib": "*",
21-
"ext-mbstring": "*",
22-
"ext-simplexml": "*",
23-
"ext-json": "*",
2420
"ext-dom": "*",
21+
"ext-json": "*",
22+
"ext-mbstring": "*",
2523
"ext-openssl": "*",
26-
"symfony/console": "^5.0",
27-
"justinrainbow/json-schema": "^3.0 || ^4.0 || ^5.0",
24+
"ext-simplexml": "*",
25+
"ext-zlib": "*",
2826
"composer/composer": "<2.0",
29-
"padraic/phar-updater": "~1.0@dev"
27+
"justinrainbow/json-schema": "^3.0 || ^4.0 || ^5.0",
28+
"padraic/phar-updater": "~1.0@dev",
29+
"symfony/console": "^5.0"
3030
},
3131
"require-dev": {
3232
"atoum/atoum": "~3.4",
3333
"atoum/praspel-extension": "~0.17",
3434
"atoum/visibility-extension": "~1.3",
3535
"behat/behat": "~3.6",
36-
"symfony/process": "^5.0",
37-
"friendsofphp/php-cs-fixer": "^2.16"
36+
"friendsofphp/php-cs-fixer": "^2.16",
37+
"mlocati/composer-patcher": "^1.2.2",
38+
"symfony/process": "^5.0"
3839
},
3940
"autoload": {
4041
"psr-4": {
@@ -43,13 +44,28 @@
4344
},
4445
"bin": ["bin/pickle"],
4546
"config": {
47+
"optimize-autoloader": true,
48+
"sort-packages": true,
4649
"platform": {
4750
"php": "7.2.5"
48-
}
51+
},
52+
"discard-changes": true
4953
},
5054
"scripts": {
5155
"cs": "vendor/bin/php-cs-fixer --ansi fix --config=sf23",
5256
"test": "vendor/bin/atoum --force-terminal && vendor/bin/behat --suite pickle --colors"
57+
},
58+
"extra": {
59+
"patches": {
60+
"atoum/atoum:3.4.2": {
61+
"PHP 8 fixes": "patches/atoum/atoum/0001-PHP-8-fixes.patch"
62+
},
63+
"hoa/realdom:1.17.01.13": {
64+
"PHP 8 fixes": "patches/hoa/realdom/0001-Remove-use-of-deprecated-each-function.patch"
65+
},
66+
"hoa/stream:1.17.02.21": {
67+
"PHP 8 fixes": "patches/hoa/stream/0001-Fix-PHP-8-compatibility.patch"
68+
}
69+
}
5370
}
54-
55-
}
71+
}

composer.lock

Lines changed: 93 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
From: Michele Locati <[email protected]>
2+
Date: Mon, 25 Jan 2021 09:49:46 +0100
3+
Subject: [PATCH] PHP 8 fixes
4+
5+
--- a/classes/autoloader.php
6+
+++ b/classes/autoloader.php
7+
@@ -40,7 +40,8 @@ class autoloader
8+
9+
$defaultAliases = [
10+
'atoum' => __NAMESPACE__ . '\test',
11+
- __NAMESPACE__ => __NAMESPACE__ . '\test'
12+
+ __NAMESPACE__ => __NAMESPACE__ . '\test',
13+
+ __NAMESPACE__ . '\iterators\recursives\directory\factory' => __NAMESPACE__ . '\iterators\recursives\directory\\' . (PHP_VERSION_ID < 80000 ? 'factory7' : 'factory8'),
14+
];
15+
16+
foreach ($classAliases ?: $defaultAliases as $alias => $target) {
17+
--- a/classes/includer.php
18+
+++ b/classes/includer.php
19+
@@ -84,7 +84,7 @@ class includer
20+
return $firstError;
21+
}
22+
23+
- public function errorHandler($error, $message, $file, $line, $context)
24+
+ public function errorHandler($error, $message, $file, $line, $context = null)
25+
{
26+
$errorReporting = $this->adapter->error_reporting();
27+
28+
new file mode 100644
29+
--- /dev/null
30+
+++ b/classes/iterators/recursives/directory/factory7.php
31+
@@ -0,0 +1,11 @@
32+
+<?php
33+
+
34+
+namespace mageekguy\atoum\iterators\recursives\directory;
35+
+
36+
+class factory7 extends factoryBase
37+
+{
38+
+ public function getIterator($path)
39+
+ {
40+
+ return $this->getIteratorBase($path);
41+
+ }
42+
+}
43+
new file mode 100644
44+
--- /dev/null
45+
+++ b/classes/iterators/recursives/directory/factory8.php
46+
@@ -0,0 +1,11 @@
47+
+<?php
48+
+
49+
+namespace mageekguy\atoum\iterators\recursives\directory;
50+
+
51+
+class factory8 extends factoryBase
52+
+{
53+
+ public function getIterator()
54+
+ {
55+
+ return $this->getIteratorBase(func_get_arg(0));
56+
+ }
57+
+}
58+
diff --git a/classes/iterators/recursives/directory/factory.php b/classes/iterators/recursives/directory/factoryBase.phpsimilarity index 97%
59+
similarity index 97%
60+
rename from classes/iterators/recursives/directory/factory.php
61+
rename to classes/iterators/recursives/directory/factoryBase.php
62+
--- a/classes/iterators/recursives/directory/factory.php
63+
+++ b/classes/iterators/recursives/directory/factoryBase.php
64+
@@ -4,7 +4,7 @@ namespace mageekguy\atoum\iterators\recursives\directory;
65+
66+
use mageekguy\atoum\iterators\filters;
67+
68+
-class factory implements \iteratorAggregate
69+
+abstract class factoryBase implements \iteratorAggregate
70+
{
71+
protected $dotFilterFactory = null;
72+
protected $iteratorFactory = null;
73+
@@ -63,7 +63,7 @@ class factory implements \iteratorAggregate
74+
return $this->extensionFilterFactory;
75+
}
76+
77+
- public function getIterator($path)
78+
+ public function getIteratorBase($path)
79+
{
80+
$iterator = call_user_func($this->iteratorFactory, $path);
81+

0 commit comments

Comments
 (0)