Skip to content

Commit

Permalink
refactor: Update return types.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Oct 7, 2020
1 parent f1aae0d commit 25cc915
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
14 changes: 7 additions & 7 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ public function duplicate(): CollectionInterface
return $this->run(Duplicate::of());
}

public static function empty(): Collection
public static function empty(): CollectionInterface
{
return new self();
}
Expand Down Expand Up @@ -438,7 +438,7 @@ public function frequency(): CollectionInterface
return $this->run(Frequency::of());
}

public static function fromCallable(callable $callable, ...$parameters): Collection
public static function fromCallable(callable $callable, ...$parameters): CollectionInterface
{
return new self(
static function (callable $callable, array $parameters): Generator {
Expand All @@ -449,7 +449,7 @@ static function (callable $callable, array $parameters): Generator {
);
}

public static function fromFile(string $filepath): Collection
public static function fromFile(string $filepath): CollectionInterface
{
return new self(
static function (string $filepath): Generator {
Expand All @@ -459,7 +459,7 @@ static function (string $filepath): Generator {
);
}

public static function fromIterable(iterable $iterable): Collection
public static function fromIterable(iterable $iterable): CollectionInterface
{
return new self(
static function (iterable $iterable): Generator {
Expand All @@ -469,7 +469,7 @@ static function (iterable $iterable): Generator {
);
}

public static function fromResource($resource): Collection
public static function fromResource($resource): CollectionInterface
{
return new self(
/**
Expand All @@ -484,7 +484,7 @@ static function ($resource): Generator {
);
}

public static function fromString(string $string, string $delimiter = ''): Collection
public static function fromString(string $string, string $delimiter = ''): CollectionInterface
{
return new self(
/**
Expand Down Expand Up @@ -843,7 +843,7 @@ public function window(int $size): CollectionInterface
return $this->run(Window::of()($size));
}

public static function with($data = [], ...$parameters): Collection
public static function with($data = [], ...$parameters): CollectionInterface
{
return new self($data, ...$parameters);
}
Expand Down
29 changes: 17 additions & 12 deletions src/Contract/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,9 @@ interface Collection extends
* @psalm-template NewTKey of array-key
* @psalm-template NewT
*
* @psalm-return \loophp\collection\Collection<NewTKey, NewT>
* @psalm-return \loophp\collection\Contract\Collection<NewTKey, NewT>
*/
public static function empty(): \loophp\collection\Collection;
public static function empty(): Collection;

/**
* @psalm-template NewTKey
Expand All @@ -321,9 +321,14 @@ public static function empty(): \loophp\collection\Collection;
*
* @param mixed ...$parameters
*
* @psalm-return \loophp\collection\Collection<NewTKey, NewT>
* @psalm-return \loophp\collection\Contract\Collection<NewTKey, NewT>
*/
public static function fromCallable(callable $callable, ...$parameters): \loophp\collection\Collection;
public static function fromCallable(callable $callable, ...$parameters): Collection;

/**
* @psalm-return \loophp\collection\Contract\Collection<int, string>
*/
public static function fromFile(string $filepath): Collection;

/**
* @psalm-template NewTKey
Expand All @@ -333,21 +338,21 @@ public static function fromCallable(callable $callable, ...$parameters): \loophp
* @param iterable<mixed> $iterable
* @psalm-param iterable<NewTKey, NewT> $iterable
*
* @psalm-return \loophp\collection\Collection<NewTKey, NewT>
* @psalm-return \loophp\collection\Contract\Collection<NewTKey, NewT>
*/
public static function fromIterable(iterable $iterable): \loophp\collection\Collection;
public static function fromIterable(iterable $iterable): Collection;

/**
* @param resource $resource
*
* @psalm-return \loophp\collection\Collection<int, string>
* @psalm-return \loophp\collection\Contract\Collection<int, string>
*/
public static function fromResource($resource): \loophp\collection\Collection;
public static function fromResource($resource): Collection;

/**
* @psalm-return \loophp\collection\Collection<int, string>
* @psalm-return \loophp\collection\Contract\Collection<int, string>
*/
public static function fromString(string $string, string $delimiter = ''): \loophp\collection\Collection;
public static function fromString(string $string, string $delimiter = ''): Collection;

/**
* @psalm-return \loophp\collection\Iterator\ClosureIterator<TKey, T>
Expand All @@ -364,7 +369,7 @@ public function getIterator(): ClosureIterator;
* @param mixed $data
* @param mixed ...$parameters
*
* @psalm-return \loophp\collection\Collection<NewTKey, NewT>
* @psalm-return \loophp\collection\Contract\Collection<NewTKey, NewT>
*/
public static function with($data = [], ...$parameters): \loophp\collection\Collection;
public static function with($data = [], ...$parameters): Collection;
}

0 comments on commit 25cc915

Please sign in to comment.