Skip to content

Commit

Permalink
Add collection context as 3rd param to item tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
jakejohns committed Jul 9, 2016
1 parent 4478c7a commit 37b5788
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Runner.php
Expand Up @@ -188,7 +188,7 @@ protected function runItemTasks($items, $tasks)
foreach ($tasks as $spec) {
$task = $this->resolve($spec);
foreach ($items as $key => $value) {
$task($value, $key);
$task($value, $key, $items);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion tests/RunnerTest.php
Expand Up @@ -15,11 +15,13 @@ public function setUp()
$test = $this;

$this->input = [1,2,3,4];
$input = $this->input;

$this->each = function ($value, $key) use ($test) {
$this->each = function ($value, $key, $context) use ($test, $input) {
static $idx = 0;
$test->assertEquals($value, $idx + 1);
$test->assertEquals($key, $idx);
$this->assertEquals($context, $input);
$idx++;
};

Expand Down

0 comments on commit 37b5788

Please sign in to comment.