Skip to content

Conversation

@ndossche
Copy link
Member

No description provided.

@ndossche ndossche requested a review from bukka as a code owner November 23, 2024 14:28
@ndossche ndossche linked an issue Nov 23, 2024 that may be closed by this pull request
@ndossche
Copy link
Member Author

Actually, throwing may be more appropriate here...

@ndossche ndossche marked this pull request as draft November 23, 2024 14:44
Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

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

Actually, throwing may be more appropriate here...

If we're following the behavior of foreach, then skipping the unset property would be most appropriate.

RETURN_FALSE;
}

if (Z_TYPE_P(entry) == IS_INDIRECT) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: May use ZVAL_DEINDIRECT().

@iluuu1994
Copy link
Member

iluuu1994 commented Nov 23, 2024

That said, this behavior is deprecated, so a complicated solution might not be necessary. Throwing until we eventually remove the feature sounds acceptable.

@ndossche
Copy link
Member Author

If we're following the behavior of foreach, then skipping the unset property would be most appropriate.

I guess this makes sense; I'll see how easy it is to do

@ndossche
Copy link
Member Author

Made that change, turns out that was quite easy to do.

@ndossche ndossche marked this pull request as ready for review November 23, 2024 15:09
}

RETURN_COPY_DEREF(entry);
ia_return_current(return_value, array, true);
Copy link
Member

Choose a reason for hiding this comment

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

This will implicitly advance when the current element is unset. E.g. with a current(), unset(), current(). I think it would be reasonable for current() not to advance, but to throw if the element is undef.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that's fair, same for key(), let me fix this.

@iluuu1994
Copy link
Member

Unfortunately, I found out that current() and key() also implicitly advance iterators for dynamic keys (more precisely, it's the unset() I believe). https://3v4l.org/LKlpQ I don't mind the current solution, but maybe my suggestion to not advance was not the most consistent... I'll let you decide what to do. In reality, I hope nobody relies on this.

@ndossche
Copy link
Member Author

Okay, I went back to the "move forward" behaviour as that seems most consistent.

Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

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

LGTM, sorry for the back and forth!

@ndossche
Copy link
Member Author

LGTM, sorry for the back and forth!

Nah don't worry, I should've checked myself better too ;)

@ndossche ndossche closed this in e1b4534 Nov 28, 2024
charmitro pushed a commit to wasix-org/php that referenced this pull request Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Internal iterator functions can't handle UNDEF properties

3 participants