Skip to content

Commit

Permalink
Fix PHP 8.4 deprecation notice
Browse files Browse the repository at this point in the history
Implicit nullable types support will be removed
  • Loading branch information
martijngastkemper committed Jan 23, 2025
1 parent 99f6bf4 commit ad1bd30
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions functions/every.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
* Returns true if $callback returns true for every item in the collection.
*
* @param callable $fn
* @param array<mixed, mixed> $collection
* @param array<mixed, mixed>|null $collection
* @return ($collection is null ? callable : bool)
*/
function every(callable $fn, iterable $collection = null) {
function every(callable $fn, ?iterable $collection = null) {
return autocurry(
function ($fn, $collection): bool {
return reduce(
Expand Down
4 changes: 2 additions & 2 deletions functions/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
* Accepts more than arrays.
*
* @param callable $predicate
* @param iterable<mixed,mixed> $collection
* @param iterable<mixed,mixed>|null $collection
* @return ($collection is null ? callable : array<mixed,mixed>)
*/
function filter(callable $predicate, iterable $collection = null) {
function filter(callable $predicate, ?iterable $collection = null) {
return autocurry(
function ($predicate, $collection): iterable {
$collection = is_array($collection) ? $collection : iterator_to_array($collection);
Expand Down
4 changes: 2 additions & 2 deletions functions/find.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
* Filter a collection and get the first element.
*
* @param callable $predicate
* @param iterable<mixed, mixed> $collection
* @param iterable<mixed, mixed>|null $collection
* @return ($collection is null ? callable : mixed)
*/
function find(callable $predicate, iterable $collection = null) {
function find(callable $predicate, ?iterable $collection = null) {
return autocurry(
function ($predicate, $collection) {
return reduce(
Expand Down
4 changes: 2 additions & 2 deletions functions/find_index.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
* Filter a collection and get the index of the first match.
*
* @param callable $predicate
* @param iterable<mixed,mixed> $collection
* @param iterable<mixed,mixed>|null $collection
* @return ($collection is null ? callable : mixed)
*/
function find_index(callable $predicate, iterable $collection = null) {
function find_index(callable $predicate, ?iterable $collection = null) {
return autocurry(
function ($predicate, $collection) {
return reduce_assoc(
Expand Down
4 changes: 2 additions & 2 deletions functions/group_by.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
* Inspired by Clojure's group-by function.
*
* @param callable|string $indexFn
* @param iterable<mixed,mixed> $collection
* @param iterable<mixed,mixed>|null $collection
* @return ($collection is null ? callable : array)
*/
function group_by($indexFn, iterable $collection = null) {
function group_by($indexFn, ?iterable $collection = null) {
return autocurry(
function ($indexFn, $collection): array {
$indexFn = !is_callable($indexFn) ? prop($indexFn) : $indexFn;
Expand Down
4 changes: 2 additions & 2 deletions functions/index_by.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
* indexed by the given $indexFn.
*
* @param callable|string $indexFn
* @param array<mixed,mixed> $collection
* @param array<mixed,mixed>|null $collection
* @return ($collection is null ? callable : int)
* @see group_by
*/
function index_by($indexFn, iterable $collection = null) {
function index_by($indexFn, ?iterable $collection = null) {
return autocurry(
function ($indexFn, $collection): array {
$indexFn = !is_callable($indexFn) ? prop($indexFn) : $indexFn;
Expand Down
4 changes: 2 additions & 2 deletions functions/keys_where.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
* Returns the keys of a list, matching the given predicate.
*
* @param callable $predicate
* @param iterable<mixed,mixed> $collection
* @param iterable<mixed,mixed>|null $collection
* @return ($collection is null ? callable : array<int,mixed>)
*/
function keys_where(callable $predicate, iterable $collection = null) {
function keys_where(callable $predicate, ?iterable $collection = null) {
return autocurry(
function ($predicate, $collection) {
return reduce_assoc(
Expand Down
4 changes: 2 additions & 2 deletions functions/map.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
* Accepts more than arrays.
*
* @param callable $fn
* @param iterable<mixed,mixed> $collection
* @param iterable<mixed,mixed>|null $collection
* @return ($collection is null ? callable : array)
*/
function map(callable $fn, iterable $collection = null) {
function map(callable $fn, ?iterable $collection = null) {
return autocurry(
function ($fn, $collection): array {
$collection = $collection instanceof \Traversable ? iterator_to_array($collection) : $collection;
Expand Down
4 changes: 2 additions & 2 deletions functions/merge_after.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
* @param mixed $index Either the actual index (numeric or associative) or a predicate function.
* In case of a function the first item in $target the function returns true
* for will determine the index.
* @param array<mixed,mixed> $target The receiver of the spliced-in object.
* @param array<mixed,mixed>|null $target The receiver of the spliced-in object.
* @return ($target is null ? callable : array) A new array.
*/
function merge_after($object, $index, array $target = null) {
function merge_after($object, $index, ?array $target = null) {
return autocurry(
function ($object, $index, $target) {
$targetIsAssoc = is_assoc($target);
Expand Down
4 changes: 2 additions & 2 deletions functions/merge_at.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
* @param mixed $index Either the actual index (numeric or associative) or a predicate function.
* In case of a function the first item in $target the function returns true
* for will determine the index.
* @param array<mixed,mixed> $target The receiver of the spliced-in object.
* @param array<mixed,mixed>|null $target The receiver of the spliced-in object.
* @return ($target is null ? callable : array) A new array.
*/
function merge_at($object, $index, array $target = null) {
function merge_at($object, $index, ?array $target = null) {
return autocurry(
function ($object, $index, $target) {
$targetIsAssoc = is_assoc($target);
Expand Down
4 changes: 2 additions & 2 deletions functions/none.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
* Returns true if $callback returns false for every item in the collection.
*
* @param callable $fn
* @param iterable<mixed,mixed> $collection
* @param iterable<mixed,mixed>|null $collection
* @return ($collection is null ? callable : bool)
*/
function none($fn, iterable $collection = null) {
function none($fn, ?iterable $collection = null) {
return autocurry(
function ($fn, $collection) {
return reduce(
Expand Down
4 changes: 2 additions & 2 deletions functions/reduce.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
*
* @param callable $fn Reduction function
* @param mixed $default
* @param iterable<mixed,mixed> $collection
* @param iterable<mixed,mixed>|null $collection
* @return ($collection is null ? callable : mixed)
*/
function reduce(callable $fn, $default, iterable $collection = null) {
function reduce(callable $fn, $default, ?iterable $collection = null) {
$reduce = function ($fn, $acc, $collection) {
foreach ($collection as $item) {
$acc = $fn($acc, $item);
Expand Down
4 changes: 2 additions & 2 deletions functions/reduce_assoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
*
* @param callable $fn Reducation function
* @param mixed $default
* @param array<mixed,mixed> $collection
* @param array<mixed,mixed>|null $collection
* @return ($collection is null ? callable : mixed)
*/
function reduce_assoc(callable $fn, $default, iterable $collection = null) {
function reduce_assoc(callable $fn, $default, ?iterable $collection = null) {
return autocurry(
function ($fn, $default, $collection) {
return reduce(
Expand Down
2 changes: 1 addition & 1 deletion functions/reject.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @param mixed $collection
* @return ($collection is null ? callable : mixed)
*/
function reject(callable $predicate, iterable $collection = null) {
function reject(callable $predicate, ?iterable $collection = null) {
return autocurry(
function ($predicate, $collection) {
return filter(not($predicate), $collection);
Expand Down
4 changes: 2 additions & 2 deletions functions/rename_keys.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
* Rename keys in an array.
*
* @param array<mixed,mixed>|callable $transformMap
* @param array $collection
* @param array|null $collection
* @return ($collection is null ? callable : array)
*/
function rename_keys($transformMap, array $collection = null) {
function rename_keys($transformMap, ?array $collection = null) {
return autocurry(
function ($transformMap, $collection) {
if (!is_callable($transformMap) && !is_array($transformMap)) {
Expand Down
4 changes: 2 additions & 2 deletions functions/sort_by.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
* Inspired by Clojure's `sort-by`
*
* @param callable $fn
* @param array $collection
* @param array|null $collection
* @return ($collection is null ? callable : int)
*/
function sort_by(callable $fn, array $collection = null) {
function sort_by(callable $fn, ?array $collection = null) {
return autocurry(
function (callable $fn, array $collection): array {
return usort(
Expand Down
4 changes: 2 additions & 2 deletions functions/split.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
* Split a string.
*
* @param string $separator
* @param string $subject
* @param string|null $subject
* @return ($subject is null ? callable : array)
*/
function split(string $separator, string $subject = null) {
function split(string $separator, ?string $subject = null) {
return autocurry(
function ($separator, $subject): array {
return explode($separator, $subject);
Expand Down
4 changes: 2 additions & 2 deletions functions/usort.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
* Pure sort function. Returns a sorted copy.
*
* @param callable $fn
* @param array<mixed,mixed> $collection
* @param array<mixed,mixed>|null $collection
* @return ($collection is null ? callable : array)
*/
function usort(callable $fn, array $collection = null) {
function usort(callable $fn, ?array $collection = null) {
return autocurry(
function ($fn, array $collection): array {
// make a copy of the array as to not disturb the original
Expand Down
4 changes: 2 additions & 2 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -456,12 +456,12 @@ parameters:
path: tests/Helpers/MockSpiceTraverser.php

-
message: "#^Property Garp\\\\Functional\\\\Tests\\\\Helpers\\\\MockSpiceTraverser\\:\\:\\$_spices \\(array\\<int, string\\>\\) does not accept array\\<int, mixed\\>\\.$#"
message: "#^Property Garp\\\\Functional\\\\Tests\\\\Helpers\\\\MockSpiceTraverser\\:\\:\\$_spices \\(array\\<int, string\\>\\) does not accept array\\.$#"
count: 1
path: tests/Helpers/MockSpiceTraverser.php

-
message: "#^Property Garp\\\\Functional\\\\Tests\\\\Helpers\\\\MockSpiceTraverser\\:\\:\\$_spices \\(array\\<int, string\\>\\) does not accept array\\<int\\|string, mixed\\>\\.$#"
message: "#^Property Garp\\\\Functional\\\\Tests\\\\Helpers\\\\MockSpiceTraverser\\:\\:\\$_spices \\(array\\<int, string\\>\\) does not accept array\\<int, mixed\\>\\.$#"
count: 1
path: tests/Helpers/MockSpiceTraverser.php

Expand Down

0 comments on commit ad1bd30

Please sign in to comment.