Skip to content

Commit

Permalink
Return 0 if strcmp return 0
Browse files Browse the repository at this point in the history
  • Loading branch information
jjsaunier committed May 3, 2014
1 parent ec48913 commit 9a400f5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Symfony/Component/Finder/Iterator/SortableIterator.php
Expand Up @@ -43,7 +43,13 @@ public function __construct(\Traversable $iterator, $sort)
$this->sort = function ($a, $b) {

//strcmp returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.
return strcmp($a->getRealpath(), $b->getRealpath()) < 0 ? -1 : 1;
$result = strcmp($a->getRealpath(), $b->getRealpath());

if ($result == 0) {

This comment has been minimized.

Copy link
@hhamon

hhamon May 3, 2014

if (0 === $result)

return 0;
}

return $result < 0 ? -1 : 1;
};
} elseif (self::SORT_BY_TYPE === $sort) {
$this->sort = function ($a, $b) {
Expand All @@ -54,7 +60,13 @@ public function __construct(\Traversable $iterator, $sort)
}

//strcmp returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.
return strcmp($a->getRealpath(), $b->getRealpath()) < 0 ? -1 : 1;
$result = strcmp($a->getRealpath(), $b->getRealpath()) < 0 ? -1 : 1;

if ($result == 0) {

This comment has been minimized.

Copy link
@hhamon

hhamon May 3, 2014

Same here.

return 0;
}

return $result < 0 ? -1 : 1;
};
} elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
$this->sort = function ($a, $b) {
Expand Down

0 comments on commit 9a400f5

Please sign in to comment.