Skip to content

Commit

Permalink
Made Server::getMessages() api more consistent by making it allways r…
Browse files Browse the repository at this point in the history
…eturn an array.
  • Loading branch information
Lumbendil committed Sep 18, 2012
1 parent 812e4eb commit fe83d77
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/Fetch/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,6 @@ public function getMessages($limit = null)
if(isset($limit) && is_numeric($limit) && $limit < $numMessages)
$numMessages = $limit;

if($numMessages < 1)
return false;

$stream = $this->getImapStream();
$messages = array();
for($i = 1; $i <= $numMessages; $i++)
Expand Down

3 comments on commit fe83d77

@tedivm
Copy link

@tedivm tedivm commented on fe83d77 Oct 4, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of removing those lines we should just return an empty array directly, rather than continuing those other calls against nothing.

@Lumbendil
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do it. I just took the simpler option. It added close to no overhead, since it just got something already calculated, initializated an array, and then skipped the loop, but I'll change it to return an array.

@Lumbendil
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tedivm I had forgotten about this PR. I've updated the branch in order to make it mergeable.

Please sign in to comment.