Skip to content

Conversation

iluuu1994
Copy link
Member

Fixes GH-20177

@iluuu1994
Copy link
Member Author

One side-effect in this PR is that this will also affect foreach ($this as $prop). https://3v4l.org/rCSNe#v8.4.13 Doesn't seem obvious what the "right" solution is here. Another approach might be to adjust just get_object_vars() to skip properties that have already been set, i.e. ones that were set by the parent class.

@nielsdos
Copy link
Member

Right. I understand the BC concern. Although I'd also expect that get_object_vars() and foreach() behaves consistently.

@iluuu1994
Copy link
Member Author

@nielsdos Right. Maybe it's ok to merge this for master then. The docs say:

https://www.php.net/manual/en/language.oop5.iterations.php

By default, all visible properties will be used for the iteration.

I guess the child property can be thought of as "reverse shadowed". Though I don't think these semantics were ever properly described or even considered.

@nielsdos
Copy link
Member

Agreed. This is kinda underspecified.

@iluuu1994
Copy link
Member Author

Pinging @bwoebi, as he has had opinions on previous, similar issues. ^^

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.

2 participants