php.net |  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
Votes:3
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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
22 + 10 = ?
Subscribe to this entry?

 
 [2012-07-19 12:12 UTC] mateusz dot charytoniuk at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/class.traversable
---

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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-01-09 01:18 UTC] danack@php.net
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.

<?php 

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] nikic@php.net
-Assigned To: +Assigned To: nikic
 [2020-03-05 17:54 UTC] nikic@php.net
-Summary: Traversable Interface +Summary: Allow implementing Traversable on abstract classes
 [2020-03-06 10:12 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e9ae581f024e06878b2b1991b7daed6318c811a7
Log: Fixed bug #62609: Allow implementing Traversable in abstract class
 [2020-03-06 10:12 UTC] nikic@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Sep 22 22:01:24 2020 UTC