History log of /PHP-8.1/Zend/tests/stringable_internal_class.phpt (Results 1 – 1 of 1)
Revision Date Author Comments
# b302bfab 05-Nov-2021 Nikita Popov

Implement Stringable automatically for internal classes

Requiring all internal classes (including those from 3rd-party
extensions) to implement Stringable if they provide __toString()

Implement Stringable automatically for internal classes

Requiring all internal classes (including those from 3rd-party
extensions) to implement Stringable if they provide __toString()
is too error prone. Case in point, our _ZendTestClass test class
was not doing so, resulting in preloading test failures after
recent changes.

Instead we automatically implement Stringable, the same as we do
for userland classes. We still allow explicit implementations,
but ignore them (normally they would result in an error due to
duplicate interface implementation). Finally, we need to be
careful about not trying to implement Stringable on Stringable
itself.

In some cases this changes the interface order, in particular the
automatic Stringable implementation will now come first.

show more ...