Bug #67782 [Opn]: Internal Cursors
| From: | fredemmott@php.net | Date: | Tue, 30 Jun 2015 17:02:29 +0000 |
| Subject: | Bug #67782 [Opn]: Internal Cursors | ||
| References: | 1 | Groups: | php.standards |
| Request: | Send a blank email to standards-+get-829@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67782&edit=1
ID: 67782
Updated by: fredemmott@php.net
Reported by: joelm@php.net
Summary: Internal Cursors
Status: Open
Type: Bug
Package: PHP Language Specification
PHP Version: PHP-5.6
Block user comment: N
Private report: N
New Comment:
In case this does get documented: one weird case is that these also work with some container
objects, but not subclasses of them - eg if you override offsetGet in an ArrayObject subclass, you
get different results with cur/next/prev vs other forms of iteration.
For what it's worth, HHVM hasn't implemented these for objects and we've had very few
compatibility issues reported because of this; almost all of the reports actually turned out to be
buggy PHP code because of the subtleties of it.
Previous Comments:
------------------------------------------------------------------------
[2015-06-28 21:55:42] stas@php.net
I'm not sure this has a place in the spec, as this is largely an implementation detail, also
one that changes somewhat between 5.6 and 7.
------------------------------------------------------------------------
[2014-08-05 17:11:59] joelm@php.net
Description:
------------
https://github.com/php/php-langspec/blob/master/spec/12-arrays.md#arrays
The concept of an array's internal cursor or an object's internal cursor is never
mentioned. The state of the internal cursor of an array or object can be witnessed via the
current(), key(), next(), prev(), reset(), end(), and each() library functions. While it's
technically library functions that expose the state of the cursor to the programmer, you can find
code deep in the core array/object implementation of PHP5 that deals with and maintains internal
cursors. Also, internal cursors get mentioned in various parts of the php.net documentation,
including the documentation for "foreach", so internal cursors are arguably a language
feature.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67782&edit=1