php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62629 IteratorIterator doesn't delegate count() method
Submitted: 2012-07-21 08:29 UTC Modified: 2012-07-21 14:46 UTC
From: zoeslam at gmail dot com Assigned: colder (profile)
Status: Closed Package: SPL related
PHP Version: 5.4.5 OS: Ubuntu 12.04
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:
48 - 39 = ?
Subscribe to this entry?

 
 [2012-07-21 08:29 UTC] zoeslam at gmail dot com
Description:
------------
This bug report MAY be similar to:

https://bugs.php.net/bug.php?id=62616

But behave differently

Test script:
---------------
class MyFile extends SplFileObject
{
    private $x = 10;
    private $y = 20;

    public function setX($x) { $this->x = $x; }
    public function setY($y) { $this->y = $y; }

    public function getX()   { return $this->x; }
    public function count()  { return $this->y; }
}

$myFile = new MyFile(__FILE__);

var_dump($myFile->getX());
var_dump($myFile->count());

$myFile->setX(15);
$myFile->setY(25);

var_dump($myFile->getX());
var_dump($myFile->count());

$ii = new IteratorIterator($myFile);

var_dump($ii->getX());
var_dump($ii->count());

Expected result:
----------------
int(10)
int(20)
int(15)
int(25)
int(15)
int(25)

Actual result:
--------------
int(10)
int(20)
int(15)
int(25)
int(15)

Notice: Undefined property: IteratorIterator::$y in /tmp/it.php on line 12
NULL

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-21 09:05 UTC] laruence@php.net
yeah, the reason should be the same.
 [2012-07-21 09:05 UTC] laruence@php.net
-Assigned To: +Assigned To: colder
 [2012-07-21 14:45 UTC] laruence@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2012-07-21 14:45 UTC] laruence@php.net
-Status: Assigned +Status: Closed
 [2012-07-21 14:46 UTC] laruence@php.net
refer to the commit log of #62616
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 10:01:29 2024 UTC