|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-01-28 08:51 UTC] andrey@php.net
Description:
------------
See the code attached :
class FubarOK has no problem implementing Iterator. interface NewIterator just extends Iterator and adds nothing, and here comes the fun - an error message when FubarProblem tries to implement NewIterator.
Reproduce code:
---------------
<?php
class FubarOk implements Iterator {
public function next(){}
public function key(){}
public function current(){}
public function hasMore(){}
public function rewind(){}
}
interface NewIterator extends Iterator {
}
class FubarProblem implements NewIterator {
public function next(){}
public function key(){}
public function current(){}
public function hasMore(){}
public function rewind(){}
}
?>
Actual result:
--------------
PHP Fatal error: Class FubarProblem must implement interface Traversable as
part of either Iterator or IteratorAggregate in Unknown on line 0
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 02:00:01 2025 UTC |
This is something we may fix later but for now the following is enough: class FubarProblem implements Iterator, NewIterator { public function next(){} public function key(){} public function current(){} public function hasMore(){} public function rewind(){} } As you see here the Iterator interface is inherited first so that the checks are done in the correct order.