Skip to content

Commit

Permalink
changes parameters for $then and $else from callable to \Closure
Browse files Browse the repository at this point in the history
  • Loading branch information
liambaloh committed Sep 24, 2021
1 parent 43ce8d4 commit e09020e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1794,11 +1794,11 @@ Map::from( ['a' => 'X', 'b' => 'Y'] )->has( 'X' );
Executes callables $then and $else depending on callable $condition.

```php
public function if( $condition, callable $then, callable $else = null ) : self
public function if( $condition, \Closure $then, \Closure $else = null ) : self
```
* @param callable|bool $condition Bool or function with (Map) parameter which evaluates to bool
* @param callable $then Function with (Map) parameter which returns void
* @param callable|null $else Optional function with (Map) parameter which returns void
* @param \Closure $then Function with (Map) parameter which returns void
* @param \Closure|null $else Optional function with (Map) parameter which returns void
* @return self Same map for fluid interface

**Examples:**
Expand Down
6 changes: 3 additions & 3 deletions src/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -3741,11 +3741,11 @@ protected function visit( iterable $entries, array &$result, int $level, ?\Closu
* ->first();
*
* @param callable|bool $condition Bool or function with (Map) parameter which evaluates to bool
* @param callable $then Function with (Map) parameter which returns void
* @param callable|null $else Optional function with (Map) parameter which returns void
* @param \Closure $then Function with (Map) parameter which returns void
* @param \Closure|null $else Optional function with (Map) parameter which returns void
* @return self Same map for fluid interface
*/
public function if( $condition, callable $then, callable $else = null ): self
public function if( $condition, \Closure $then, \Closure $else = null ): self
{
if( $condition instanceof \Closure ? $condition( $this ) : $condition ){
$then( $this );
Expand Down

0 comments on commit e09020e

Please sign in to comment.