Skip to content

Commit b27fa4d

Browse files
authored
PHPC-1965 Re-enable PHP 8.1 build on GH Actions (#1258)
* Re-enable PHP 8.1 build on GH Actions * Work around different error wording in PHP 8.1 * Limit failing tests to PHP < 8.1 * Add tests for PHPC-1839 for PHP >= 8.1
1 parent f663761 commit b27fa4d

35 files changed

+260
-32
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ jobs:
2525
php-version:
2626
- "7.4"
2727
- "8.0"
28-
# Re-enable after PHPC-1849 is resolved
29-
# - "8.1"
28+
- "8.1"
3029
mongodb-version:
3130
- "4.4"
3231
topology:

tests/bson/bson-binary_error-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MyBinary extends MongoDB\BSON\Binary {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MyBinary may not inherit from final class (MongoDB\BSON\Binary) in %s on line %d
12+
Fatal error: Class MyBinary %s final class %SMongoDB\BSON\Binary%S in %s on line %d

tests/bson/bson-dbpointer_error-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MyDBPointer extends MongoDB\BSON\DBPointer {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MyDBPointer may not inherit from final class (MongoDB\BSON\DBPointer) in %s on line %d
12+
Fatal error: Class MyDBPointer %s final class %SMongoDB\BSON\DBPointer%S in %s on line %d

tests/bson/bson-decimal128_error-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MyDecimal128 extends MongoDB\BSON\Decimal128 {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MyDecimal128 may not inherit from final class (MongoDB\BSON\Decimal128) in %s on line %d
12+
Fatal error: Class MyDecimal128 %s final class %SMongoDB\BSON\Decimal128%S in %s on line %d

tests/bson/bson-int64_error-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MyInt64 extends MongoDB\BSON\Int64 {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MyInt64 may not inherit from final class (MongoDB\BSON\Int64) in %s on line %d
12+
Fatal error: Class MyInt64 %s final class %SMongoDB\BSON\Int64%S in %s on line %d

tests/bson/bson-javascript_error-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MyJavascript extends MongoDB\BSON\Javascript {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MyJavascript may not inherit from final class (MongoDB\BSON\Javascript) in %s on line %d
12+
Fatal error: Class MyJavascript %s final class %SMongoDB\BSON\Javascript%S in %s on line %d

tests/bson/bson-maxkey_error-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MyMaxKey extends MongoDB\BSON\MaxKey {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MyMaxKey may not inherit from final class (MongoDB\BSON\MaxKey) in %s on line %d
12+
Fatal error: Class MyMaxKey %s final class %SMongoDB\BSON\MaxKey%S in %s on line %d

tests/bson/bson-minkey_error-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MyMinKey extends MongoDB\BSON\MinKey {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MyMinKey may not inherit from final class (MongoDB\BSON\MinKey) in %s on line %d
12+
Fatal error: Class MyMinKey %s final class %SMongoDB\BSON\MinKey%S in %s on line %d

tests/bson/bson-objectid_error-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MyObjectId extends MongoDB\BSON\ObjectId {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MyObjectId may not inherit from final class (MongoDB\BSON\ObjectId) in %s on line %d
12+
Fatal error: Class MyObjectId %s final class %SMongoDB\BSON\ObjectId%S in %s on line %d

tests/bson/bson-regex_error-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MyRegex extends MongoDB\BSON\Regex {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MyRegex may not inherit from final class (MongoDB\BSON\Regex) in %s on line %d
12+
Fatal error: Class MyRegex %s final class %SMongoDB\BSON\Regex%S in %s on line %d

tests/bson/bson-symbol_error-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MySymbol extends MongoDB\BSON\Symbol {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MySymbol may not inherit from final class (MongoDB\BSON\Symbol) in %s on line %d
12+
Fatal error: Class MySymbol %s final class %SMongoDB\BSON\Symbol%S in %s on line %d

tests/bson/bson-timestamp_error-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MyTimestamp extends MongoDB\BSON\Timestamp {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MyTimestamp may not inherit from final class (MongoDB\BSON\Timestamp) in %s on line %d
12+
Fatal error: Class MyTimestamp %s final class %SMongoDB\BSON\Timestamp%S in %s on line %d

tests/bson/bson-undefined_error-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MyUndefined extends MongoDB\BSON\Undefined {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MyUndefined may not inherit from final class (MongoDB\BSON\Undefined) in %s on line %d
12+
Fatal error: Class MyUndefined %s final class %SMongoDB\BSON\Undefined%S in %s on line %d

tests/bson/bson-utcdatetime_error-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MyUTCDateTime extends MongoDB\BSON\UTCDateTime {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MyUTCDateTime may not inherit from final class (MongoDB\BSON\UTCDateTime) in %s on line %d
12+
Fatal error: Class MyUTCDateTime %s final class %SMongoDB\BSON\UTCDateTime%S in %s on line %d

tests/bson/bug1839-001.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
--TEST--
2-
PHPC-1839: Referenced, out-of-scope, non-interned string in typeMap
2+
PHPC-1839: Referenced, out-of-scope, non-interned string in typeMap (PHP < 8.1)
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_php_version('>=', '8.1'); ?>
36
--FILE--
47
<?php
58
require_once __DIR__ . "/../utils/basic.inc";

tests/bson/bug1839-002.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
--TEST--
2-
PHPC-1839: Referenced, local, non-interned string in typeMap
2+
PHPC-1839: Referenced, local, non-interned string in typeMap (PHP < 8.1)
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_php_version('>=', '8.1'); ?>
36
--FILE--
47
<?php
58
require_once __DIR__ . "/../utils/basic.inc";

tests/bson/bug1839-003.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
--TEST--
2-
PHPC-1839: Referenced, out-of-scope, interned string in typeMap
2+
PHPC-1839: Referenced, out-of-scope, interned string in typeMap (PHP < 8.1)
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_php_version('>=', '8.1'); ?>
36
--FILE--
47
<?php
58
require_once __DIR__ . "/../utils/basic.inc";

tests/bson/bug1839-004.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
--TEST--
2-
PHPC-1839: Referenced, local, interned string in typeMap
2+
PHPC-1839: Referenced, local, interned string in typeMap (PHP < 8.1)
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_php_version('>=', '8.1'); ?>
36
--FILE--
47
<?php
58
require_once __DIR__ . "/../utils/basic.inc";

tests/bson/bug1839-005.phpt

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
--TEST--
2+
PHPC-1839: Referenced, out-of-scope, non-interned string in typeMap (PHP >= 8.1)
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_php_version('<', '8.1'); ?>
6+
--FILE--
7+
<?php
8+
require_once __DIR__ . "/../utils/basic.inc";
9+
10+
function createTypemap()
11+
{
12+
// Assemble the string so as to not have an interned string
13+
$rootValue = chr(ord('a')) . 'rray';
14+
$documentValue = chr(ord('a')) . 'rray';
15+
16+
// Use a reference to this non-interned string in the type map
17+
$typemap = ['root' => &$rootValue, 'document' => &$documentValue];
18+
19+
return $typemap;
20+
}
21+
22+
$typemap = createTypemap();
23+
$bson = MongoDB\BSON\fromPhp((object) []);
24+
25+
echo "Before:\n";
26+
debug_zval_dump($typemap);
27+
28+
MongoDB\BSON\toPHP($bson, $typemap);
29+
30+
echo "After:\n";
31+
debug_zval_dump($typemap);
32+
33+
?>
34+
===DONE===
35+
<?php exit(0); ?>
36+
--EXPECT--
37+
Before:
38+
array(2) refcount(2){
39+
["root"]=>
40+
reference refcount(1) {
41+
string(5) "array" refcount(1)
42+
}
43+
["document"]=>
44+
reference refcount(1) {
45+
string(5) "array" refcount(1)
46+
}
47+
}
48+
After:
49+
array(2) refcount(2){
50+
["root"]=>
51+
reference refcount(1) {
52+
string(5) "array" refcount(1)
53+
}
54+
["document"]=>
55+
reference refcount(1) {
56+
string(5) "array" refcount(1)
57+
}
58+
}
59+
===DONE===

tests/bson/bug1839-006.phpt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
--TEST--
2+
PHPC-1839: Referenced, local, non-interned string in typeMap (PHP >= 8.1)
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_php_version('<', '8.1'); ?>
6+
--FILE--
7+
<?php
8+
require_once __DIR__ . "/../utils/basic.inc";
9+
10+
// Assemble the string so as to not have an interned string
11+
$rootValue = chr(ord('a')) . 'rray';
12+
$documentValue = chr(ord('a')) . 'rray';
13+
14+
$typemap = ['root' => &$rootValue, 'document' => &$documentValue];
15+
$bson = MongoDB\BSON\fromPhp((object) []);
16+
17+
echo "Before:\n";
18+
debug_zval_dump($typemap);
19+
20+
MongoDB\BSON\toPHP($bson, $typemap);
21+
22+
echo "After:\n";
23+
debug_zval_dump($typemap);
24+
25+
?>
26+
===DONE===
27+
<?php exit(0); ?>
28+
--EXPECT--
29+
Before:
30+
array(2) refcount(2){
31+
["root"]=>
32+
reference refcount(2) {
33+
string(5) "array" refcount(1)
34+
}
35+
["document"]=>
36+
reference refcount(2) {
37+
string(5) "array" refcount(1)
38+
}
39+
}
40+
After:
41+
array(2) refcount(2){
42+
["root"]=>
43+
reference refcount(2) {
44+
string(5) "array" refcount(1)
45+
}
46+
["document"]=>
47+
reference refcount(2) {
48+
string(5) "array" refcount(1)
49+
}
50+
}
51+
===DONE===

tests/bson/bug1839-007.phpt

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
--TEST--
2+
PHPC-1839: Referenced, out-of-scope, interned string in typeMap (PHP >= 8.1)
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_php_version('<', '8.1'); ?>
6+
--FILE--
7+
<?php
8+
require_once __DIR__ . "/../utils/basic.inc";
9+
10+
function createTypemap()
11+
{
12+
$rootValue = 'array';
13+
$documentValue = 'array';
14+
15+
$typemap = ['root' => &$rootValue, 'document' => &$documentValue];
16+
17+
return $typemap;
18+
}
19+
20+
$typemap = createTypemap();
21+
$bson = MongoDB\BSON\fromPhp((object) []);
22+
23+
echo "Before:\n";
24+
debug_zval_dump($typemap);
25+
26+
MongoDB\BSON\toPHP($bson, $typemap);
27+
28+
echo "After:\n";
29+
debug_zval_dump($typemap);
30+
31+
?>
32+
===DONE===
33+
<?php exit(0); ?>
34+
--EXPECT--
35+
Before:
36+
array(2) refcount(2){
37+
["root"]=>
38+
reference refcount(1) {
39+
string(5) "array" interned
40+
}
41+
["document"]=>
42+
reference refcount(1) {
43+
string(5) "array" interned
44+
}
45+
}
46+
After:
47+
array(2) refcount(2){
48+
["root"]=>
49+
reference refcount(1) {
50+
string(5) "array" interned
51+
}
52+
["document"]=>
53+
reference refcount(1) {
54+
string(5) "array" interned
55+
}
56+
}
57+
===DONE===

tests/bson/bug1839-008.phpt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
--TEST--
2+
PHPC-1839: Referenced, local, interned string in typeMap (PHP >= 8.1)
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_php_version('<', '8.1'); ?>
6+
--FILE--
7+
<?php
8+
require_once __DIR__ . "/../utils/basic.inc";
9+
10+
$rootValue = 'array';
11+
$documentValue = 'array';
12+
13+
$typemap = ['root' => &$rootValue, 'document' => &$documentValue];
14+
$bson = MongoDB\BSON\fromPhp((object) []);
15+
16+
echo "Before:\n";
17+
debug_zval_dump($typemap);
18+
19+
MongoDB\BSON\toPHP($bson, $typemap);
20+
21+
echo "After:\n";
22+
debug_zval_dump($typemap);
23+
24+
?>
25+
===DONE===
26+
<?php exit(0); ?>
27+
--EXPECT--
28+
Before:
29+
array(2) refcount(2){
30+
["root"]=>
31+
reference refcount(2) {
32+
string(5) "array" interned
33+
}
34+
["document"]=>
35+
reference refcount(2) {
36+
string(5) "array" interned
37+
}
38+
}
39+
After:
40+
array(2) refcount(2){
41+
["root"]=>
42+
reference refcount(2) {
43+
string(5) "array" interned
44+
}
45+
["document"]=>
46+
reference refcount(2) {
47+
string(5) "array" interned
48+
}
49+
}
50+
===DONE===

tests/bulk/bulkwrite_error-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MyBulkWrite extends MongoDB\Driver\BulkWrite {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MyBulkWrite may not inherit from final class (MongoDB\Driver\BulkWrite) in %s on line %d
12+
Fatal error: Class MyBulkWrite %s final class %SMongoDB\Driver\BulkWrite%S in %s on line %d

tests/command/command_error-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MyCommand extends MongoDB\Driver\Command {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MyCommand may not inherit from final class (MongoDB\Driver\Command) in %s on line %d
12+
Fatal error: Class MyCommand %s final class %SMongoDB\Driver\Command%S in %s on line %d

tests/cursor/cursor_error-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MyCursor extends MongoDB\Driver\Cursor {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MyCursor may not inherit from final class (MongoDB\Driver\Cursor) in %s on line %d
12+
Fatal error: Class MyCursor %s final class %SMongoDB\Driver\Cursor%S in %s on line %d

tests/cursorid/cursorid_error-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MyCursorId extends MongoDB\Driver\CursorId {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MyCursorId may not inherit from final class (MongoDB\Driver\CursorId) in %s on line %d
12+
Fatal error: Class MyCursorId %s final class %SMongoDB\Driver\CursorId%S in %s on line %d

tests/manager/manager_error-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MyManager extends MongoDB\Driver\Manager {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MyManager may not inherit from final class (MongoDB\Driver\Manager) in %s on line %d
12+
Fatal error: Class MyManager %s final class %SMongoDB\Driver\Manager%S in %s on line %d

tests/query/query_error-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MyQuery extends MongoDB\Driver\Query {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MyQuery may not inherit from final class (MongoDB\Driver\Query) in %s on line %d
12+
Fatal error: Class MyQuery %s final class %SMongoDB\Driver\Query%S in %s on line %d

tests/readConcern/readconcern_error-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MyReadConcern extends MongoDB\Driver\ReadConcern {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MyReadConcern may not inherit from final class (MongoDB\Driver\ReadConcern) in %s on line %d
12+
Fatal error: Class MyReadConcern %s final class %SMongoDB\Driver\ReadConcern%S in %s on line %d

tests/readPreference/readpreference_error-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ class MyReadPreference extends MongoDB\Driver\ReadPreference {}
99
===DONE===
1010
<?php exit(0); ?>
1111
--EXPECTF--
12-
Fatal error: Class MyReadPreference may not inherit from final class (MongoDB\Driver\ReadPreference) in %s on line %d
12+
Fatal error: Class MyReadPreference %s final class %SMongoDB\Driver\ReadPreference%S in %s on line %d

0 commit comments

Comments
 (0)