mirror of
https://github.com/macintoshplus/mongo-php-driver.git
synced 2026-03-26 01:42:10 +01:00
Revert previous enum instantiation behavior and PersistableEnum trait from de5f1e5a93
Backed enums will be encoded as their case value. Non-backed cannot be encoded and no enums can be encoded at the root level.
Prohibit enums from implementing Persistable and Unserializable.
23 lines
486 B
PHP
23 lines
486 B
PHP
--TEST--
|
|
Enum cannot implement Persistable
|
|
--SKIPIF--
|
|
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
|
|
<?php skip_if_php_version('<', '8.1.0'); ?>
|
|
--FILE--
|
|
<?php
|
|
|
|
enum MyEnum implements MongoDB\BSON\Persistable
|
|
{
|
|
case A;
|
|
|
|
public function bsonSerialize(): array {}
|
|
|
|
public function bsonUnserialize(array $data): void {}
|
|
}
|
|
|
|
?>
|
|
===DONE===
|
|
<?php exit(0); ?>
|
|
--EXPECTF--
|
|
Fatal error: Enum class MyEnum cannot implement interface MongoDB\BSON\Persistable in %s on line %d
|