Skip to content

Commit

Permalink
Remove query as an argument to result formatter methods.
Browse files Browse the repository at this point in the history
The Query argument is not always passed consistently, and is a bit
unnecessary as one can always close over the query argument if it is
needed.

Refs #5689
  • Loading branch information
markstory committed Jan 19, 2015
1 parent 5460105 commit c87168b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Datasource/QueryTrait.php
Expand Up @@ -432,7 +432,7 @@ protected function _decorateResults($result)
}

foreach ($this->_formatters as $formatter) {
$result = $formatter($result, $this);
$result = $formatter($result);
}

if (!empty($this->_formatters) && !($result instanceof $decorator)) {
Expand Down
6 changes: 2 additions & 4 deletions tests/TestCase/ORM/QueryTest.php
Expand Up @@ -1815,8 +1815,7 @@ public function testQueryWithFormatter()
{
$table = TableRegistry::get('authors');
$query = new Query($this->connection, $table);
$query->select()->formatResults(function ($results, $q) use ($query) {
$this->assertSame($query, $q);
$query->select()->formatResults(function ($results) {
$this->assertInstanceOf('Cake\ORM\ResultSet', $results);
return $results->indexBy('id');
});
Expand All @@ -1832,8 +1831,7 @@ public function testQueryWithStackedFormatters()
{
$table = TableRegistry::get('authors');
$query = new Query($this->connection, $table);
$query->select()->formatResults(function ($results, $q) use ($query) {
$this->assertSame($query, $q);
$query->select()->formatResults(function ($results) {
$this->assertInstanceOf('Cake\ORM\ResultSet', $results);
return $results->indexBy('id');
});
Expand Down

0 comments on commit c87168b

Please sign in to comment.