php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #67558 Method call passthrough of IteratorIterator is not documented
Submitted: 2014-07-03 09:17 UTC Modified: 2018-07-08 14:19 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: chris at cs278 dot org Assigned: cmb (profile)
Status: Closed Package: SPL related
PHP Version: Irrelevant OS: n/a
Private report: No CVE-ID: None
 [2014-07-03 09:17 UTC] chris at cs278 dot org
Description:
------------
If you call a method that does not exist on an IteratorIterator, it delegates that call to the inner iterator. The test script demonstrates this non existent method delegation.

I'm unable to find any reference to this behaviour in the documentation.

It should probably also be documented that implementing __call() will replace the normal delegation.

Test script:
---------------
<?php

$inner = new ArrayIterator([1, 2]);
$outer = new IteratorIterator($inner);

var_dump(method_exists(get_class($outer), 'count'));
var_dump(method_exists($outer, 'count'));
var_dump($outer->count());

// bool(false)
// bool(true)
// int(2)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-07-08 14:19 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2018-07-08 14:19 UTC] cmb@php.net
This issue has been resolved in the meantime:
<http://svn.php.net/viewvc?view=revision&revision=337231>.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 07:01:28 2024 UTC