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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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: Tue Mar 19 08:01:29 2024 UTC