Skip to content

Commit 60131cb

Browse files
authored
Merge pull request #65 from alexpott/php8-compatibility
* fix PHP 8.0-RC1, 7.4.12, 7.3.24 notices calling `stream_wrapper_restore` * run tests on `symfony/phpunit-bridge` instead of `phpunit/phpunit`
2 parents ea5c600 + b4ba66d commit 60131cb

File tree

11 files changed

+59
-11
lines changed

11 files changed

+59
-11
lines changed

.appveyor.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ init:
2424
- SET COMPOSER_NO_INTERACTION=1
2525
- SET PHP=1 # This var is connected to PHP install cache
2626
- SET ANSICON=121x90 (121x90)
27+
- SET SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT=1
2728

2829
## Install PHP and composer, and run the appropriate composer command
2930
install:
@@ -38,7 +39,7 @@ install:
3839
- IF %PHP%==1 echo extension=php_fileinfo.dll >> php.ini
3940
- IF %PHP%==1 echo extension=php_bz2.dll >> php.ini
4041
- IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat
41-
- appveyor-retry appveyor DownloadFile https://getcomposer.org/composer.phar
42+
- appveyor-retry appveyor DownloadFile https://getcomposer.org/composer-1.phar -FileName composer.phar
4243
- cd c:\projects\php-project-workspace
4344
# Remove xdebug dependency as performance testing is not relevant at this point.
4445
- composer remove --dev --no-update ext-xdebug
@@ -50,4 +51,4 @@ install:
5051
## Run the actual test
5152
test_script:
5253
- cd c:\projects\php-project-workspace
53-
- vendor/bin/phpunit
54+
- vendor/bin/simple-phpunit

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/.appveyor.yml export-ignore
33
/.gitattributes export-ignore
44
/.gitignore export-ignore
5+
/.scrutinizer.yml export-ignore
56
/.travis.yml export-ignore
67
/phpunit.xml export-ignore
78
/tests/ export-ignore

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea
2+
.phpunit.result.cache
23
vendor/
34
composer.lock

.scrutinizer.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
build:
2+
environment:
3+
php: '7.2'
4+
dependencies:
5+
before:
6+
- pecl install xdebug
7+
- echo zend_extension=$(php-config --extension-dir)/xdebug.so >> $(php --ini | grep -F '/php.ini' | cut -d ':' -f 2)
8+
nodes:
9+
analysis:
10+
project_setup:
11+
override:
12+
- 'true'
13+
tests:
14+
override:
15+
- php-scrutinizer-run
16+
-
17+
command: phpcs-run
18+
use_website_config: true
19+
tests:
20+
override:
21+
- SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT=1 vendor/bin/simple-phpunit --colors
22+
filter:
23+
excluded_paths:
24+
- 'tests/*'
25+
checks:
26+
php:
27+
phpunit_assertions: true
28+
29+
coding_style:
30+
php:
31+
spaces:
32+
around_operators:
33+
concatenation: true

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ script:
3939
- >
4040
echo;
4141
echo "Running tests";
42-
vendor/bin/phpunit --colors
42+
SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT=1 vendor/bin/simple-phpunit --colors
4343
- >
4444
echo;
4545
echo "Running PHP lint";

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
"homepage": "https://typo3.org/",
77
"keywords": ["php", "phar", "stream-wrapper", "security"],
88
"require": {
9-
"php": "^7.0",
9+
"php": "^7.0 || ^8.0",
1010
"ext-json": "*"
1111
},
1212
"require-dev": {
1313
"ext-xdebug": "*",
14-
"phpunit/phpunit": "^6.5"
14+
"phpspec/prophecy": "^1.10",
15+
"symfony/phpunit-bridge": "^5.1"
1516
},
1617
"suggest": {
1718
"ext-fileinfo": "For PHP builtin file type guessing, otherwise uses internal processing"

phpunit.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<phpunit
3+
bootstrap="vendor/autoload.php"
34
backupGlobals="true"
45
colors="true"
56
processIsolation="true"
67
verbose="true">
7-
8+
<php>
9+
<ini name="SYMFONY_PHPUNIT_REMOVE" value="symfony/yaml"/>
10+
</php>
811
<testsuites>
912
<testsuite name="functional tests">
1013
<directory>tests/Functional/</directory>

src/PharStreamWrapper.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,15 @@ private function invokeInternalStreamWrapper(string $functionName, ...$arguments
495495

496496
private function restoreInternalSteamWrapper()
497497
{
498-
stream_wrapper_restore('phar');
498+
if (PHP_VERSION_ID < 70324
499+
|| PHP_VERSION_ID >= 70400 && PHP_VERSION_ID < 70412) {
500+
stream_wrapper_restore('phar');
501+
} else {
502+
// with https://github.com/php/php-src/pull/6183 (PHP #76943) the
503+
// behavior of `stream_wrapper_restore()` did change for
504+
// PHP 8.0-RC1, 7.4.12 and 7.3.24
505+
@stream_wrapper_restore('phar');
506+
}
499507
}
500508

501509
private function registerStreamWrapper()

tests/Functional/Interceptor/AbstractTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function directoryActionAllowsInvocationDataProvider(): array
107107
public function directoryOpenAllowsInvocation(string $path)
108108
{
109109
$handle = opendir('phar://' . $path);
110-
self::assertInternalType('resource', $handle);
110+
self::assertIsResource($handle);
111111
}
112112

113113
/**
@@ -372,7 +372,7 @@ public function urlStatDeniesInvocation(string $functionName, string $path)
372372
public function streamOpenAllowsInvocationForFileOpen(string $allowedPath)
373373
{
374374
$handle = fopen('phar://' . $allowedPath . '/Resources/content.txt', 'r');
375-
self::assertInternalType('resource', $handle);
375+
self::assertIsResource($handle);
376376
}
377377

378378
/**

tests/Functional/Interceptor/PharExtensionInterceptorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function cliToolIsExecuted(string $command)
107107
['pipe', 'w'], // STDERR
108108
];
109109
$process = proc_open('php ' . $command, $descriptorSpecifications, $pipes);
110-
static::assertInternalType('resource', $process);
110+
static::assertIsResource($process);
111111

112112
$read = [$pipes[1], $pipes[2]]; // reading from process' STDOUT & STDERR
113113
$write = null;

0 commit comments

Comments
 (0)