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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mateusz dot charytoniuk at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 08:01:28 2024 UTC