Open sandrokeil opened 6 years ago
Did you ever actually solve this? This should work, but I'll check it out in a bit to make sure that it does.
This is here because the maintained release repository fork by FastDebug - Carlos,has no issues reporting.
Issue is that Php::Traversible code as documented online will not work as advertised in later versions of PHP. This likely happened for 7.3 and later.
On 8.1 for instance, the "Map" example as found in the online documentation, or similar, will not work.
On using the example code with minimal fixup for compile and link , PHP 8.1 reports - "PHP Fatal error: Class Map must implement interface Traversable as part of either Iterator or IteratorAggregate in Unknown on line 0". Similar for code that did work with PHP 7.2.
IteratorAggregate demands that a real PHP class be returned with public "getIterator() method. Such a class needs to implement public IteratorAggregate,
The solution could be to make a class that declares itself as implementing the IteratorAggregate interface, and return the iterator object that way.
That's another thing - this and perhaps a few other online examples don't have source code in the repository "Examples". Which should be also good for basic test cases. There are not enough examples and test cases.
We have implemented a traversable class like
but in PHP the
instanceOf \Traversable
check will fail. If I use reflection to get the implemented interfaces, nothing is implemented. The extension export with addedimplements("Traversable")
doesn't work.Is there anything I missed? How can I let PHP know, that the
Cursor
class implemente the PHP native interfaceTraversable
to use PHP classes like IteratorIterator?