Skip to content
This repository has been archived by the owner on May 15, 2020. It is now read-only.

Commit

Permalink
[BUGFIX] Pass reversibles as variable to the static closure
Browse files Browse the repository at this point in the history
  • Loading branch information
vertexvaar committed Feb 7, 2020
1 parent 6e137c1 commit 8a6f3e9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/ReversibleQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ public function enqueue(Reversible $reversible)

public function getExecutionClosure(): Closure
{
return static function($value) {
foreach ($this->reversibles as $reversible) {
$reversibles = $this->reversibles;
return static function($value) use ($reversibles) {
foreach ($reversibles as $reversible) {
$value = $reversible->getExecutionClosure()($value);
}
return $value;
Expand All @@ -27,8 +28,9 @@ public function getExecutionClosure(): Closure

public function getReversionClosure(): Closure
{
return static function($value) {
foreach (array_reverse($this->reversibles) as $reversible) {
$reversibles = array_reverse($this->reversibles);
return static function($value) use ($reversibles) {
foreach ($reversibles as $reversible) {
$value = $reversible->getReversionClosure()($value);
}
return $value;
Expand Down

0 comments on commit 8a6f3e9

Please sign in to comment.