Skip to content

SplFixedArray::valid() is unavailable #4575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
divinity76 opened this issue Mar 31, 2025 · 2 comments
Open

SplFixedArray::valid() is unavailable #4575

divinity76 opened this issue Mar 31, 2025 · 2 comments
Labels
bug Documentation contains incorrect information Status: Needs Triage

Comments

@divinity76
Copy link
Contributor

Description

The following code:

<?php
(new SplFixedArray(0))->valid();

Resulted in this output:

    Fatal error: Uncaught Error: Call to undefined method SplFixedArray::valid() in /in/9mO1i:2
    Stack trace:
    #0 {main}
      thrown in /in/9mO1i on line 2

    Process exited with code 255.

But I expected this output instead:

(blank)

I don't see any notice about SplFixedArray::valid being deprecated/removed in the documentation, and there's no mention of it in the PHP8.0.0 changelog https://www.php.net/ChangeLog-8.php either,

but it has been unavailable since PHP8.0.0.

PHP Version

PHP8.4.5

Operating System

No response

@divinity76 divinity76 added bug Documentation contains incorrect information Status: Needs Triage labels Mar 31, 2025
@DanielEScherzer
Copy link
Member

From php/php-src@4222ae1

SplFixedArray is now an IteratorAggregate and not an Iterator.
SplFixedArray::rewind(), ::current(), ::key(), ::next(), and ::valid()
have been removed. In their place, SplFixedArray::getIterator() has been
added. Any code which uses explicit iteration over SplFixedArray must now
obtain an Iterator through SplFixedArray::getIterator(). This means that
SplFixedArray is now safe to use in nested loops.

From https://www.php.net/ChangeLog-8.php#8.0.0

SplFixedArray is now IteratorAggregate rather than Iterator.

We should probably document this better though, e.g. add a changelog to https://www.php.net/manual/en/splfixedarray.valid.php and the other methods indicating when they were removed

@divinity76
Copy link
Contributor Author

Sounds like a documentation issue then. Can someone move it?

@TimWolla TimWolla transferred this issue from php/php-src Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Documentation contains incorrect information Status: Needs Triage
Projects
None yet
Development

No branches or pull requests

2 participants