Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Reduce.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function toValue(iterable $data, callable $reducer, $initialValue
*
* @return mixed|null
*/
public static function toMin(iterable $data, callable $compareBy = null)
public static function toMin(iterable $data, ?callable $compareBy = null)
{
if ($compareBy !== null) {
return static::toValue(
Expand All @@ -71,7 +71,7 @@ public static function toMin(iterable $data, callable $compareBy = null)
*
* @return mixed|null
*/
public static function toMax(iterable $data, callable $compareBy = null)
public static function toMax(iterable $data, ?callable $compareBy = null)
{
if ($compareBy !== null) {
return static::toValue(
Expand Down Expand Up @@ -99,7 +99,7 @@ public static function toMax(iterable $data, callable $compareBy = null)
*
* @return array{numeric, numeric}|array{null, null}
*/
public static function toMinMax(iterable $numbers, callable $compareBy = null): array
public static function toMinMax(iterable $numbers, ?callable $compareBy = null): array
{
if ($compareBy !== null) {
return static::toValue($numbers, static function (array $carry, $datum) use ($compareBy) {
Expand Down
8 changes: 4 additions & 4 deletions src/Single.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static function filter(iterable $data, callable $predicate): \Generator
*
* @return \Generator<mixed>
*/
public static function filterFalse(iterable $data, callable $predicate = null): \Generator
public static function filterFalse(iterable $data, ?callable $predicate = null): \Generator
{
if ($predicate === null) {
$predicate = fn($datum): bool => \boolval($datum);
Expand All @@ -173,7 +173,7 @@ public static function filterFalse(iterable $data, callable $predicate = null):
*
* @return \Generator<mixed>
*/
public static function filterTrue(iterable $data, callable $predicate = null): \Generator
public static function filterTrue(iterable $data, ?callable $predicate = null): \Generator
{
if ($predicate === null) {
$predicate = fn($datum): bool => \boolval($datum);
Expand Down Expand Up @@ -244,7 +244,7 @@ public static function flatten(iterable $data, int $dimensions = 1): \Generator
public static function groupBy(
iterable $data,
callable $groupKeyFunction,
callable $itemKeyFunction = null
?callable $itemKeyFunction = null
): \Generator {
$itemKeyFunction ??= fn ($x) => null;
$groups = [];
Expand Down Expand Up @@ -473,7 +473,7 @@ public static function reverse(iterable $data): \Generator
*
* @return \Generator<T>
*/
public static function slice(iterable $data, int $start = 0, int $count = null, int $step = 1): \Generator
public static function slice(iterable $data, int $start = 0, ?int $count = null, int $step = 1): \Generator
{
if ($start < 0) {
throw new \InvalidArgumentException("Parameter 'start' cannot be negative");
Expand Down
4 changes: 2 additions & 2 deletions src/Sort.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Sort
*
* @return \Generator
*/
public static function asort(iterable $data, callable $comparator = null): \Generator
public static function asort(iterable $data, ?callable $comparator = null): \Generator
{
$array = \iterator_to_array(Transform::toIterator($data), true);

Expand All @@ -41,7 +41,7 @@ public static function asort(iterable $data, callable $comparator = null): \Gene
*
* @return \Generator
*/
public static function sort(iterable $data, callable $comparator = null): \Generator
public static function sort(iterable $data, ?callable $comparator = null): \Generator
{
$array = \iterator_to_array(Transform::toIterator($data));

Expand Down
28 changes: 14 additions & 14 deletions src/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public function filter(callable $predicate): self
*
* @see Single::filterTrue()
*/
public function filterTrue(callable $predicate = null): self
public function filterTrue(?callable $predicate = null): self
{
$this->iterable = Single::filterTrue($this->iterable, $predicate);
return $this;
Expand All @@ -309,7 +309,7 @@ public function filterTrue(callable $predicate = null): self
*
* @see Single::filterFalse()
*/
public function filterFalse(callable $predicate = null): self
public function filterFalse(?callable $predicate = null): self
{
$this->iterable = Single::filterFalse($this->iterable, $predicate);
return $this;
Expand Down Expand Up @@ -344,7 +344,7 @@ public function filterKeys(callable $predicate): self
*
* @see Single::groupBy()
*/
public function groupBy(callable $groupKeyFunction, callable $itemKeyFunction = null): self
public function groupBy(callable $groupKeyFunction, ?callable $itemKeyFunction = null): self
{
$this->iterable = Single::groupBy($this->iterable, $groupKeyFunction, $itemKeyFunction);
return $this;
Expand Down Expand Up @@ -475,7 +475,7 @@ public function flatten(int $dimensions = 1): self
*
* @see Single::slice()
*/
public function slice(int $start = 0, int $count = null, int $step = 1): self
public function slice(int $start = 0, ?int $count = null, int $step = 1): self
{
$this->iterable = Single::slice($this->iterable, $start, $count, $step);
return $this;
Expand Down Expand Up @@ -536,7 +536,7 @@ public function relativeFrequencies(bool $strict = true): self
*
* @see Single::sort()
*/
public function sort(callable $comparator = null): self
public function sort(?callable $comparator = null): self
{
$this->iterable = Sort::sort($this->iterable, $comparator);
return $this;
Expand All @@ -553,7 +553,7 @@ public function sort(callable $comparator = null): self
*
* @see Single::asort()
*/
public function asort(callable $comparator = null): self
public function asort(?callable $comparator = null): self
{
$this->iterable = Sort::asort($this->iterable, $comparator);
return $this;
Expand Down Expand Up @@ -1074,7 +1074,7 @@ public function toArray(): array
*
* @see Transform::toAssociativeArray()
*/
public function toAssociativeArray(callable $keyFunc = null, callable $valueFunc = null): array
public function toAssociativeArray(?callable $keyFunc = null, ?callable $valueFunc = null): array
{
return Transform::toAssociativeArray($this->iterable, $keyFunc, $valueFunc);
}
Expand Down Expand Up @@ -1112,7 +1112,7 @@ public function tee(int $count): array
*
* @return void
*/
public function toFile($fileResource, string $newlineSeparator = \PHP_EOL, string $header = null, string $footer = null): void
public function toFile($fileResource, string $newlineSeparator = \PHP_EOL, ?string $header = null, ?string $footer = null): void
{
ResourcePolicy::assertIsSatisfied($fileResource);

Expand Down Expand Up @@ -1154,7 +1154,7 @@ public function toFile($fileResource, string $newlineSeparator = \PHP_EOL, strin
*/
public function toCsvFile(
$fileResource,
array $header = null,
?array $header = null,
string $separator = ',',
string $enclosure = '"',
string $escape = '\\'
Expand Down Expand Up @@ -1215,7 +1215,7 @@ public function anyMatch(callable $predicate): bool
*
* @see Summary::exactlyN()
*/
public function exactlyN(int $n, callable $predicate = null): bool
public function exactlyN(int $n, ?callable $predicate = null): bool
{
return Summary::exactlyN($this->iterable, $n, $predicate);
}
Expand All @@ -1236,7 +1236,7 @@ public function exactlyN(int $n, callable $predicate = null): bool
*
* @see Summary::isPartitioned()
*/
public function isPartitioned(callable $predicate = null): bool
public function isPartitioned(?callable $predicate = null): bool
{
return Summary::isPartitioned($this->iterable, $predicate);
}
Expand Down Expand Up @@ -1436,7 +1436,7 @@ public function toCount(): int
*
* @see Reduce::toMax()
*/
public function toMax(callable $compareBy = null)
public function toMax(?callable $compareBy = null)
{
return Reduce::toMax($this->iterable, $compareBy);
}
Expand All @@ -1456,7 +1456,7 @@ public function toMax(callable $compareBy = null)
*
* @see Reduce::toMin()
*/
public function toMin(callable $compareBy = null)
public function toMin(?callable $compareBy = null)
{
return Reduce::toMin($this->iterable, $compareBy);
}
Expand All @@ -1476,7 +1476,7 @@ public function toMin(callable $compareBy = null)
*
* @see Reduce::toMinMax()
*/
public function toMinMax(callable $compareBy = null): array
public function toMinMax(?callable $compareBy = null): array
{
/** @var iterable<numeric> $iterable */
$iterable = $this->iterable;
Expand Down
4 changes: 2 additions & 2 deletions src/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public static function sameCount(iterable ...$iterables): bool
*
* @return bool
*/
public static function exactlyN(iterable $data, int $n, callable $predicate = null): bool
public static function exactlyN(iterable $data, int $n, ?callable $predicate = null): bool
{
if ($n < 0) {
return false;
Expand Down Expand Up @@ -318,7 +318,7 @@ private static function arePermutationsInternal(bool $strict, iterable ...$itera
*
* @return bool
*/
public static function isPartitioned(iterable $data, callable $predicate = null): bool
public static function isPartitioned(iterable $data, ?callable $predicate = null): bool
{
$predicate ??= fn ($item): bool => \boolval($item);

Expand Down
4 changes: 2 additions & 2 deletions src/Transform.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public static function toArray(iterable $iterable): array
*/
public static function toAssociativeArray(
iterable $iterable,
callable $keyFunc = null,
callable $valueFunc = null
?callable $keyFunc = null,
?callable $valueFunc = null
): array {
if ($keyFunc === null) {
$keyFunc = fn ($item, $key) => $key;
Expand Down
8 changes: 4 additions & 4 deletions src/Util/Iterators/TeeIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getRelatedIterators(): array
*
* @param RelatedIterator<TKey, TValue>|null $related
*/
public function next(RelatedIterator $related = null): void
public function next(?RelatedIterator $related = null): void
{
if ($related === null) {
throw new \LogicException();
Expand Down Expand Up @@ -98,7 +98,7 @@ public function next(RelatedIterator $related = null): void
* @param RelatedIterator<TKey, TValue>|null $related
*/
#[\ReturnTypeWillChange]
public function current(RelatedIterator $related = null)
public function current(?RelatedIterator $related = null)
{
if ($related === null) {
throw new \LogicException();
Expand All @@ -115,7 +115,7 @@ public function current(RelatedIterator $related = null)
* @return TKey
*/
#[\ReturnTypeWillChange]
public function key(RelatedIterator $related = null)
public function key(?RelatedIterator $related = null)
{
if ($related === null) {
throw new \LogicException();
Expand All @@ -129,7 +129,7 @@ public function key(RelatedIterator $related = null)
*
* @param RelatedIterator<TKey, TValue>|null $related
*/
public function valid(RelatedIterator $related = null): bool
public function valid(?RelatedIterator $related = null): bool
{
if ($related === null) {
throw new \LogicException();
Expand Down
Loading