@@ -1733,6 +1733,7 @@ public function firstKey( $default = null )
17331733 {
17341734 $ list = $ this ->list ();
17351735
1736+ // PHP 7.x compatibility
17361737 if ( function_exists ( 'array_key_first ' ) ) {
17371738 $ key = array_key_first ( $ list );
17381739 } else {
@@ -3125,6 +3126,7 @@ public function lastKey( $default = null )
31253126 {
31263127 $ list = $ this ->list ();
31273128
3129+ // PHP 7.x compatibility
31283130 if ( function_exists ( 'array_key_last ' ) ) {
31293131 $ key = array_key_last ( $ list );
31303132 } else {
@@ -3606,7 +3608,8 @@ public function partition( $number ) : self
36063608
36073609 return new static ( $ result );
36083610 }
3609- elseif ( is_int ( $ number ) )
3611+
3612+ if ( is_int ( $ number ) )
36103613 {
36113614 $ start = 0 ;
36123615 $ size = (int ) ceil ( count ( $ list ) / $ number );
@@ -4451,7 +4454,7 @@ public function slice( int $offset, ?int $length = null ) : self
44514454 * Results:
44524455 * The first three examples will return TRUE while the fourth and fifth will return FALSE
44534456 *
4454- * @param \Closure|iterable|mixed $values Anonymous function with (item, key) parameter, element or list of elements to test against
4457+ * @param \Closure|iterable|mixed $values Closure with (item, key) parameter, element or list of elements to test against
44554458 * @param bool $strict TRUE to check the type too, using FALSE '1' and 1 will be the same
44564459 * @return bool TRUE if at least one element is available in map, FALSE if the map contains none of them
44574460 */
@@ -4470,7 +4473,8 @@ public function some( $values, bool $strict = false ) : bool
44704473
44714474 return false ;
44724475 }
4473- elseif ( is_callable ( $ values ) )
4476+
4477+ if ( $ values instanceof \Closure )
44744478 {
44754479 foreach ( $ list as $ key => $ item )
44764480 {
@@ -4479,12 +4483,8 @@ public function some( $values, bool $strict = false ) : bool
44794483 }
44804484 }
44814485 }
4482- elseif ( in_array ( $ values , $ list , $ strict ) === true )
4483- {
4484- return true ;
4485- }
44864486
4487- return false ;
4487+ return in_array ( $ values , $ list , $ strict ) ;
44884488 }
44894489
44904490
@@ -4584,6 +4584,7 @@ public function sorted( int $options = SORT_REGULAR ) : self
45844584 */
45854585 public function splice ( int $ offset , ?int $ length = null , $ replacement = [] ) : self
45864586 {
4587+ // PHP 7.x doesn't allow to pass NULL as replacement
45874588 if ( $ length === null ) {
45884589 $ length = count ( $ this ->list () );
45894590 }
@@ -4695,7 +4696,6 @@ public function strBefore( string $value, bool $case = false, string $encoding =
46954696 $ list [$ key ] = mb_substr ( $ str , 0 , $ pos , $ encoding );
46964697 } elseif ( $ str !== '' && $ pos !== false ) {
46974698 $ list [$ key ] = $ str ;
4698- } else {
46994699 }
47004700 }
47014701 }
0 commit comments