#1038·mockery

Serialization of mocked objects in PHP 7.4

Author: okdewitCreated Feb 12, 2020Updated Mar 13, 2024

This snippet of code:

php
serialize(Mockery::mock(User::class))

works with Mockery 1.3.1, using PHP 7.3. Using PHP 7.4, keeping all else equal, it gives the exception:

Exception : Serialization of 'ReflectionClass' is not allowed

I suspect it's because of the changes merged into 7.4 after this RFC: https://wiki.php.net/rfc/custom_object_serialization However, that RFC claims to not have any BC-breaking changes.

Is there something that can be done to remedy this from the side of Mockery, or should this be considered a core PHP bug?