diff --git a/src/ArrayInterface.php b/src/ArrayInterface.php index 97c9967..00d319e 100644 --- a/src/ArrayInterface.php +++ b/src/ArrayInterface.php @@ -51,14 +51,14 @@ public function isEmpty(): bool; /** * Tests if all elements satisfy the given predicate. * - * @psalm-param pure-callable(TValue):bool $callback + * @psalm-param callable(TValue):bool $callback */ public function allSatisfy(callable $callback): bool; /** * Tests for the existence of an element that satisfies the given predicate. * - * @psalm-param pure-callable(TValue):bool $callback + * @psalm-param callable(TValue):bool $callback */ public function exists(callable $callback): bool; @@ -71,8 +71,8 @@ public function count(): int; /** * @template TReducedValue - * @param pure-callable(TReducedValue,TValue):TReducedValue $callback - * @param TReducedValue $initial + * @param callable(TReducedValue,TValue):TReducedValue $callback + * @param TReducedValue $initial * @return TReducedValue */ public function reduce(callable $callback, $initial); diff --git a/src/Array_.php b/src/Array_.php index f149b7c..bbc8e92 100644 --- a/src/Array_.php +++ b/src/Array_.php @@ -107,6 +107,10 @@ protected function valueComparator(): callable public function allSatisfy(callable $callback): bool { foreach ($this->data as $value) { + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ if (! $callback($value)) { return false; } @@ -118,6 +122,10 @@ public function allSatisfy(callable $callback): bool public function exists(callable $callback): bool { foreach ($this->data as $value) { + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ if ($callback($value)) { return true; } @@ -131,7 +139,11 @@ public function reduce(callable $callback, $initial) { $instance = clone $this; - /** @psalm-suppress MixedReturnStatement The return value of the callback ensures the return type. */ + /** + * @psalm-suppress MixedReturnStatement The return value of the callback ensures the return type. + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ return array_reduce($instance->data, $callback, $initial); } } diff --git a/src/Map.php b/src/Map.php index 2d69e5a..40bf90d 100644 --- a/src/Map.php +++ b/src/Map.php @@ -70,6 +70,10 @@ public function sort(?callable $callback = null): MapInterface return $instance; } + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ uasort($data, $callback); $instance->data = $data; @@ -84,10 +88,14 @@ public function diffKeys(MapInterface $other, ?callable $keyComparator = null): /** * @psalm-var array $diff1 + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. */ $diff1 = array_diff_ukey($instance->data, $otherData, $keyComparator); /** * @psalm-var array $diff2 + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. */ $diff2 = array_diff_ukey($otherData, $instance->data, $keyComparator); $merged = array_merge( @@ -101,7 +109,7 @@ public function diffKeys(MapInterface $other, ?callable $keyComparator = null): } /** - * @psalm-return pure-callable(TKey,TKey):int + * @psalm-return callable(TKey,TKey):int */ private function keyComparator(): callable { @@ -118,6 +126,10 @@ public function toOrderedList(?callable $sorter = null): OrderedListInterface $data = $this->data; + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ usort($data, $sorter); return new GenericOrderedList($data); @@ -128,6 +140,10 @@ public function filter(callable $callback): MapInterface $instance = clone $this; $filtered = []; foreach ($instance->data as $key => $value) { + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ if (! $callback($value, $key)) { continue; } @@ -179,8 +195,8 @@ public function intersect(MapInterface $other, ?callable $valueComparator = null /** * @psalm-param MapInterface $other - * @psalm-param (pure-callable(TValue,TValue):int)|null $valueComparator - * @psalm-param (pure-callable(TKey,TKey):int)|null $keyComparator + * @psalm-param (callable(TValue,TValue):int)|null $valueComparator + * @psalm-param (callable(TKey,TKey):int)|null $keyComparator * @psalm-return array * @phpcsSuppress SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedMethod */ @@ -189,6 +205,8 @@ private function intersection(MapInterface $other, ?callable $valueComparator, ? if ($valueComparator && $keyComparator) { /** * @psalm-var array $intersection + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. */ $intersection = array_uintersect_uassoc( $this->data, @@ -203,6 +221,8 @@ private function intersection(MapInterface $other, ?callable $valueComparator, ? if ($keyComparator) { /** * @psalm-var array $intersection + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. */ $intersection = array_intersect_ukey($this->data, $other->toNativeArray(), $keyComparator); @@ -215,6 +235,8 @@ private function intersection(MapInterface $other, ?callable $valueComparator, ? /** * @psalm-var array $intersection + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. */ $intersection = array_uintersect($this->data, $other->toNativeArray(), $valueComparator); @@ -252,6 +274,8 @@ public function diff(MapInterface $other, ?callable $valueComparator = null): Ma { /** * @psalm-var array $diff1 + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. */ $diff1 = array_udiff( $this->toNativeArray(), @@ -261,6 +285,8 @@ public function diff(MapInterface $other, ?callable $valueComparator = null): Ma /** * @psalm-var array $diff2 + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. */ $diff2 = array_udiff( $other->toNativeArray(), @@ -303,13 +329,17 @@ public function removeElement($element): MapInterface /** * @template TNewValue - * @psalm-param pure-callable(TValue,TKey):TNewValue $callback + * @psalm-param callable(TValue,TKey):TNewValue $callback * @psalm-return MapInterface */ public function map(callable $callback): MapInterface { $data = []; foreach ($this->data as $key => $value) { + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ $data[$key] = $callback($value, $key); } @@ -326,6 +356,10 @@ public function partition(callable $callback): array $filtered = $unfiltered = []; foreach ($this->data as $key => $element) { + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ if ($callback($element)) { $filtered[$key] = $element; continue; @@ -344,7 +378,7 @@ public function partition(callable $callback): array /** * @template TGroup of non-empty-string - * @psalm-param pure-callable(TValue):TGroup $callback + * @psalm-param callable(TValue):TGroup $callback * * @psalm-return MapInterface> */ @@ -356,6 +390,10 @@ public function group(callable $callback): MapInterface $groups = new GenericMap([]); foreach ($this->data as $key => $value) { + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ $groupIdentifier = $callback($value); try { $group = $groups->get($groupIdentifier); @@ -411,6 +449,10 @@ public function sortByKey(?callable $sorter = null): MapInterface $sorter = $sorter ?? $this->keyComparator(); $data = $this->data; $instance = clone $this; + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ uksort($data, $sorter); $instance->data = $data; @@ -429,7 +471,7 @@ public function join(string $separator = ''): string /** * @template TNewKey of string - * @param pure-callable(TKey,TValue):TNewKey $keyGenerator + * @param callable(TKey,TValue):TNewKey $keyGenerator * * @return MapInterface * @throws RuntimeException if a new key is being generated more than once. @@ -440,6 +482,10 @@ public function keyExchange(callable $keyGenerator): MapInterface $exchanged = new GenericMap(); foreach ($this->data as $key => $value) { + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ $newKey = $keyGenerator($key, $value); if ($exchanged->has($newKey)) { throw new RuntimeException(sprintf( diff --git a/src/MapInterface.php b/src/MapInterface.php index 20a1ec7..321cca7 100644 --- a/src/MapInterface.php +++ b/src/MapInterface.php @@ -20,7 +20,7 @@ interface MapInterface extends ArrayInterface, JsonSerializable * Filters out all values not matched by the callback. * This method is the equivalent of `array_filter`. * - * @psalm-param pure-callable(TValue,TKey):bool $callback + * @psalm-param callable(TValue,TKey):bool $callback * @psalm-return MapInterface */ public function filter(callable $callback): MapInterface; @@ -29,7 +29,7 @@ public function filter(callable $callback): MapInterface; * Sorts the items by using either the given callback or the native `SORT_NATURAL` logic of PHP. * This method is the equivalent of `sort`/`usort`. * - * @psalm-param (pure-callable(TValue,TValue):int)|null $callback + * @psalm-param (callable(TValue,TValue):int)|null $callback * @psalm-return MapInterface */ public function sort(?callable $callback = null): MapInterface; @@ -51,7 +51,7 @@ public function merge(MapInterface ...$stack): MapInterface; * This method is the equivalent of `array_diff`. * * @psalm-param MapInterface $other - * @psalm-param (pure-callable(TKey,TKey):int)|null $keyComparator + * @psalm-param (callable(TKey,TKey):int)|null $keyComparator * @psalm-return MapInterface */ public function diffKeys(MapInterface $other, ?callable $keyComparator = null): MapInterface; @@ -61,7 +61,7 @@ public function diffKeys(MapInterface $other, ?callable $keyComparator = null): * This method is the equivalent of `array_map`. * * @template TNewValue - * @psalm-param pure-callable(TValue,TKey):TNewValue $callback + * @psalm-param callable(TValue,TKey):TNewValue $callback * @psalm-return MapInterface */ public function map(callable $callback): MapInterface; @@ -74,7 +74,7 @@ public function map(callable $callback): MapInterface; * This method is the equivalent of `array_intersect`. * * @psalm-param MapInterface $other - * @psalm-param (pure-callable(TValue,TValue):int)|null $valueComparator + * @psalm-param (callable(TValue,TValue):int)|null $valueComparator * @psalm-return MapInterface */ public function intersect(MapInterface $other, ?callable $valueComparator = null): MapInterface; @@ -87,7 +87,7 @@ public function intersect(MapInterface $other, ?callable $valueComparator = null * This method is the equivalent of `array_diff`. * * @psalm-param MapInterface $other - * @psalm-param (pure-callable(TValue,TValue):int)|null $valueComparator + * @psalm-param (callable(TValue,TValue):int)|null $valueComparator * @psalm-return MapInterface */ public function diff(MapInterface $other, ?callable $valueComparator = null): MapInterface; @@ -97,7 +97,7 @@ public function diff(MapInterface $other, ?callable $valueComparator = null): Ma * The items are being sorted by using the provided sorter. In case there is no sorter provided, the values * are just passed in the order they werestored in this map. * - * @psalm-param (pure-callable(TValue,TValue):int)|null $sorter + * @psalm-param (callable(TValue,TValue):int)|null $sorter * @psalm-return OrderedListInterface */ public function toOrderedList(?callable $sorter = null): OrderedListInterface; @@ -163,7 +163,7 @@ public function get(string $key); * * @psalm-param MapInterface $other * @psalm-return MapInterface - * @psalm-param (pure-callable(TValue,TValue):int)|null $valueComparator + * @psalm-param (callable(TValue,TValue):int)|null $valueComparator */ public function intersectAssoc(MapInterface $other, ?callable $valueComparator = null): MapInterface; @@ -174,7 +174,7 @@ public function intersectAssoc(MapInterface $other, ?callable $valueComparator = * * @psalm-param MapInterface $other * @psalm-return MapInterface - * @psalm-param (pure-callable(TKey,TKey):int)|null $keyComparator + * @psalm-param (callable(TKey,TKey):int)|null $keyComparator */ public function intersectUsingKeys(MapInterface $other, ?callable $keyComparator = null): MapInterface; @@ -186,8 +186,8 @@ public function intersectUsingKeys(MapInterface $other, ?callable $keyComparator * This method is the equivalent of `array_intersect_assoc`/`array_intersect_uassoc`/`array_intersect_key`/`array_intersect_ukey`. * * @psalm-param MapInterface $other - * @psalm-param (pure-callable(TValue,TValue):int)|null $valueComparator - * @psalm-param (pure-callable(TKey,TKey):int)|null $keyComparator + * @psalm-param (callable(TValue,TValue):int)|null $valueComparator + * @psalm-param (callable(TKey,TKey):int)|null $keyComparator * @psalm-return MapInterface */ public function intersectUserAssoc( @@ -207,7 +207,7 @@ public function has(string $key): bool; /** * Partitions the current map into those items which are filtered by the callback and those which don't. * - * @psalm-param pure-callable(TValue):bool $callback + * @psalm-param callable(TValue):bool $callback * @psalm-return array{0:MapInterface,1:MapInterface} */ public function partition(callable $callback): array; @@ -216,7 +216,7 @@ public function partition(callable $callback): array; * Groups the items of this object by using the callback. * * @template TGroup of non-empty-string - * @psalm-param pure-callable(TValue):TGroup $callback + * @psalm-param callable(TValue):TGroup $callback * * @psalm-return MapInterface> */ @@ -235,7 +235,7 @@ public function slice(int $length): MapInterface; * After the method has been executed properly, an `MappedErrorCollection` is being thrown so one can * see what item key actually failed executing the callback. * - * @param pure-callable(TValue,TKey):void $callback + * @param callable(TValue,TKey):void $callback * @throws MappedErrorCollection If an error occured during execution. */ public function forAll(callable $callback): ForAllPromiseInterface; @@ -243,7 +243,7 @@ public function forAll(callable $callback): ForAllPromiseInterface; /** * Sorts the map by sorting its keys. * - * @param (pure-callable(TKey,TKey):int)|null $sorter + * @param (callable(TKey,TKey):int)|null $sorter * * @psalm-return MapInterface */ @@ -261,7 +261,7 @@ public function join(string $separator = ''): string; * Creates a new map where the keys of items might have been exchanged with another key. * * @template TNewKey of string - * @param pure-callable(TKey,TValue):TNewKey $keyGenerator + * @param callable(TKey,TValue):TNewKey $keyGenerator * * @return MapInterface * @throws RuntimeException if a new key is being generated more than once. diff --git a/src/OrderedList.php b/src/OrderedList.php index 86565e6..b6775ce 100644 --- a/src/OrderedList.php +++ b/src/OrderedList.php @@ -63,6 +63,10 @@ public function map(callable $callback): OrderedListInterface $data = []; foreach ($this->data as $index => $value) { assert($index >= 0); + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ $data[] = $callback($value, $index); } @@ -97,6 +101,10 @@ public function sort(?callable $callback = null): OrderedListInterface return $instance; } + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ usort($data, $callback); $instance->data = $data; @@ -109,12 +117,20 @@ public function diff(OrderedListInterface $other, ?callable $valueComparator = n $valueComparator = $valueComparator ?? $this->valueComparator(); + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ $diff1 = array_udiff( $instance->toNativeArray(), $other->toNativeArray(), $valueComparator ); + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ $diff2 = array_udiff( $other->toNativeArray(), $instance->toNativeArray(), @@ -131,7 +147,11 @@ public function diff(OrderedListInterface $other, ?callable $valueComparator = n public function intersect(OrderedListInterface $other, ?callable $valueComparator = null): OrderedListInterface { - $instance = clone $this; + $instance = clone $this; + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ $instance->data = array_values(array_uintersect( $instance->data, $other->toNativeArray(), @@ -147,6 +167,10 @@ public function toMap(callable $keyGenerator): MapInterface $mapped = []; foreach ($instance->data as $index => $value) { assert($index >= 0); + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ $key = $keyGenerator($value, $index); $mapped[$key] = $value; } @@ -175,6 +199,10 @@ public function filter(callable $callback): OrderedListInterface $instance = clone $this; $filtered = []; foreach ($instance->data as $index => $value) { + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ if (! $callback($value, $index)) { continue; } @@ -206,11 +234,19 @@ public function unify( $unified = new GenericMap([]); foreach ($instance->data as $value) { + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ $identifier = $unificationIdentifierGenerator($value); try { $unique = $unified->get($identifier); if ($callback) { + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ $unique = $callback($unique, $value); } } catch (OutOfBoundsException $exception) { @@ -248,24 +284,32 @@ public function fill(int $startIndex, int $amount, $value): OrderedListInterface } /** - * @psalm-param TValue|pure-callable(int):TValue $value + * @psalm-param TValue|callable(int):TValue $value * @psalm-return array */ private function createListFilledWithValues(int $start, int $amount, $value): array { $filled = []; - /** @var pure-callable(int):TValue $callable */ + /** @var callable(int):TValue $callable */ $callable = $value; + /** + * @psalm-suppress ImpureFunctionCall I was not aware that `is_callable` is impure... + */ if (! is_callable($callable)) { /** - * @var pure-callable(int):TValue $callable + * @var callable(int):TValue $callable * @psalm-suppress MissingClosureReturnType We have to assume that the value contains the fill value. + * @return TValue */ $callable = static fn () => $value; } for ($index = $start; $index < $amount; $index++) { + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ $filled[$index] = $callable($index); } @@ -288,6 +332,10 @@ public function limit(int $length): OrderedListInterface public function find(callable $callback) { foreach ($this->data as $value) { + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ if ($callback($value)) { return $value; } @@ -301,6 +349,10 @@ public function partition(callable $callback): array $filtered = $unfiltered = []; foreach ($this->data as $element) { + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ if ($callback($element)) { $filtered[] = $element; continue; @@ -319,7 +371,7 @@ public function partition(callable $callback): array /** * @template TGroup of non-empty-string - * @psalm-param pure-callable(TValue):TGroup $callback + * @psalm-param callable(TValue):TGroup $callback * * @psalm-return MapInterface> */ @@ -328,6 +380,10 @@ public function group(callable $callback): MapInterface /** @var MapInterface> $groups */ $groups = new GenericMap([]); foreach ($this as $value) { + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ $groupName = $callback($value); if (! $groups->has($groupName)) { $groups = $groups->put($groupName, new GenericOrderedList([$value])); @@ -402,6 +458,10 @@ public function findFirstMatchingIndex(callable $filter): ?int { foreach ($this->data as $index => $value) { assert($index >= 0); + /** + * @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the + * value here. + */ if ($filter($value)) { return $index; } diff --git a/src/OrderedListInterface.php b/src/OrderedListInterface.php index 45290ac..0dca3b5 100644 --- a/src/OrderedListInterface.php +++ b/src/OrderedListInterface.php @@ -36,7 +36,7 @@ public function at(int $position); * Filters out all values not matched by the callback. * This method is the equivalent of `array_filter`. * - * @psalm-param pure-callable(TValue,int):bool $callback + * @psalm-param callable(TValue,int):bool $callback * @psalm-return OrderedListInterface */ public function filter(callable $callback): OrderedListInterface; @@ -45,7 +45,7 @@ public function filter(callable $callback): OrderedListInterface; * Sorts the items by using either the given callback or the native `SORT_NATURAL` logic of PHP. * This method is the equivalent of `sort`/`usort`. * - * @psalm-param (pure-callable(TValue,TValue):int)|null $callback + * @psalm-param (callable(TValue,TValue):int)|null $callback * @psalm-return OrderedListInterface */ public function sort(?callable $callback = null): OrderedListInterface; @@ -65,7 +65,7 @@ public function merge(OrderedListInterface ...$stack): OrderedListInterface; * This method is the equivalent of `array_map`. * * @template TNewValue - * @psalm-param pure-callable(TValue,0|positive-int):TNewValue $callback + * @psalm-param callable(TValue,0|positive-int):TNewValue $callback * @psalm-return OrderedListInterface */ public function map(callable $callback): OrderedListInterface; @@ -78,7 +78,7 @@ public function map(callable $callback): OrderedListInterface; * This method is the equivalent of `array_intersect`. * * @psalm-param OrderedListInterface $other - * @psalm-param (pure-callable(TValue,TValue):int)|null $valueComparator + * @psalm-param (callable(TValue,TValue):int)|null $valueComparator * @psalm-return OrderedListInterface */ public function intersect(OrderedListInterface $other, ?callable $valueComparator = null): OrderedListInterface; @@ -91,7 +91,7 @@ public function intersect(OrderedListInterface $other, ?callable $valueComparato * This method is the equivalent of `array_diff`. * * @psalm-param OrderedListInterface $other - * @psalm-param (pure-callable(TValue,TValue):int)|null $valueComparator + * @psalm-param (callable(TValue,TValue):int)|null $valueComparator * @psalm-return OrderedListInterface */ public function diff(OrderedListInterface $other, ?callable $valueComparator = null): OrderedListInterface; @@ -100,7 +100,7 @@ public function diff(OrderedListInterface $other, ?callable $valueComparator = n * Creates a map of this ordered list by using the provided key generator to generate dedicated keys for each item. * * @template TKeyForMap of non-empty-string - * @psalm-param pure-callable(TValue,0|positive-int):TKeyForMap $keyGenerator + * @psalm-param callable(TValue,0|positive-int):TKeyForMap $keyGenerator * @psalm-return MapInterface */ public function toMap(callable $keyGenerator): MapInterface; @@ -120,8 +120,8 @@ public function removeElement($element): OrderedListInterface; * of a value. If not, a simple hashing strategy is being applied to identify identical values from this list. * In case a callback is provided, all duplications are being passed to that callback so one keep track of these. * - * @psalm-param (pure-callable(TValue):non-empty-string)|null $unificationIdentifierGenerator - * @psalm-param (pure-callable(TValue,TValue):TValue)|null $callback This callback is called for duplications only. + * @psalm-param (callable(TValue):non-empty-string)|null $unificationIdentifierGenerator + * @psalm-param (callable(TValue,TValue):TValue)|null $callback This callback is called for duplications only. * @psalm-return OrderedListInterface */ public function unify( @@ -137,7 +137,7 @@ public function unify( * * @throws InvalidArgumentException if start index does is not fitting in the current list state. * - * @psalm-param TValue|pure-callable(int):TValue $value + * @psalm-param TValue|callable(int):TValue $value * @psalm-return OrderedListInterface */ public function fill(int $startIndex, int $amount, $value): OrderedListInterface; @@ -164,7 +164,7 @@ public function limit(int $length): OrderedListInterface; * returning that match. * In case there are multiple elements matching the callback, only the first item will be returned. * - * @psalm-param pure-callable(TValue):bool $callback + * @psalm-param callable(TValue):bool $callback * @psalm-return TValue * @throws OutOfBoundsException if value could not be found with provided callback. */ @@ -173,7 +173,7 @@ public function find(callable $callback); /** * Partitions the current list into those items which are filtered by the callback and those which don't. * - * @param pure-callable(TValue $value):bool $callback + * @param callable(TValue $value):bool $callback * * @psalm-return array{0:OrderedListInterface,1:OrderedListInterface} */ @@ -183,7 +183,7 @@ public function partition(callable $callback): array; * Groups the items by using the callback. * * @template TGroup of non-empty-string - * @psalm-param pure-callable(TValue):TGroup $callback + * @psalm-param callable(TValue):TGroup $callback * * @psalm-return MapInterface> */ @@ -243,7 +243,7 @@ public function jsonSerialize(): array; * being returned and the iteration stops. * If no item matches the filter, `null` is being returned. * - * @param pure-callable(TValue):bool $filter + * @param callable(TValue):bool $filter * * @return 0|positive-int|null */ diff --git a/tests/GenericMapTest.php b/tests/GenericMapTest.php index c0e6969..01e8e2c 100644 --- a/tests/GenericMapTest.php +++ b/tests/GenericMapTest.php @@ -934,7 +934,6 @@ public function testWillGenerateErrorCollectionWhileExecutingForAll(): void $errorCollection = null; try { - /** @psalm-suppress InvalidArgument We do want to pass an impure method here for testing purposes */ $map->forAll($callable)->execute(); } catch (MappedErrorCollection $errorCollection) { } @@ -965,7 +964,6 @@ public function testWillGenerateErrorCollectionWhileExecutingForAllButStopsExecu $errorCollection = null; try { - /** @psalm-suppress InvalidArgument We do want to pass an impure method here for testing purposes */ $map->forAll($callable)->stopOnError()->execute(); } catch (MappedErrorCollection $errorCollection) { } diff --git a/tests/GenericOrderedListTest.php b/tests/GenericOrderedListTest.php index a110b0c..ab004e6 100644 --- a/tests/GenericOrderedListTest.php +++ b/tests/GenericOrderedListTest.php @@ -564,7 +564,6 @@ public function testCallbackOnDeduplicationIsOnlyCalledForDuplicates(): void /** * @psalm-suppress UnusedMethodCall - * @psalm-suppress InvalidArgument We do explicitly pass impure callable here to track usages */ $list->unify(null, static function (int $duplicate, int $number) use (&$callbackCalled): int { self::assertEquals($duplicate, $number);