Skip to content

Commit

Permalink
Bugfix/Wrong constructor typehint. (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
othercodes authored Jan 3, 2024
1 parent f166d00 commit 17ed6ae
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/FilterGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*
* @author Unay Santisteban <usantisteban@othercode.io>
* @package ComplexHeart\Domain\Criteria
*
* @extends TypedCollection<int, Filter>
*/
final class FilterGroup extends TypedCollection
{
Expand All @@ -23,23 +25,27 @@ final class FilterGroup extends TypedCollection
/**
* FilterGroup constructor.
*
* @param array<Filter> $items
* @param array<int, Filter> $items
*/
public function __construct(array $items = [])
{
parent::__construct(array_unique($items));
}

public static function create(Filter ...$filters): self
/**
* @param Filter ...$filters
* @return FilterGroup
*/
public static function create(Filter ...$filters): FilterGroup
{
return new self($filters);
return new self(array_values($filters));
}

/**
* @param array<string, scalar>|array<int, array<int, string>> $filters
* @return self
* @param array<int, array<int|string, mixed>> $filters
* @return FilterGroup
*/
public static function createFromArray(array $filters): self
public static function createFromArray(array $filters): FilterGroup
{
return self::create(
...map(fn(array $filter): Filter => Filter::createFromArray($filter), $filters)
Expand Down

0 comments on commit 17ed6ae

Please # to comment.