-
Notifications
You must be signed in to change notification settings - Fork 813
Open
Labels
Status: Needs TriagebugDocumentation contains incorrect informationDocumentation contains incorrect information
Description
Description
the docs describe foreach
as
The foreach construct provides an easy way to iterate over arrays and Traversable objects. foreach will issue an error when used with a variable containing a different data type or with an uninitialized variable.
while working on a PHPStan issue, I recently discovered that php also allows to iterate over an object implementing ArrayAccess
, even though thats neither Traversable
nor is_iterable
nor is_array
.
see https://3v4l.org/NMrFZ#veol
I am a bit lost whether
- this actually works like expected?
- this needs a doc update?
- php-src misses to issue a error/warning?
- whether I am overlooking something
PHP Version
any since PHP 7.1+
Operating System
macOS sequioa
Metadata
Metadata
Assignees
Labels
Status: Needs TriagebugDocumentation contains incorrect informationDocumentation contains incorrect information