Skip to content

Commit

Permalink
Fix phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvanassche committed Feb 9, 2024
1 parent 8550a10 commit b884e9a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 26 deletions.
6 changes: 5 additions & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,16 @@ parameters:
count: 1
path: src/Data.php


-
message: "#^PHPDoc tag @return with type Spatie\\\\LaravelData\\\\DataCollection\\<int, TValue\\> is not subtype of native type static\\(Spatie\\\\LaravelData\\\\DataCollection\\<TKey of \\(int\\|string\\), TValue\\>\\)\\.$#"
count: 1
path: src/DataCollection.php

-
message: "#^Consider using bind method instead or pass a closure\\.$#"
count: 2
path: src/LaravelDataServiceProvider.php

-
message: "#^Call to an undefined method Illuminate\\\\Contracts\\\\Pagination\\\\Paginator\\:\\:count\\(\\)\\.$#"
count: 1
Expand Down
52 changes: 27 additions & 25 deletions src/Concerns/EnumerableMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
/**
* @template TKey of array-key
* @template TValue
* @template TMapValue
*
* @implements \ArrayAccess<TKey, TValue>
*/
trait EnumerableMethods
{
/**
* @deprecated In v5, use a regular Laravel collection instead
* @template TMapValue
*
* @param callable(TValue, TKey): TMapValue $through
*
* @return static
* @deprecated In v5, use a regular Laravel collection instead
*/
public function through(callable $through): static
{
Expand All @@ -30,23 +30,25 @@ public function through(callable $through): static
}

/**
* @deprecated In v5, use a regular Laravel collection instead
* @template TMapValue
*
* @param callable(TValue, TKey): TMapValue $map
*
* @return static
* @deprecated In v5, use a regular Laravel collection instead
*
*/
public function map(callable $map): static
{
return $this->through(...func_get_args());
}

/**
* @deprecated In v5, use a regular Laravel collection instead
*
* @param callable(TValue): bool $filter
*
* @return static
* @deprecated In v5, use a regular Laravel collection instead
*
*/
public function filter(callable $filter): static
{
Expand All @@ -58,11 +60,11 @@ public function filter(callable $filter): static
}

/**
* @deprecated In v5, use a regular Laravel collection instead
*
* @param callable(TValue): bool $filter
*
* @return static
* @deprecated In v5, use a regular Laravel collection instead
*
*/
public function reject(callable $filter): static
{
Expand All @@ -74,41 +76,41 @@ public function reject(callable $filter): static
}

/**
* @param null| (callable(TValue,TKey): bool) $callback
* @param TFirstDefault|(\Closure(): TFirstDefault) $default
*
* @return TValue|TFirstDefault
* @deprecated In v5, use a regular Laravel collection instead
*
* @template TFirstDefault
*
* @param null| (callable(TValue,TKey): bool) $callback
* @param TFirstDefault|(\Closure(): TFirstDefault) $default
*
* @return TValue|TFirstDefault
*/
public function first(callable|null $callback = null, $default = null)
{
return $this->items->first(...func_get_args());
}

/**
* @param null| (callable(TValue,TKey): bool) $callback
* @param TLastDefault|(\Closure(): TLastDefault) $default
*
* @return TValue|TLastDefault
* @deprecated In v5, use a regular Laravel collection instead
*
* @template TLastDefault
*
* @param null| (callable(TValue,TKey): bool) $callback
* @param TLastDefault|(\Closure(): TLastDefault) $default
*
* @return TValue|TLastDefault
*/
public function last(callable|null $callback = null, $default = null)
{
return $this->items->last(...func_get_args());
}

/**
* @deprecated In v5, use a regular Laravel collection instead
*
* @param callable(TValue, TKey): mixed $callback
*
* @return static
* @deprecated In v5, use a regular Laravel collection instead
*
*/
public function each(callable $callback): static
{
Expand All @@ -118,9 +120,9 @@ public function each(callable $callback): static
}

/**
* @return static<int, TValue>
* @deprecated In v5, use a regular Laravel collection instead
*
* @return static<int, TValue>
*/
public function values(): static
{
Expand All @@ -144,32 +146,32 @@ public function where(string $key, mixed $operator = null, mixed $value = null):
}

/**
* @param callable(TReduceInitial|TReduceReturnType, TValue, TKey): TReduceReturnType $callback
* @param TReduceInitial $initial
*
* @return TReduceReturnType
* @deprecated In v5, use a regular Laravel collection instead
*
* @template TReduceInitial
* @template TReduceReturnType
*
* @param callable(TReduceInitial|TReduceReturnType, TValue, TKey): TReduceReturnType $callback
* @param TReduceInitial $initial
*
* @return TReduceReturnType
*/
public function reduce(callable $callback, mixed $initial = null)
{
return $this->items->reduce(...func_get_args());
}

/**
* @deprecated In v5, use a regular Laravel collection instead
*
* @param (callable(TValue, TKey): bool)|string|null $key
* @param (callable(TValue, TKey): bool)|string|null $key
* @param mixed $operator
* @param mixed $value
*
* @return TValue
*
* @throws \Illuminate\Support\ItemNotFoundException
* @throws \Illuminate\Support\MultipleItemsFoundException
* @deprecated In v5, use a regular Laravel collection instead
*
*/
public function sole(callable|string|null $key = null, mixed $operator = null, mixed $value = null)
{
Expand Down

0 comments on commit b884e9a

Please sign in to comment.