Skip to content

Commit

Permalink
Merge pull request #474 from kukulich/php74
Browse files Browse the repository at this point in the history
Run tests on PHP 7.4
  • Loading branch information
Ocramius authored May 27, 2019
2 parents 38876ee + f4b3469 commit f5488ff
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
34 changes: 34 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ before_script:
- rm composer.lock
- travis_retry composer update --prefer-dist $DEPENDENCIES

matrix:
allow_failures:
- php: 7.4snapshot

jobs:
include:
- stage: Test
Expand Down Expand Up @@ -76,6 +80,16 @@ jobs:
- echo "memory_limit=1G" >> /c/tools/php/php.ini
script: vendor/bin/phpunit

- stage: Test
php: 7.4snapshot
env: DEPENDENCIES=""
script: vendor/bin/phpunit

- stage: Test
php: 7.4snapshot
env: DEPENDENCIES="--prefer-lowest --prefer-stable"
script: vendor/bin/phpunit

- stage: Test Compatibility
php: 7.2
env: DEPENDENCIES=""
Expand Down Expand Up @@ -144,6 +158,16 @@ jobs:
- echo "memory_limit=1G" >> /c/tools/php/php.ini
script: vendor/bin/phpunit test/compat

- stage: Test Compatibility
php: 7.4snapshot
env: DEPENDENCIES=""
script: vendor/bin/phpunit test/compat

- stage: Test Compatibility
php: 7.4snapshot
env: DEPENDENCIES="--prefer-lowest --prefer-stable"
script: vendor/bin/phpunit test/compat

- stage: Check Demo Scripts
php: 7.2
env: DEPENDENCIES=""
Expand All @@ -164,6 +188,16 @@ jobs:
env: DEPENDENCIES="--prefer-lowest --prefer-stable"
script: test/demo/check-demo.sh

- stage: Check Demo Scripts
php: 7.4snapshot
env: DEPENDENCIES=""
script: test/demo/check-demo.sh

- stage: Check Demo Scripts
php: 7.4snapshot
env: DEPENDENCIES="--prefer-lowest --prefer-stable"
script: test/demo/check-demo.sh

- stage: Check Coding Standard
php: 7.3
env: DEPENDENCIES=""
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Better Reflection - an improved code reflection API",
"license": "MIT",
"require": {
"php": ">=7.2.0,<7.4.0",
"php": ">=7.2.0,<7.5.0",
"ext-json": "*",
"jetbrains/phpstorm-stubs": "2019.1",
"nikic/php-parser": "^4.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,20 @@ public function internalClassesProvider() : array
get_declared_traits()
);

// Needs fixes in JetBrains/phpstorm-stubs
$missingClassesInStubs = ['WeakReference'];

return array_map(
static function (string $className) : array {
return [$className];
},
array_filter(
$classNames,
static function (string $className) : bool {
static function (string $className) use ($missingClassesInStubs) : bool {
if (in_array($className, $missingClassesInStubs, true)) {
return false;
}

$reflection = new CoreReflectionClass($className);

if (! $reflection->isInternal()) {
Expand Down Expand Up @@ -159,6 +166,11 @@ private function assertSameClassAttributes(CoreReflectionClass $original, Reflec
continue;
}

// Added in PHP 7.4.0
if (PHP_VERSION_ID >= 70400 && $method->getShortName() === '__unserialize') {
return;
}

$this->assertSameMethodAttributes($method, $stubbed->getMethod($method->getName()));
}

Expand Down Expand Up @@ -272,7 +284,7 @@ public function internalFunctionsProvider() : array
$functionNames = get_defined_functions()['internal'];

// Needs fixes in JetBrains/phpstorm-stubs
$missingFunctionsInStubs = ['sapi_windows_vt100_support'];
$missingFunctionsInStubs = ['password_algos', 'sapi_windows_vt100_support', 'sapi_windows_set_ctrl_handler', 'sapi_windows_generate_ctrl_event'];

return array_map(
static function (string $functionName) : array {
Expand Down Expand Up @@ -361,6 +373,11 @@ public function testInternalFunctions(string $functionName) : void
return;
}

// Changed in PHP 7.4.0
if (PHP_VERSION_ID >= 70400 && $functionName === 'preg_replace_callback') {
return;
}

// Needs fixes in JetBrains/phpstorm-stubs or PHP
if (in_array($functionName, ['get_resources', 'sapi_windows_cp_get', 'stream_context_set_option'], true)) {
return;
Expand Down

0 comments on commit f5488ff

Please sign in to comment.