php-src/Zend/tests/bug48667_1.phpt
Nikita Popov c05a9c3dcd Implement interfaces after all methods available
The place where interface implementation handlers is called is
currently ill-defined: If the class implements interfaces itself,
the handlers for both the parent interfaces and the new interfaces
will be called after all methods are registered (post trait use).
If the class does not implement interfaces, then the parent
interface handlers are called early during inheritance (before
methods are inherited).

This commit moves the calls to always occur after all methods are
available. For userland classes this will be post trait import,
at the time where interfaces get implemented (whether the class
itself defines additional interfaces or not). For internal classes
it will be at the end of inheritance, as internal class declarations
do not have proper finalization.

This allows us to simplify the logic for implementing the magic
Iterator / IteratorAggregate interfaces. In particularly we can
now also automatically detect whether an extension of
IteratorAggregate can safely reuse a custom get_iterator handler,
or whether it needs to switch to the userland mechanism. The
Iterator case continues to rely on ZEND_ACC_REUSE_GET_ITERATOR
for this purpose, as a wholesale replacement is not possible there.
2020-03-04 10:29:21 +01:00

11 lines
271 B
PHP

--TEST--
Bug #48667 (Implementing both iterator and iteratoraggregate)
--FILE--
<?php
abstract class A implements Iterator, IteratorAggregate { }
?>
--EXPECTF--
Fatal error: Class A cannot implement both Iterator and IteratorAggregate at the same time in %s on line %d