|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62609 Allow implementing Traversable on abstract classes
Submitted: 2012-07-19 12:12 UTC Modified: 2020-03-05 17:54 UTC
Avg. Score:4.3 ± 0.9
Reproduced:2 of 3 (66.7%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: mateusz dot charytoniuk at gmail dot com Assigned: nikic (profile)
Status: Closed Package: SPL related
PHP Version: 5.4.4 OS: Debian wheezy/sid 3.2.0-3-amd64
Private report: No CVE-ID: None
 [2012-07-19 12:12 UTC] mateusz dot charytoniuk at gmail dot com
From manual page:

It would be interesting if one could add 'implements Traversable' to abstract class and then (in deriving classess) implement it either as Iterator or IteratorAggregate.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-01-09 01:18 UTC]
This appears to be a bug not a feature request, as it should be possible. e.g. in the code below the userland interface + abstract class is fine. But the internal interface and abstract class is not fine.


interface foo {
    public function bar();

abstract class b implements foo {} 
//compiles fine

abstract class a implements Traversable {}
//PHP Fatal error:  Class a must implement interface Traversable as part of either Iterator or IteratorAggregate in Unknown on line 0
 [2020-03-05 17:45 UTC]
-Assigned To: +Assigned To: nikic
 [2020-03-05 17:54 UTC]
-Summary: Traversable Interface +Summary: Allow implementing Traversable on abstract classes
 [2020-03-06 10:12 UTC]
Automatic comment on behalf of
Log: Fixed bug #62609: Allow implementing Traversable in abstract class
 [2020-03-06 10:12 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Dec 02 08:01:29 2023 UTC