Skip to content

Commit

Permalink
Remove duplicate type.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jun 20, 2020
1 parent 6e981db commit de7d49c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Contract/Transformation/Transformable.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface Transformable
/**
* @param \loophp\collection\Contract\Transformation ...$transformers
*
* @return array<mixed>|bool|bool|int|\loophp\collection\Iterator\ClosureIterator|mixed|string
* @return array<mixed>|bool|int|\loophp\collection\Iterator\ClosureIterator|mixed|string
*/
public function transform(Transformation ...$transformers);
}
14 changes: 11 additions & 3 deletions src/Operation/Sort.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ final class Sort extends AbstractOperation implements Operation
{
public function __construct(?callable $callback = null)
{
$this->storage['callback'] = $callback ?? static function ($left, $right): int {
return $left <=> $right;
};
$this->storage['callback'] = $callback ?? Closure::fromCallable([$this, 'compare']);
}

/**
Expand All @@ -27,4 +25,14 @@ public function __invoke(): Closure
yield from new SortableIterableIterator($collection, $callback);
};
}

/**
* @param mixed $left
* @param mixed $right
*
* @return int
*/
private function compare($left, $right): int {
return $left <=> $right;
}
}

0 comments on commit de7d49c

Please sign in to comment.