phpspec / prophecy

Highly opinionated mocking framework for PHP 5.3+
MIT License
8.53k stars 241 forks source link

Doubling Enums #536

Closed ciaranmcnulty closed 2 years ago

ciaranmcnulty commented 3 years ago

We will need to handle Enum types being doubled.

(If this is difficult we could at least show a sensible 'not supported yet' message when it's attempted)

https://php.watch/versions/8.1/enums

sebastianbergmann commented 3 years ago

I do not see how this would be possible since enumerations are final:

$ php -a
Interactive shell

php > enum Suit {
    case Clubs;
    case Diamonds;
    case Hearts;
    case Spades;
}
php > $rc = new ReflectionClass(Suit::class);
php > var_dump($rc->isFinal());
bool(true)

And on the conceptual level, I do not think that doubling enumerations makes sense.

ciaranmcnulty commented 3 years ago

Thanks @sebastianbergmann, it just needs a test around it then probably? I need to check the developer experience basically

sebastianbergmann commented 3 years ago

Here's what I did for PHPUnit: https://github.com/sebastianbergmann/phpunit/commit/5c7f79d9a4878ba6b93caf30b6a03baea04e47b3