Skip to content

Commit

Permalink
Optimized assignment and condition #11795
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Opitz committed May 10, 2018
1 parent 6b17679 commit 3a87631
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/Database/Statement/BufferedStatement.php
Expand Up @@ -112,11 +112,9 @@ public function fetch($type = parent::FETCH_TYPE_NUM)
*/
public function fetchAssoc()
{
if ($result = $this->fetch(static::FETCH_TYPE_ASSOC)) {
return $result;
}
$result = $this->fetch(static::FETCH_TYPE_ASSOC);

return [];
return $result ? $result : [];
}

/**
Expand Down
6 changes: 2 additions & 4 deletions src/Database/Statement/StatementDecorator.php
Expand Up @@ -226,11 +226,9 @@ public function fetch($type = self::FETCH_TYPE_NUM)
*/
public function fetchAssoc()
{
if ($result = $this->fetch(static::FETCH_TYPE_ASSOC)) {
return $result;
}
$result = $this->fetch(static::FETCH_TYPE_ASSOC);

return [];
return $result ? $result : [];
}

/**
Expand Down

0 comments on commit 3a87631

Please sign in to comment.