php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #80454 SplFixedArray now implements IteratorAggregate instead of Iterator
Submitted: 2020-12-01 14:05 UTC Modified: 2020-12-02 10:18 UTC
From: brucekwells at gmail dot com Assigned:
Status: Verified Package: SPL related
PHP Version: 8.0.0 OS: Window 10 latest
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: brucekwells at gmail dot com
New email:
PHP Version: OS:

 

 [2020-12-01 14:05 UTC] brucekwells at gmail dot com
Description:
------------
The test script produces the following error on PHP 8.0.0:


Fatal error: Uncaught TypeError: NoRewindIterator::__construct(): Argument #1 ($iterator) must be of type Iterator, SplFixedArray given

Works on PHP 7.4.9

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

$tokens = [1,2,3];
new NoRewindIterator(SplFixedArray::fromArray($tokens));

Expected result:
----------------
No error message generated

Actual result:
--------------
Fatal error: Uncaught TypeError: NoRewindIterator::__construct(): Argument #1 ($iterator) must be of type Iterator, SplFixedArray given in filename.php

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-01 14:16 UTC] cmb@php.net
-Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem -Package: *Programming Data Structures +Package: SPL related
 [2020-12-01 14:16 UTC] cmb@php.net
As of PHP 8.0.0, SplFixedArray no longer implements Iterator, but
rather IteratorAggregate.  Use the ::getIterator() method to get
the Iterator: <https://3v4l.org/13jav>.

This is documented in the migration guide[1], but not in the
manual proper.

[1] <https://www.php.net/manual/en/migration80.incompatible.php#migration80.incompatible.spl>
 [2020-12-02 10:18 UTC] nikic@php.net
-Summary: Type mismatch error +Summary: SplFixedArray now implements IteratorAggregate instead of Iterator
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC