Skip to content

Commit 837e6c5

Browse files
X-Coder264taylorotwell
authored andcommitted
[5.8] Deprecate useless Arr and Str global helper methods/aliases (#26898)
1 parent fa3ac1e commit 837e6c5

16 files changed

+209
-112
lines changed

src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Illuminate\Foundation\Testing\Concerns;
44

5+
use Illuminate\Support\Arr;
56
use Illuminate\Console\OutputStyle;
67
use Illuminate\Contracts\Console\Kernel;
78
use Illuminate\Foundation\Testing\PendingCommand;
@@ -44,11 +45,11 @@ public function artisan($command, $parameters = [])
4445

4546
$this->beforeApplicationDestroyed(function () {
4647
if (count($this->expectedQuestions)) {
47-
$this->fail('Question "'.array_first($this->expectedQuestions)[0].'" was not asked.');
48+
$this->fail('Question "'.Arr::first($this->expectedQuestions)[0].'" was not asked.');
4849
}
4950

5051
if (count($this->expectedOutput)) {
51-
$this->fail('Output "'.array_first($this->expectedOutput).'" was not printed.');
52+
$this->fail('Output "'.Arr::first($this->expectedOutput).'" was not printed.');
5253
}
5354
});
5455

src/Illuminate/Support/helpers.php

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ function append_config(array $array)
3838
* @param string $key
3939
* @param mixed $value
4040
* @return array
41+
*
42+
* @deprecated Arr::add() should be used directly instead. Will be removed in Laravel 5.9.
4143
*/
4244
function array_add($array, $key, $value)
4345
{
@@ -51,6 +53,8 @@ function array_add($array, $key, $value)
5153
*
5254
* @param array $array
5355
* @return array
56+
*
57+
* @deprecated Arr::collapse() should be used directly instead. Will be removed in Laravel 5.9.
5458
*/
5559
function array_collapse($array)
5660
{
@@ -64,6 +68,8 @@ function array_collapse($array)
6468
*
6569
* @param array $array
6670
* @return array
71+
*
72+
* @deprecated Arr::divide() should be used directly instead. Will be removed in Laravel 5.9.
6773
*/
6874
function array_divide($array)
6975
{
@@ -78,6 +84,8 @@ function array_divide($array)
7884
* @param array $array
7985
* @param string $prepend
8086
* @return array
87+
*
88+
* @deprecated Arr::dot() should be used directly instead. Will be removed in Laravel 5.9.
8189
*/
8290
function array_dot($array, $prepend = '')
8391
{
@@ -92,6 +100,8 @@ function array_dot($array, $prepend = '')
92100
* @param array $array
93101
* @param array|string $keys
94102
* @return array
103+
*
104+
* @deprecated Arr::except() should be used directly instead. Will be removed in Laravel 5.9.
95105
*/
96106
function array_except($array, $keys)
97107
{
@@ -107,6 +117,8 @@ function array_except($array, $keys)
107117
* @param callable|null $callback
108118
* @param mixed $default
109119
* @return mixed
120+
*
121+
* @deprecated Arr::first() should be used directly instead. Will be removed in Laravel 5.9.
110122
*/
111123
function array_first($array, callable $callback = null, $default = null)
112124
{
@@ -121,6 +133,8 @@ function array_first($array, callable $callback = null, $default = null)
121133
* @param array $array
122134
* @param int $depth
123135
* @return array
136+
*
137+
* @deprecated Arr::flatten() should be used directly instead. Will be removed in Laravel 5.9.
124138
*/
125139
function array_flatten($array, $depth = INF)
126140
{
@@ -135,6 +149,8 @@ function array_flatten($array, $depth = INF)
135149
* @param array $array
136150
* @param array|string $keys
137151
* @return void
152+
*
153+
* @deprecated Arr::forget() should be used directly instead. Will be removed in Laravel 5.9.
138154
*/
139155
function array_forget(&$array, $keys)
140156
{
@@ -150,6 +166,8 @@ function array_forget(&$array, $keys)
150166
* @param string $key
151167
* @param mixed $default
152168
* @return mixed
169+
*
170+
* @deprecated Arr::get() should be used directly instead. Will be removed in Laravel 5.9.
153171
*/
154172
function array_get($array, $key, $default = null)
155173
{
@@ -164,6 +182,8 @@ function array_get($array, $key, $default = null)
164182
* @param \ArrayAccess|array $array
165183
* @param string|array $keys
166184
* @return bool
185+
*
186+
* @deprecated Arr::has() should be used directly instead. Will be removed in Laravel 5.9.
167187
*/
168188
function array_has($array, $keys)
169189
{
@@ -179,6 +199,8 @@ function array_has($array, $keys)
179199
* @param callable|null $callback
180200
* @param mixed $default
181201
* @return mixed
202+
*
203+
* @deprecated Arr::last() should be used directly instead. Will be removed in Laravel 5.9.
182204
*/
183205
function array_last($array, callable $callback = null, $default = null)
184206
{
@@ -193,6 +215,8 @@ function array_last($array, callable $callback = null, $default = null)
193215
* @param array $array
194216
* @param array|string $keys
195217
* @return array
218+
*
219+
* @deprecated Arr::only() should be used directly instead. Will be removed in Laravel 5.9.
196220
*/
197221
function array_only($array, $keys)
198222
{
@@ -208,6 +232,8 @@ function array_only($array, $keys)
208232
* @param string|array $value
209233
* @param string|array|null $key
210234
* @return array
235+
*
236+
* @deprecated Arr::pluck() should be used directly instead. Will be removed in Laravel 5.9.
211237
*/
212238
function array_pluck($array, $value, $key = null)
213239
{
@@ -223,6 +249,8 @@ function array_pluck($array, $value, $key = null)
223249
* @param mixed $value
224250
* @param mixed $key
225251
* @return array
252+
*
253+
* @deprecated Arr::prepend() should be used directly instead. Will be removed in Laravel 5.9.
226254
*/
227255
function array_prepend($array, $value, $key = null)
228256
{
@@ -238,6 +266,8 @@ function array_prepend($array, $value, $key = null)
238266
* @param string $key
239267
* @param mixed $default
240268
* @return mixed
269+
*
270+
* @deprecated Arr::pull() should be used directly instead. Will be removed in Laravel 5.9.
241271
*/
242272
function array_pull(&$array, $key, $default = null)
243273
{
@@ -252,6 +282,8 @@ function array_pull(&$array, $key, $default = null)
252282
* @param array $array
253283
* @param int|null $num
254284
* @return mixed
285+
*
286+
* @deprecated Arr::random() should be used directly instead. Will be removed in Laravel 5.9.
255287
*/
256288
function array_random($array, $num = null)
257289
{
@@ -269,6 +301,8 @@ function array_random($array, $num = null)
269301
* @param string $key
270302
* @param mixed $value
271303
* @return array
304+
*
305+
* @deprecated Arr::set() should be used directly instead. Will be removed in Laravel 5.9.
272306
*/
273307
function array_set(&$array, $key, $value)
274308
{
@@ -283,6 +317,8 @@ function array_set(&$array, $key, $value)
283317
* @param array $array
284318
* @param callable|string|null $callback
285319
* @return array
320+
*
321+
* @deprecated Arr::sort() should be used directly instead. Will be removed in Laravel 5.9.
286322
*/
287323
function array_sort($array, $callback = null)
288324
{
@@ -296,6 +332,8 @@ function array_sort($array, $callback = null)
296332
*
297333
* @param array $array
298334
* @return array
335+
*
336+
* @deprecated Arr::sortRecursive() should be used directly instead. Will be removed in Laravel 5.9.
299337
*/
300338
function array_sort_recursive($array)
301339
{
@@ -310,6 +348,8 @@ function array_sort_recursive($array)
310348
* @param array $array
311349
* @param callable $callback
312350
* @return array
351+
*
352+
* @deprecated Arr::where() should be used directly instead. Will be removed in Laravel 5.9.
313353
*/
314354
function array_where($array, callable $callback)
315355
{
@@ -323,6 +363,8 @@ function array_where($array, callable $callback)
323363
*
324364
* @param mixed $value
325365
* @return array
366+
*
367+
* @deprecated Arr::wrap() should be used directly instead. Will be removed in Laravel 5.9.
326368
*/
327369
function array_wrap($value)
328370
{
@@ -365,6 +407,8 @@ function blank($value)
365407
*
366408
* @param string $value
367409
* @return string
410+
*
411+
* @deprecated Str::camel() should be used directly instead. Will be removed in Laravel 5.9.
368412
*/
369413
function camel_case($value)
370414
{
@@ -572,6 +616,8 @@ function e($value, $doubleEncode = true)
572616
* @param string $haystack
573617
* @param string|array $needles
574618
* @return bool
619+
*
620+
* @deprecated Str::endsWith() should be used directly instead. Will be removed in Laravel 5.9.
575621
*/
576622
function ends_with($haystack, $needles)
577623
{
@@ -650,6 +696,8 @@ function head($array)
650696
*
651697
* @param string $value
652698
* @return string
699+
*
700+
* @deprecated Str::kebab() should be used directly instead. Will be removed in Laravel 5.9.
653701
*/
654702
function kebab_case($value)
655703
{
@@ -778,6 +826,8 @@ function retry($times, callable $callback, $sleep = 0)
778826
* @param string $value
779827
* @param string $delimiter
780828
* @return string
829+
*
830+
* @deprecated Str::snake() should be used directly instead. Will be removed in Laravel 5.9.
781831
*/
782832
function snake_case($value, $delimiter = '_')
783833
{
@@ -792,6 +842,8 @@ function snake_case($value, $delimiter = '_')
792842
* @param string $haystack
793843
* @param string|array $needles
794844
* @return bool
845+
*
846+
* @deprecated Str::startsWith() should be used directly instead. Will be removed in Laravel 5.9.
795847
*/
796848
function starts_with($haystack, $needles)
797849
{
@@ -806,6 +858,8 @@ function starts_with($haystack, $needles)
806858
* @param string $subject
807859
* @param string $search
808860
* @return string
861+
*
862+
* @deprecated Str::after() should be used directly instead. Will be removed in Laravel 5.9.
809863
*/
810864
function str_after($subject, $search)
811865
{
@@ -820,6 +874,8 @@ function str_after($subject, $search)
820874
* @param string $subject
821875
* @param string $search
822876
* @return string
877+
*
878+
* @deprecated Str::before() should be used directly instead. Will be removed in Laravel 5.9.
823879
*/
824880
function str_before($subject, $search)
825881
{
@@ -834,6 +890,8 @@ function str_before($subject, $search)
834890
* @param string $haystack
835891
* @param string|array $needles
836892
* @return bool
893+
*
894+
* @deprecated Str::contains() should be used directly instead. Will be removed in Laravel 5.9.
837895
*/
838896
function str_contains($haystack, $needles)
839897
{
@@ -848,6 +906,8 @@ function str_contains($haystack, $needles)
848906
* @param string $value
849907
* @param string $cap
850908
* @return string
909+
*
910+
* @deprecated Str::finish() should be used directly instead. Will be removed in Laravel 5.9.
851911
*/
852912
function str_finish($value, $cap)
853913
{
@@ -862,6 +922,8 @@ function str_finish($value, $cap)
862922
* @param string|array $pattern
863923
* @param string $value
864924
* @return bool
925+
*
926+
* @deprecated Str::is() should be used directly instead. Will be removed in Laravel 5.9.
865927
*/
866928
function str_is($pattern, $value)
867929
{
@@ -877,6 +939,8 @@ function str_is($pattern, $value)
877939
* @param int $limit
878940
* @param string $end
879941
* @return string
942+
*
943+
* @deprecated Str::limit() should be used directly instead. Will be removed in Laravel 5.9.
880944
*/
881945
function str_limit($value, $limit = 100, $end = '...')
882946
{
@@ -891,6 +955,8 @@ function str_limit($value, $limit = 100, $end = '...')
891955
* @param string $value
892956
* @param int $count
893957
* @return string
958+
*
959+
* @deprecated Str::plural() should be used directly instead. Will be removed in Laravel 5.9.
894960
*/
895961
function str_plural($value, $count = 2)
896962
{
@@ -906,6 +972,8 @@ function str_plural($value, $count = 2)
906972
* @return string
907973
*
908974
* @throws \RuntimeException
975+
*
976+
* @deprecated Str::random() should be used directly instead. Will be removed in Laravel 5.9.
909977
*/
910978
function str_random($length = 16)
911979
{
@@ -921,6 +989,8 @@ function str_random($length = 16)
921989
* @param array $replace
922990
* @param string $subject
923991
* @return string
992+
*
993+
* @deprecated Str::replaceArray() should be used directly instead. Will be removed in Laravel 5.9.
924994
*/
925995
function str_replace_array($search, array $replace, $subject)
926996
{
@@ -936,6 +1006,8 @@ function str_replace_array($search, array $replace, $subject)
9361006
* @param string $replace
9371007
* @param string $subject
9381008
* @return string
1009+
*
1010+
* @deprecated Str::replaceFirst() should be used directly instead. Will be removed in Laravel 5.9.
9391011
*/
9401012
function str_replace_first($search, $replace, $subject)
9411013
{
@@ -951,6 +1023,8 @@ function str_replace_first($search, $replace, $subject)
9511023
* @param string $replace
9521024
* @param string $subject
9531025
* @return string
1026+
*
1027+
* @deprecated Str::replaceLast() should be used directly instead. Will be removed in Laravel 5.9.
9541028
*/
9551029
function str_replace_last($search, $replace, $subject)
9561030
{
@@ -964,6 +1038,8 @@ function str_replace_last($search, $replace, $subject)
9641038
*
9651039
* @param string $value
9661040
* @return string
1041+
*
1042+
* @deprecated Str::singular() should be used directly instead. Will be removed in Laravel 5.9.
9671043
*/
9681044
function str_singular($value)
9691045
{
@@ -979,6 +1055,8 @@ function str_singular($value)
9791055
* @param string $separator
9801056
* @param string $language
9811057
* @return string
1058+
*
1059+
* @deprecated Str::slug() should be used directly instead. Will be removed in Laravel 5.9.
9821060
*/
9831061
function str_slug($title, $separator = '-', $language = 'en')
9841062
{
@@ -993,6 +1071,8 @@ function str_slug($title, $separator = '-', $language = 'en')
9931071
* @param string $value
9941072
* @param string $prefix
9951073
* @return string
1074+
*
1075+
* @deprecated Str::start() should be used directly instead. Will be removed in Laravel 5.9.
9961076
*/
9971077
function str_start($value, $prefix)
9981078
{
@@ -1006,6 +1086,8 @@ function str_start($value, $prefix)
10061086
*
10071087
* @param string $value
10081088
* @return string
1089+
*
1090+
* @deprecated Str::studly() should be used directly instead. Will be removed in Laravel 5.9.
10091091
*/
10101092
function studly_case($value)
10111093
{
@@ -1080,6 +1162,8 @@ function throw_unless($condition, $exception, ...$parameters)
10801162
*
10811163
* @param string $value
10821164
* @return string
1165+
*
1166+
* @deprecated Str::title() should be used directly instead. Will be removed in Laravel 5.9.
10831167
*/
10841168
function title_case($value)
10851169
{

0 commit comments

Comments
 (0)