@@ -1733,6 +1733,7 @@ public function firstKey( $default = null )
1733
1733
{
1734
1734
$ list = $ this ->list ();
1735
1735
1736
+ // PHP 7.x compatibility
1736
1737
if ( function_exists ( 'array_key_first ' ) ) {
1737
1738
$ key = array_key_first ( $ list );
1738
1739
} else {
@@ -3125,6 +3126,7 @@ public function lastKey( $default = null )
3125
3126
{
3126
3127
$ list = $ this ->list ();
3127
3128
3129
+ // PHP 7.x compatibility
3128
3130
if ( function_exists ( 'array_key_last ' ) ) {
3129
3131
$ key = array_key_last ( $ list );
3130
3132
} else {
@@ -3606,7 +3608,8 @@ public function partition( $number ) : self
3606
3608
3607
3609
return new static ( $ result );
3608
3610
}
3609
- elseif ( is_int ( $ number ) )
3611
+
3612
+ if ( is_int ( $ number ) )
3610
3613
{
3611
3614
$ start = 0 ;
3612
3615
$ size = (int ) ceil ( count ( $ list ) / $ number );
@@ -4451,7 +4454,7 @@ public function slice( int $offset, ?int $length = null ) : self
4451
4454
* Results:
4452
4455
* The first three examples will return TRUE while the fourth and fifth will return FALSE
4453
4456
*
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
4455
4458
* @param bool $strict TRUE to check the type too, using FALSE '1' and 1 will be the same
4456
4459
* @return bool TRUE if at least one element is available in map, FALSE if the map contains none of them
4457
4460
*/
@@ -4470,7 +4473,8 @@ public function some( $values, bool $strict = false ) : bool
4470
4473
4471
4474
return false ;
4472
4475
}
4473
- elseif ( is_callable ( $ values ) )
4476
+
4477
+ if ( $ values instanceof \Closure )
4474
4478
{
4475
4479
foreach ( $ list as $ key => $ item )
4476
4480
{
@@ -4479,12 +4483,8 @@ public function some( $values, bool $strict = false ) : bool
4479
4483
}
4480
4484
}
4481
4485
}
4482
- elseif ( in_array ( $ values , $ list , $ strict ) === true )
4483
- {
4484
- return true ;
4485
- }
4486
4486
4487
- return false ;
4487
+ return in_array ( $ values , $ list , $ strict ) ;
4488
4488
}
4489
4489
4490
4490
@@ -4584,6 +4584,7 @@ public function sorted( int $options = SORT_REGULAR ) : self
4584
4584
*/
4585
4585
public function splice ( int $ offset , ?int $ length = null , $ replacement = [] ) : self
4586
4586
{
4587
+ // PHP 7.x doesn't allow to pass NULL as replacement
4587
4588
if ( $ length === null ) {
4588
4589
$ length = count ( $ this ->list () );
4589
4590
}
@@ -4695,7 +4696,6 @@ public function strBefore( string $value, bool $case = false, string $encoding =
4695
4696
$ list [$ key ] = mb_substr ( $ str , 0 , $ pos , $ encoding );
4696
4697
} elseif ( $ str !== '' && $ pos !== false ) {
4697
4698
$ list [$ key ] = $ str ;
4698
- } else {
4699
4699
}
4700
4700
}
4701
4701
}
0 commit comments