@@ -48,38 +48,38 @@ public static function containsKey(iterable $iterable, mixed $key): bool
4848
4949
5050	/** 
51- 	 * Returns the first item (matching the specified predicate if given) or null if  there is no such item. 
52- 	 * The callback  has the signature `function ($value, $key, $iterable): bool`. 
51+ 	 * Returns the first item (matching the specified predicate if given). If  there is no such item, it returns result of invoking $else or null . 
52+ 	 * The $predicate  has the signature `function ($value, $key, $iterable): bool`. 
5353	 * @template T 
5454	 * @param  iterable<T>  $iterable 
5555	 * @return ?T 
5656	 */ 
57- 	public  static  function  first (iterable  $ iterablecallable  $ predicatenull ): mixed 
57+ 	public  static  function  first (iterable  $ iterablecallable  $ predicatenull , ? callable   $ else  =  null ): mixed 
5858	{
5959		foreach  ($ iterableas  $ k$ v
6060			if  (!$ predicate$ predicate$ v$ k$ iterable
6161				return  $ v
6262			}
6363		}
64- 		return  null ;
64+ 		return  $ else  ?  $ else () :  null ;
6565	}
6666
6767
6868	/** 
69- 	 * Returns the key of first item (matching the specified predicate if given) or null if  there is no such item. 
70- 	 * The callback  has the signature `function ($value, $key, $iterable): bool`. 
69+ 	 * Returns the key of first item (matching the specified predicate if given). If  there is no such item, it returns result of invoking $else or null . 
70+ 	 * The $predicate  has the signature `function ($value, $key, $iterable): bool`. 
7171	 * @template T 
7272	 * @param  iterable<T, mixed>  $iterable 
7373	 * @return ?T 
7474	 */ 
75- 	public  static  function  firstKey (iterable  $ iterablecallable  $ predicatenull ): mixed 
75+ 	public  static  function  firstKey (iterable  $ iterablecallable  $ predicatenull , ? callable   $ else  =  null ): mixed 
7676	{
7777		foreach  ($ iterableas  $ k$ v
7878			if  (!$ predicate$ predicate$ v$ k$ iterable
7979				return  $ k
8080			}
8181		}
82- 		return  null ;
82+ 		return  $ else  ?  $ else () :  null ;
8383	}
8484
8585
0 commit comments