Skip to content
This repository was archived by the owner on Sep 20, 2021. It is now read-only.

Conversation

@shulard
Copy link
Contributor

@shulard shulard commented Feb 5, 2018

The each function was deprecated with the release of PHP7.2.
It's now replaced with a foreach loop.

For more details see: https://wiki.php.net/rfc/deprecations_php_7_2#each

@guiled
Copy link
Member

guiled commented Feb 9, 2018

👍
I do support this PR as I start to use realdom with atoum in PHP7.2 and I have an error because of each()

@shulard shulard force-pushed the fix/php72-deprecation-each branch from 1ef64c6 to d16f9fe Compare February 10, 2018 15:25
The each function was deprecated with the release of PHP7.2.
It's now replaced with a foreach loop.

For more details see: https://wiki.php.net/rfc/deprecations_php_7_2#each
}

while (list($name, $default) = each($this->_arguments)) {
do {
Copy link
Member

Choose a reason for hiding this comment

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

(previous comment lost)
I think you should keep a while() (} loop because $this->_arguments might be already at the end because of the previous next() call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From the PHP.net doc, it seems that each return the current key / value even, next moves the cursor. The do {} while () loop give the same behavior in our case.

Copy link
Member

@guiled guiled Feb 12, 2018

Choose a reason for hiding this comment

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

The thing is that while (each() ) {} doesn't enter into the loop if the pointer is already at the end because of this line

So, it could be possible that all this block is run while there is no more _arguments.

The while () {} prevent this but makes it a little more difficult than the do {} while();

@Hywan
Copy link
Member

Hywan commented Feb 12, 2018

I'm good with this PR, thanks! I would like to double check with @Pierozi and @guiled though.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Development

Successfully merging this pull request may close these issues.

4 participants