Skip to content

Deprecate many ArrayIterator methods that are aliases to ArrayObject ones #7345

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

morrisonlevi
Copy link
Contributor

@morrisonlevi morrisonlevi commented Aug 6, 2021

This will need an RFC, I think.

These are needless, and cause problems (see some of the bugs lol).
Generally if you want these methods, use an ArrayObject directly.

I intend to remove these and possibly more in PHP 9.0 so that
ArrayIterator can be made efficient.

Of the deprecations included, the only ones I'm not sure about are
the serialize/unserialize ones with the Serializable interface. We
want those to go away eventually, but not sure if we're ready to
add a deprecation notice on this particular usage.

@morrisonlevi morrisonlevi changed the title Deprecate many of the ArrayIterator methods that are aliases to ArrayObject ones Deprecate many ArrayIterator methods that are aliases to ArrayObject ones Aug 6, 2021
@@ -7,10 +7,10 @@ var_dump($ao->getFlags());

$ao2 = new ArrayObject($ao);
var_dump($ao2->getFlags());
var_dump($ao2->getIterator()->getFlags());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to just switch off E-DEPRECATED in ini settings instead of using error_reporting(0). Is there a problem in fixing the test cases to avoid the deprecation warning or just silencing E_DEPRECATED?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignoring E_DEPRECATED is fine with me.

@krakjoe krakjoe added the RFC label Aug 8, 2021
@morrisonlevi morrisonlevi added this to the PHP 8.2 milestone Sep 21, 2021
…Object ones

These are needless, and cause problems (see some of the bugs lol).
Generally if you want these methods, use an ArrayObject directly.

I intend to _remove_ these and possibly more in PHP 9.0 so that
ArrayIterator can be made efficient.
@morrisonlevi morrisonlevi force-pushed the arrayiterator-deprecate branch from 2b37860 to 55ab025 Compare September 21, 2021 20:29
@morrisonlevi
Copy link
Contributor Author

I'm going to clean this up and prepare it for discussion.

@nikic, since you are the one who probably knows the most about
serialize/unserialize and what's best practice, what is your opinion on
the @deprecated for serialize/unserialize methods on ArrayIterator?
Too early, wrong, or go ahead?

@ralflang
Copy link
Contributor

I think it should be similar to what happens with the Serializable interface by itself:
If you only have

implements Serializable
public function serialize(): ?string
public function unserialize(string $data): void

then issue a notice DEPRECATED.

If you add

public function __serialize(): array
public function __unserialize(array $data): void

then you issue no notice DEPRECATED even if the Serializable interface is present.
I see no need to hurry this transition.

@morrisonlevi morrisonlevi removed this from the PHP 8.2 milestone May 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants