📁 File Manager Pro
v10.0.3 | PHP: 7.4.33
Server: LiteSpeed
2026-07-12 05:55:27
📂
/ (Root)
/
opt
/
alt
/
tests
/
alt-php83-pecl-mongodb_1.18.1-1.el8
/
tests
📍 /opt/alt/tests/alt-php83-pecl-mongodb_1.18.1-1.el8/tests
🔄 Refresh
✏️
Editing: bson-fromPHP_error-005.phpt
Read Only
--TEST-- MongoDB\BSON\fromPHP(): Serializable with circular references --FILE-- <?php require_once __DIR__ . '/../utils/basic.inc'; class MyRecursiveSerializable implements MongoDB\BSON\Serializable { public $child = 1; #[\ReturnTypeWillChange] public function bsonSerialize() { return $this; } } class MyIndirectlyRecursiveSerializable extends MyRecursiveSerializable { #[\ReturnTypeWillChange] public function bsonSerialize() { return ['parent' => $this]; } } echo "\nTesting Serializable with direct circular reference\n"; echo throws(function() { fromPHP(new MyRecursiveSerializable); }, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; echo "\nTesting Serializable with indirect circular reference\n"; echo throws(function() { fromPHP(new MyIndirectlyRecursiveSerializable); }, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n"; ?> ===DONE=== <?php exit(0); ?> --EXPECT-- Testing Serializable with direct circular reference OK: Got MongoDB\Driver\Exception\UnexpectedValueException Expected MyRecursiveSerializable::bsonSerialize() to return an array, stdClass, MongoDB\BSON\Document, or MongoDB\BSON\PackedArray, MyRecursiveSerializable given Testing Serializable with indirect circular reference OK: Got MongoDB\Driver\Exception\UnexpectedValueException Detected recursion for field path "parent.parent" ===DONE===
💾 Save Changes
❌ Cancel