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.
21 lines
476 B
PHP
21 lines
476 B
PHP
--TEST--
|
|
Backed enum cannot implement Unserializable
|
|
--SKIPIF--
|
|
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
|
|
<?php skip_if_php_version('<', '8.1.0'); ?>
|
|
--FILE--
|
|
<?php
|
|
|
|
enum MyBackedEnum: int implements MongoDB\BSON\Unserializable
|
|
{
|
|
case A = 1;
|
|
|
|
public function bsonUnserialize(array $data): void {}
|
|
}
|
|
|
|
?>
|
|
===DONE===
|
|
<?php exit(0); ?>
|
|
--EXPECTF--
|
|
Fatal error: Enum class MyBackedEnum cannot implement interface MongoDB\BSON\Unserializable in %s on line %d
|