-
-
Notifications
You must be signed in to change notification settings - Fork 94
using each() is deprecated since PHP 7.2 #307
Conversation
7a14eec
to
7b0505c
Compare
@@ -79,10 +79,8 @@ public function onEvent(Event $event = null) | |||
{ | |||
reset($this->messages); |
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.
This line is probably unnecesary too
$this->handle($message, $this->dispatcher); | ||
|
||
unset($this->messages[$key]); |
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.
Maybe we should clear this variable after the foreach? To avoid changing behavior
9bf1822
to
3d9c3e3
Compare
3d9c3e3
to
c3847c4
Compare
@jordisala1991 looks like the |
why not? |
@@ -79,7 +79,7 @@ public function onEvent(Event $event = null) | |||
{ | |||
reset($this->messages); | |||
|
|||
while (list($key, $message) = each($this->messages)) { | |||
foreach ($this->messages as $key => $message) { | |||
$this->handle($message, $this->dispatcher); | |||
|
|||
unset($this->messages[$key]); |
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.
You cant unset like this in a foreach, you should move this line outside the foreach in the form:
$this->messages = [];
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.
You cant unset like this in a foreach
why not? oO
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.
Because you are removing elements on the foreach and php no longer knows what element is next.
On the old code it was doing a each until there are no elements on the array. That's why it was working before
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.
Other option would be doing a while with "there are elements on the array" condition, but IMO a foreach is cleaner
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.
still failing :(
Can you try something like this:
and you dont need to clear the array anymore |
Could you provide a PR against mine? |
@OskarStark OskarStark#1 there you go |
Thank you, currently need a lot of time for my son 😉 |
could you fix flintCI if you have time |
did it via the editor on github.com ;-) |
Please review @sonata-project/contributors |
Thanks @OskarStark ! |
I am targeting this branch, because its BC.
Closes #306
Changelog