@@ -76,14 +76,31 @@ function array_except($array, $keys)
76
76
/**
77
77
* Return the first element in an array passing a given truth test.
78
78
*
79
+ * @deprecated A native function with the same name was introduced in PHP 8.5.
80
+ * Use Illuminate\Support\Arr::first to keep functionality
81
+ *
79
82
* @param array $array
80
83
* @param callable|null $callback
81
84
* @param mixed $default
82
85
* @return mixed
83
86
*/
84
87
function array_first ($ array , ?callable $ callback = null , $ default = null )
85
88
{
86
- return Arr::first ($ array , $ callback , $ default );
89
+ if (is_null ($ callback )) {
90
+ if (empty ($ array )) {
91
+ return value ($ default );
92
+ }
93
+
94
+ foreach ($ array as $ item ) {
95
+ return $ item ;
96
+ }
97
+
98
+ return value ($ default );
99
+ }
100
+
101
+ $ key = array_find_key ($ array , $ callback );
102
+
103
+ return $ key !== null ? $ array [$ key ] : value ($ default );
87
104
}
88
105
}
89
106
@@ -148,14 +165,21 @@ function array_has($array, $keys)
148
165
/**
149
166
* Return the last element in an array passing a given truth test.
150
167
*
168
+ * @deprecated A native function with the same name was introduced in PHP 8.5.
169
+ * Use Illuminate\Support\Arr::last to keep functionality
170
+ *
151
171
* @param array $array
152
172
* @param callable|null $callback
153
173
* @param mixed $default
154
174
* @return mixed
155
175
*/
156
176
function array_last ($ array , ?callable $ callback = null , $ default = null )
157
177
{
158
- return Arr::last ($ array , $ callback , $ default );
178
+ if (is_null ($ callback )) {
179
+ return empty ($ array ) ? value ($ default ) : end ($ array );
180
+ }
181
+
182
+ return Arr::first (array_reverse ($ array , true ), $ callback , $ default );
159
183
}
160
184
}
161
185
@@ -403,13 +427,30 @@ function str_before($subject, $search)
403
427
/**
404
428
* Determine if a given string contains a given substring.
405
429
*
430
+ * @deprecated A native function with the same name was introduced in PHP 8.0.
431
+ * Use Illuminate\Support\Str::contains to keep functionality
432
+ *
406
433
* @param string $haystack
407
434
* @param string|array $needles
408
435
* @return bool
409
436
*/
410
437
function str_contains ($ haystack , $ needles )
411
438
{
412
- return Str::contains ($ haystack , $ needles );
439
+ if (is_null ($ haystack )) {
440
+ return false ;
441
+ }
442
+
443
+ if (! is_iterable ($ needles )) {
444
+ $ needles = (array ) $ needles ;
445
+ }
446
+
447
+ foreach ($ needles as $ needle ) {
448
+ if ($ needle !== '' && strpos ($ haystack , $ needle ) !== false ) {
449
+ return true ;
450
+ }
451
+ }
452
+
453
+ return false ;
413
454
}
414
455
}
415
456
0 commit comments