Skip to content

Commit e1cef70

Browse files
authored
PHPLIB-1502: Test with PHP 8.4 (#1484)
* PHPLIB-1502: Test with PHP 8.4 * Remove psalm from dependencies on PHP 8.4 * Suppress deprecations in tests expecting no output * Skip test failing due to PHPUnit deprecations * Skip failing test on PHP 8.4
1 parent 96ab516 commit e1cef70

File tree

9 files changed

+129
-4
lines changed

9 files changed

+129
-4
lines changed

.evergreen/config/functions.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,9 @@ functions:
325325
working_dir: "src"
326326
script: |
327327
${PREPARE_SHELL}
328-
file="${PROJECT_DIRECTORY}/.evergreen/install-composer.sh"
329-
# Don't use ${file} syntax here because evergreen treats it as an empty expansion.
330-
[ -f "$file" ] && DEPENDENCIES=${DEPENDENCIES} bash $file || echo "$file not available, skipping"
328+
DEPENDENCIES=${DEPENDENCIES} \
329+
PHP_VERSION=${PHP_VERSION} \
330+
bash ${PROJECT_DIRECTORY}/.evergreen/install-composer.sh
331331
332332
"start load balancer":
333333
- command: shell.exec

.evergreen/config/generate-config.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
// Supported PHP versions. Add new versions to the beginning of the list
55
$modernPhpVersions = [
6+
'8.4',
67
'8.3',
78
'8.2',
89
'8.1',
@@ -13,7 +14,9 @@
1314
];
1415
$supportedPhpVersions = array_merge($modernPhpVersions, $legacyPhpVersions);
1516

16-
$latestPhpVersion = max($supportedPhpVersions);
17+
// TODO: use max() once PHP 8.4 is stable
18+
//$latestPhpVersion = max($supportedPhpVersions);
19+
$latestPhpVersion = '8.3';
1720
$lowestPhpVersion = min($supportedPhpVersions);
1821

1922
// Supported MongoDB versions. Add new versions after "rapid"

.evergreen/config/generated/build/build-extension-next-minor.yml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.evergreen/config/generated/build/build-extension.yml

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.evergreen/config/generated/test-variant/modern-php-full.yml

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.evergreen/install-composer.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,9 @@ php --ri mongodb
3838

3939
install_composer
4040

41+
# Remove psalm as it's not compatible with PHP 8.4: https://github.com/vimeo/psalm/pull/10928
42+
if [ "$PHP_VERSION" == "8.4" ]; then
43+
php composer.phar remove --no-update --dev vimeo/psalm
44+
fi
45+
4146
php composer.phar update $COMPOSER_FLAGS

tests/GridFS/BucketFunctionalTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,9 @@ public function testDanglingOpenWritableStream(): void
860860
$code = <<<'PHP'
861861
require '%s';
862862
require '%s';
863+
// Don't report deprecations - if the issue exists this code will
864+
// result in a fatal error
865+
error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
863866
$client = MongoDB\Tests\FunctionalTestCase::createTestClient();
864867
$database = $client->selectDatabase(getenv('MONGODB_DATABASE') ?: 'phplib_test');
865868
$gridfs = $database->selectGridFSBucket();
@@ -903,6 +906,9 @@ public function testDanglingOpenWritableStreamWithGlobalStreamWrapperAlias(): vo
903906
$code = <<<'PHP'
904907
require '%s';
905908
require '%s';
909+
// Don't report deprecations - if the issue exists this code will
910+
// result in a fatal error
911+
error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
906912
$client = MongoDB\Tests\FunctionalTestCase::createTestClient();
907913
$database = $client->selectDatabase(getenv('MONGODB_DATABASE') ?: 'phplib_test');
908914
$database->selectGridFSBucket()->registerGlobalStreamWrapperAlias('alias');

tests/Model/CodecCursorFunctionalTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
use MongoDB\Model\CodecCursor;
99
use MongoDB\Tests\FunctionalTestCase;
1010

11+
use function phpversion;
1112
use function restore_error_handler;
1213
use function set_error_handler;
14+
use function version_compare;
1315

1416
use const E_DEPRECATED;
1517
use const E_USER_DEPRECATED;
@@ -25,6 +27,10 @@ public function setUp(): void
2527

2628
public function testSetTypeMap(): void
2729
{
30+
if (version_compare(phpversion(), '8.4', '>=')) {
31+
$this->markTestIncomplete('Test fails on PHP 8.4 due to deprecations');
32+
}
33+
2834
$collection = self::createTestClient()->selectCollection($this->getDatabaseName(), $this->getCollectionName());
2935
$cursor = $collection->find();
3036

tests/UnifiedSpecTests/Constraint/MatchesTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
use stdClass;
1010

1111
use function hex2bin;
12+
use function phpversion;
1213
use function preg_quote;
14+
use function version_compare;
1315

1416
class MatchesTest extends FunctionalTestCase
1517
{
@@ -69,6 +71,10 @@ public function testOperatorExists(): void
6971

7072
public function testOperatorType(): void
7173
{
74+
if (version_compare(phpversion(), '8.4', '>=')) {
75+
$this->markTestIncomplete('Test fails on PHP 8.4 due to deprecations');
76+
}
77+
7278
$c = new Matches(['x' => ['$$type' => 'string']]);
7379
$this->assertResult(true, $c, ['x' => 'foo'], 'string matches string type');
7480
$this->assertResult(false, $c, ['x' => 1], 'integer does not match string type');

0 commit comments

Comments
 (0)