10000 chore: remove all references to callable, replace by closure by azjezz · Pull Request #323 · azjezz/psl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore: remove all references to callable, replace by closure #323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 21, 2021
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.
10000 Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@
* **BC** - `Psl\Str`, `Psl\Str\Byte`, and `Psl\Str\Grapheme` functions now throw `Psl\Str\Exception\OutOfBoundsException` instead of `Psl\Exception\InvaraintViolationsException` when `$offset` is out-of-bounds.
* **BC** - `Psl\Collection\IndexAccessInterface::at()` now throw `Psl\Collection\Exception\OutOfBoundsException` instead of `Psl\Exception\InvariantViolationException` if `$k` is out-of-bounds.
* **BC** - `Psl\Collection\AccessibleCollectionInterface::slice` signature has changed from `slice(int $start, int $length): static` to `slice(int $start, ?int $length = null): static`
* **BC** - All psl functions previously accepting `callable`, now accept only `Closure`.
24 changes: 12 additions & 12 deletions docs/component/collection.md
Original file line number Diff line number Diff line change
B422 Expand Up @@ -12,22 +12,22 @@

#### `Interfaces`

- [AccessibleCollectionInterface](./../../src/Psl/Collection/AccessibleCollectionInterface.php#L18)
- [CollectionInterface](./../../src/Psl/Collection/CollectionInterface.php#L21)
- [AccessibleCollectionInterface](./../../src/Psl/Collection/AccessibleCollectionInterface.php#L20)
- [CollectionInterface](./../../src/Psl/Collection/CollectionInterface.php#L22)
- [IndexAccessInterface](./../../src/Psl/Collection/IndexAccessInterface.php#L13)
- [MapInterface](./../../src/Psl/Collection/MapInterface.php#L13)
- [MutableAccessibleCollectionInterface](./../../src/Psl/Collection/MutableAccessibleCollectionInterface.php#L20)
- [MutableCollectionInterface](./../../src/Psl/Collection/MutableCollectionInterface.php#L20)
- [MapInterface](./../../src/Psl/Collection/MapInterface.php#L15)
- [MutableAccessibleCollectionInterface](./../../src/Psl/Collection/MutableAccessibleCollectionInterface.php#L22)
- [MutableCollectionInterface](./../../src/Psl/Collection/MutableCollectionInterface.php#L22)
- [MutableIndexAccessInterface](./../../src/Psl/Collection/MutableIndexAccessInterface.php#L16)
- [MutableMapInterface](./../../src/Psl/Collection/MutableMapInterface.php#L14)
- [MutableVectorInterface](./../../src/Psl/Collection/MutableVectorInterface.php#L13)
- [VectorInterface](./../../src/Psl/Collection/VectorInterface.php#L12)
- [MutableMapInterface](./../../src/Psl/Collection/MutableMapInterface.php#L16)
- [MutableVectorInterface](./../../src/Psl/Collection/MutableVectorInterface.php#L15)
- [VectorInterface](./../../src/Psl/Collection/VectorInterface.php#L14)

#### `Classes`

- [Map](./../../src/Psl/Collection/Map.php#L24)
- [MutableMap](./../../src/Psl/Collection/MutableMap.php#L24)
- [MutableVector](./../../src/Psl/Collection/MutableVector.php#L22)
- [Vector](./../../src/Psl/Collection/Vector.php#L21)
- [Map](./../../src/Psl/Collection/Map.php#L25)
- [MutableMap](./../../src/Psl/Collection/MutableMap.php#L25)
- [MutableVector](./../../src/Psl/Collection/MutableVector.php#L23)
- [Vector](./../../src/Psl/Collection/Vector.php#L22)


38 changes: 19 additions & 19 deletions docs/component/dict.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,38 @@
- [diff](./../../src/Psl/Dict/diff.php#L24)
- [diff_by_key](./../../src/Psl/Dict/diff_by_key.php#L24)
- [drop](./../../src/Psl/Dict/drop.php#L23)
- [drop_while](./../../src/Psl/Dict/drop_while.php#L26)
- [drop_while](./../../src/Psl/Dict/drop_while.php#L28)
- [equal](./../../src/Psl/Dict/equal.php#L19)
- [filter](./../../src/Psl/Dict/filter.php#L32)
- [filter_keys](./../../src/Psl/Dict/filter_keys.php#L34)
- [filter](./../../src/Psl/Dict/filter.php#L34)
- [filter_keys](./../../src/Psl/Dict/filter_keys.php#L36)
- [filter_nulls](./../../src/Psl/Dict/filter_nulls.php#L21)
- [filter_with_key](./../../src/Psl/Dict/filter_with_key.php#L37)
- [filter_with_key](./../../src/Psl/Dict/filter_with_key.php#L39)
- [flatten](./../../src/Psl/Dict/flatten.php#L28)
- [flip](./../../src/Psl/Dict/flip.php#L27)
- [from_entries](./../../src/Psl/Dict/from_entries.php#L18)
- [from_iterable](./../../src/Psl/Dict/from_iterable.php#L19)
- [from_keys](./../../src/Psl/Dict/from_keys.php#L19)
- [group_by](./../../src/Psl/Dict/group_by.php#L41)
- [from_keys](./../../src/Psl/Dict/from_keys.php#L21)
- [group_by](./../../src/Psl/Dict/group_by.php#L42)
- [intersect](./../../src/Psl/Dict/intersect.php#L24)
- [intersect_by_key](./../../src/Psl/Dict/intersect_by_key.php#L24)
- [map](./../../src/Psl/Dict/map.php#L29)
- [map_keys](./../../src/Psl/Dict/map_keys.php#L29)
- [map_with_key](./../../src/Psl/Dict/map_with_key.php#L29)
- [map](./../../src/Psl/Dict/map.php#L31)
- [map_keys](./../../src/Psl/Dict/map_keys.php#L31)
- [map_with_key](./../../src/Psl/Dict/map_with_key.php#L31)
- [merge](./../../src/Psl/Dict/merge.php#L21)
- [partition](./../../src/Psl/Dict/partition.php#L19)
- [partition_with_key](./../../src/Psl/Dict/partition_with_key.php#L19)
- [pull](./../../src/Psl/Dict/pull.php#L35)
- [pull_with_key](./../../src/Psl/Dict/pull_with_key.php#L35)
- [reindex](./../../src/Psl/Dict/reindex.php#L37)
- [partition](./../../src/Psl/Dict/partition.php#L21)
- [partition_with_key](./../../src/Psl/Dict/partition_with_key.php#L21)
- [pull](./../../src/Psl/Dict/pull.php#L37)
- [pull_with_key](./../../src/Psl/Dict/pull_with_key.php#L37)
- [reindex](./../../src/Psl/Dict/reindex.php#L39)
- [select_keys](./../../src/Psl/Dict/select_keys.php#L23)
- [slice](./../../src/Psl/Dict/slice.php#L27)
- [sort](./../../src/Psl/Dict/sort.php#L24)
- [sort_by](./../../src/Psl/Dict/sort_by.php#L24)
- [sort_by_key](./../../src/Psl/Dict/sort_by_key.php#L24)
- [sort](./../../src/Psl/Dict/sort.php#L26)
- [sort_by](./../../src/Psl/Dict/sort_by.php#L26)
- [sort_by_key](./../../src/Psl/Dict/sort_by_key.php#L26)
- [take](./../../src/Psl/Dict/take.php#L18)
- [take_while](./../../src/Psl/Dict/take_while.php#L26)
- [take_while](./../../src/Psl/Dict/take_while.php#L28)
- [unique](./../../src/Psl/Dict/unique.php#L17)
- [unique_by](./../../src/Psl/Dict/unique_by.php#L23)
- [unique_by](./../../src/Psl/Dict/unique_by.php#L24)
- [unique_scalar](./../../src/Psl/Dict/unique_scalar.php#L21)


16 changes: 8 additions & 8 deletions docs/component/iter.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

#### `Functions`

- [all](./../../src/Psl/Iter/all.php#L18)
- [any](./../../src/Psl/Iter/any.php#L19)
- [apply](./../../src/Psl/Iter/apply.php#L15)
- [all](./../../src/Psl/Iter/all.php#L20)
- [any](./../../src/Psl/Iter/any.php#L21)
- [apply](./../../src/Psl/Iter/apply.php#L17)
- [contains](./../../src/Psl/Iter/contains.php#L16)
- [contains_key](./../../src/Psl/Iter/contains_key.php#L16)
- [count](./../../src/Psl/Iter/count.php#L23)
Expand All @@ -24,15 +24,15 @@
- [last](./../../src/Psl/Iter/last.php#L17)
- [last_key](./../../src/Psl/Iter/last_key.php#L17)
- [random](./../../src/Psl/Iter/random.php#L22)
- [reduce](./../../src/Psl/Iter/reduce.php#L23)
- [reduce_keys](./../../src/Psl/Iter/reduce_keys.php#L24)
- [reduce_with_keys](./../../src/Psl/Iter/reduce_with_keys.php#L25)
- [reduce](./../../src/Psl/Iter/reduce.php#L25)
- [reduce_keys](./../../src/Psl/Iter/reduce_keys.php#L26)
- [reduce_with_keys](./../../src/Psl/Iter/reduce_with_keys.php#L27)
- [rewindable](./../../src/Psl/Iter/rewindable.php#L20)
- [search](./../../src/Psl/Iter/search.php#L26)
- [search](./../../src/Psl/Iter/search.php#L28)
- [to_iterator](./../../src/Psl/Iter/to_iterator.php#L19)

#### `Classes`

- [Iterator](./../../src/Psl/Iter/Iterator.php#L19)
- [Iterator](./../../src/Psl/Iter/Iterator.php#L20)


4 changes: 2 additions & 2 deletions docs/component/math.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
- [from_base](./../../src/Psl/Math/from_base.php#L21)
- [log](./../../src/Psl/Math/log.php#L18)
- [max](./../../src/Psl/Math/max.php#L19)
- [max_by](./../../src/Psl/Math/max_by.php#L22)
- [max_by](./../../src/Psl/Math/max_by.php#L24)
- [maxva](./../../src/Psl/Math/maxva.php#L20)
- [mean](./../../src/Psl/Math/mean.php#L18)
- [median](./../../src/Psl/Math/median.php#L19)
- [min](./../../src/Psl/Math/min.php#L19)
- [min_by](./../../src/Psl/Math/min_by.php#L22)
- [min_by](./../../src/Psl/Math/min_by.php#L24)
- [minva](./../../src/Psl/Math/minva.php#L20)
- [round](./../../src/Psl/Math/round.php#L19)
- [sin](./../../src/Psl/Math/sin.php#L14)
Expand Down
4 changes: 2 additions & 2 deletions docs/component/regex.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
- [every_match](./../../src/Psl/Regex/every_match.php#L25)
- [first_match](./../../src/Psl/Regex/first_match.php#L24)
- [matches](./../../src/Psl/Regex/matches.php#L19)
- [replace](./../../src/Psl/Regex/replace.php#L24)
- [replace_every](./../../src/Psl/Regex/replace_every.php#L25)
- [replace](./../../src/Psl/Regex/replace.php#L22)
- [replace_every](./../../src/Psl/Regex/replace_every.php#L24)
- [replace_with](./../../src/Psl/Regex/replace_with.php#L24)
- [split](./../../src/Psl/Regex/split.php#L29)

Expand Down
22 changes: 11 additions & 11 deletions docs/component/vec.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
- [concat](./../../src/Psl/Vec/concat.php#L17)
- [enumerate](./../../src/Psl/Vec/enumerate.php#L17)
- [fill](./../../src/Psl/Vec/fill.php#L24)
- [filter](./../../src/Psl/Vec/filter.php#L32)
- [filter_keys](./../../src/Psl/Vec/filter_keys.php#L35)
- [filter](./../../src/Psl/Vec/filter.php#L34)
- [filter_keys](./../../src/Psl/Vec/filter_keys.php#L37)
- [filter_nulls](./../../src/Psl/Vec/filter_nulls.php#L20)
- [filter_with_key](./../../src/Psl/Vec/filter_with_key.php#L38)
- [flat_map](./../../src/Psl/Vec/flat_map.php#L16)
- [filter_with_key](./../../src/Psl/Vec/filter_with_key.php#L40)
- [flat_map](./../../src/Psl/Vec/flat_map.php#L18)
- [keys](./../../src/Psl/Vec/keys.php#L20)
- [map](./../../src/Psl/Vec/map.php#L31)
- [map_with_key](./../../src/Psl/Vec/map_with_key.php#L27)
- [partition](./../../src/Psl/Vec/partition.php#L18)
- [map](./../../src/Psl/Vec/map.php#L33)
- [map_with_key](./../../src/Psl/Vec/map_with_key.php#L29)
- [partition](./../../src/Psl/Vec/partition.php#L20)
- [range](./../../src/Psl/Vec/range.php#L51)
- [reductions](./../../src/Psl/Vec/reductions.php#L27)
- [reproduce](./../../src/Psl/Vec/reproduce.php#L22)
- [reductions](./../../src/Psl/Vec/reductions.php#L29)
- [reproduce](./../../src/Psl/Vec/reproduce.php#L24)
- [reverse](./../../src/Psl/Vec/reverse.php#L22)
- [shuffle](./../../src/Psl/Vec/shuffle.php#L26)
- [sort](./../../src/Psl/Vec/sort.php#L23)
- [sort_by](./../../src/Psl/Vec/sort_by.php#L26)
- [sort](./../../src/Psl/Vec/sort.php#L25)
- [sort_by](./../../src/Psl/Vec/sort_by.php#L28)
- [values](./../../src/Psl/Vec/values.php#L19)
- [zip](./../../src/Psl/Vec/zip.php#L37)

Expand Down
19 changes: 10 additions & 9 deletions src/Psl/Channel/Internal/ChannelState.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Psl\Channel\Internal;

use Closure;
use Psl\Channel\ChannelInterface;
use Psl\Channel\Exception;

Expand All @@ -20,17 +21,17 @@
final class ChannelState implements ChannelInterface
{
/**
* @var list<(callable(): void)>
* @var list<(Closure(): void)>
*/
private array $closeListeners = [];

/**
* @var list<(callable(): void)>
* @var list<(Closure(): void)>
*/
private array $receiveListeners = [];

/**
* @var list<(callable(): void)>
* @var list<(Closure(): void)>
*/
private array $sendListeners = [];

Expand All @@ -50,25 +51,25 @@ public function __construct(
}

/**
* @param (callable(): void) $listener
* @param (Closure(): void) $listener
*/
public function addCloseListener(callable $listener): void
public function addCloseListener(Closure $listener): void
{
$this->closeListeners[] = $listener;
}

/**
* @param (callable(): void) $listener
* @param (Closure(): void) $listener
*/
public function addSendListener(callable $listener): void
public function addSendListener(Closure $listener): void
{
$this->sendListeners[] = $listener;
}

/**
* @param (callable(): void) $listener
* @param (Closure(): void) $listener
*/
public function addReceiveListener(callable $listener): void
public function addReceiveListener(Closure $listener): void
{
$this->receiveListeners[] = $listener;
}
Expand Down
26 changes: 14 additions & 12 deletions src/Psl/Collection/AccessibleCollectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Psl\Collection;

use Closure;

/**
* The base interface implemented for a collection type that you are able to access its values.
*
Expand Down Expand Up @@ -46,13 +48,13 @@ public function keys(): AccessibleCollectionInterface;
* The keys associated with the current `AccessibleCollectionInterface` remain unchanged in the
* returned `AccessibleCollectionInterface`.
*
* @param (callable(Tv): bool) $fn The callback containing the condition to apply to the current
* @param (Closure(Tv): bool) $fn The callback containing the condition to apply to the current
* `AccessibleCollectionInterface` values.
*
* @return AccessibleCollectionInterface<Tk, Tv> A `AccessibleCollectionInterface` containing the values
* after a user-specified condition is applied.
*/
public function filter(callable $fn): AccessibleCollectionInterface;
public function filter(Closure $fn): AccessibleCollectionInterface;

/**
* Returns a `AccessibleCollectionInterface` containing the values of the current `AccessibleCollectionInterface`
Expand All @@ -65,14 +67,14 @@ public function filter(callable $fn): AccessibleCollectionInterface;
* The keys associated with the current `AccessibleCollectionInterface` remain unchanged in the
* returned `AccessibleCollectionInterface`; the keys will be used in the filtering process only.
*
* @param (callable(Tk, Tv): bool) $fn The callback containing the condition to apply to the current
* @param (Closure(Tk, Tv): bool) $fn The callback containing the condition to apply to the current
* `AccessibleCollectionInterface` keys and values.
*
* @return AccessibleCollectionInterface<Tk, Tv> A `AccessibleCollectionInterface` containing the values
* after a user-specified condition is applied to the keys and values
* of the current `AccessibleCollectionInterface`.
*/
public function filterWithKey(callable $fn): AccessibleCollectionInterface;
public function filterWithKey(Closure $fn): AccessibleCollectionInterface;

/**
* Returns a `AccessibleCollectionInterface` after an operation has been applied to each value
Expand All @@ -86,13 +88,13 @@ public function filterWithKey(callable $fn): AccessibleCollectionInterface;
*
* @template Tu
*
* @param (callable(Tv): Tu) $fn The callback containing the operation to apply to the current
* @param (Closure(Tv): Tu) $fn The callback containing the operation to apply to the current
* `AccessibleCollectionInterface` values.
*
* @return AccessibleCollectionInterface<Tk, Tu> A `AccessibleCollectionInterface` containing key/value
* pairs after a user-specified operation is applied.
*/
public function map(callable $fn): AccessibleCollectionInterface;
public function map(Closure $fn): AccessibleCollectionInterface;

/**
* Returns a `AccessibleCollectionInterface` after an operation has been applied to each key and
Expand All @@ -107,14 +109,14 @@ public function map(callable $fn): AccessibleCollectionInterface;
*
* @template Tu
*
* @param (callable(Tk, Tv): Tu) $fn The callback containing the operation to apply to the current
* @param (Closure(Tk, Tv): Tu) $fn The callback containing the operation to apply to the current
* `AccessibleCollectionInterface` keys and values.
*
* @return AccessibleCollectionInterface<Tk, Tu> A `AccessibleCollectionInterface` containing the values
* after a user-specified operation on the current
* `AccessibleCollectionInterface`'s keys and values is applied.
*/
public function mapWithKey(callable $fn): AccessibleCollectionInterface;
public function mapWithKey(Closure $fn): AccessibleCollectionInterface;

/**
* Returns the first value in the current `AccessibleCollectionInterface`.
Expand Down Expand Up @@ -218,14 +220,14 @@ public function take(int $n): AccessibleCollectionInterface;
* The returned `AccessibleCollectionInterface` will always be a proper subset of the current
* `AccessibleCollectionInterface`.
*
* @param (callable(Tv): bool) $fn The callback that is used to determine the stopping
* @param (Closure(Tv): bool) $fn The callback that is used to determine the stopping
* condition.
*
* @return AccessibleCollectionInterface<Tk, Tv> A `AccessibleCollectionInterface` that is a proper subset
* of the current `AccessibleCollectionInterface` up until
* the callback returns `false`.
*/
public function takeWhile(callable $fn): AccessibleCollectionInterface;
public function takeWhile(Closure $fn): AccessibleCollectionInterface;

/**
* Returns a `AccessibleCollectionInterface` containing the values after the `n`-th element of
Expand Down Expand Up @@ -255,14 +257,14 @@ public function drop(int $n): AccessibleCollectionInterface;
* The returned `AccessibleCollectionInterface` will always be a proper subset of the current
* `AccessibleCollectionInterface`.
*
* @param (callable(Tv): bool) $fn The callback used to determine the starting element for the
* @param (Closure(Tv): bool) $fn The callback used to determine the starting element for the
* returned `AccessibleCollectionInterface`.
*
* @return AccessibleCollectionInterface<Tk, Tv> A `AccessibleCollectionInterface` that is a proper subset
* of the current `AccessibleCollectionInterface` starting after
* the callback returns `true`.
*/
public function dropWhile(callable $fn): AccessibleCollectionInterface;
public function dropWhile(Closure $fn): AccessibleCollectionInterface;

/**
* Returns a subset of the current `AccessibleCollectionInterface` starting from a given key up
Expand Down
Loading
0