-
Notifications
You must be signed in to change notification settings - Fork 6
Replace each() function call with a foreach loop.
#23
base: master
Are you sure you want to change the base?
Conversation
|
👍 |
1ef64c6 to
d16f9fe
Compare
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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();
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