Skip to content

[5.8] Deprecate useless Arr and Str global helper methods #26898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Foundation\Testing\Concerns;

use Illuminate\Support\Arr;
use Illuminate\Console\OutputStyle;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Testing\PendingCommand;
Expand Down Expand Up @@ -44,11 +45,11 @@ public function artisan($command, $parameters = [])

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

if (count($this->expectedOutput)) {
$this->fail('Output "'.array_first($this->expectedOutput).'" was not printed.');
$this->fail('Output "'.Arr::first($this->expectedOutput).'" was not printed.');
}
});

Expand Down
84 changes: 84 additions & 0 deletions src/Illuminate/Support/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ function append_config(array $array)
* @param string $key
* @param mixed $value
* @return array
*
* @deprecated Arr::add() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_add($array, $key, $value)
{
Expand All @@ -51,6 +53,8 @@ function array_add($array, $key, $value)
*
* @param array $array
* @return array
*
* @deprecated Arr::collapse() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_collapse($array)
{
Expand All @@ -64,6 +68,8 @@ function array_collapse($array)
*
* @param array $array
* @return array
*
* @deprecated Arr::divide() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_divide($array)
{
Expand All @@ -78,6 +84,8 @@ function array_divide($array)
* @param array $array
* @param string $prepend
* @return array
*
* @deprecated Arr::dot() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_dot($array, $prepend = '')
{
Expand All @@ -92,6 +100,8 @@ function array_dot($array, $prepend = '')
* @param array $array
* @param array|string $keys
* @return array
*
* @deprecated Arr::except() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_except($array, $keys)
{
Expand All @@ -107,6 +117,8 @@ function array_except($array, $keys)
* @param callable|null $callback
* @param mixed $default
* @return mixed
*
* @deprecated Arr::first() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_first($array, callable $callback = null, $default = null)
{
Expand All @@ -121,6 +133,8 @@ function array_first($array, callable $callback = null, $default = null)
* @param array $array
* @param int $depth
* @return array
*
* @deprecated Arr::flatten() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_flatten($array, $depth = INF)
{
Expand All @@ -135,6 +149,8 @@ function array_flatten($array, $depth = INF)
* @param array $array
* @param array|string $keys
* @return void
*
* @deprecated Arr::forget() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_forget(&$array, $keys)
{
Expand All @@ -150,6 +166,8 @@ function array_forget(&$array, $keys)
* @param string $key
* @param mixed $default
* @return mixed
*
* @deprecated Arr::get() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_get($array, $key, $default = null)
{
Expand All @@ -164,6 +182,8 @@ function array_get($array, $key, $default = null)
* @param \ArrayAccess|array $array
* @param string|array $keys
* @return bool
*
* @deprecated Arr::has() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_has($array, $keys)
{
Expand All @@ -179,6 +199,8 @@ function array_has($array, $keys)
* @param callable|null $callback
* @param mixed $default
* @return mixed
*
* @deprecated Arr::last() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_last($array, callable $callback = null, $default = null)
{
Expand All @@ -193,6 +215,8 @@ function array_last($array, callable $callback = null, $default = null)
* @param array $array
* @param array|string $keys
* @return array
*
* @deprecated Arr::only() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_only($array, $keys)
{
Expand All @@ -208,6 +232,8 @@ function array_only($array, $keys)
* @param string|array $value
* @param string|array|null $key
* @return array
*
* @deprecated Arr::pluck() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_pluck($array, $value, $key = null)
{
Expand All @@ -223,6 +249,8 @@ function array_pluck($array, $value, $key = null)
* @param mixed $value
* @param mixed $key
* @return array
*
* @deprecated Arr::prepend() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_prepend($array, $value, $key = null)
{
Expand All @@ -238,6 +266,8 @@ function array_prepend($array, $value, $key = null)
* @param string $key
* @param mixed $default
* @return mixed
*
* @deprecated Arr::pull() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_pull(&$array, $key, $default = null)
{
Expand All @@ -252,6 +282,8 @@ function array_pull(&$array, $key, $default = null)
* @param array $array
* @param int|null $num
* @return mixed
*
* @deprecated Arr::random() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_random($array, $num = null)
{
Expand All @@ -269,6 +301,8 @@ function array_random($array, $num = null)
* @param string $key
* @param mixed $value
* @return array
*
* @deprecated Arr::set() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_set(&$array, $key, $value)
{
Expand All @@ -283,6 +317,8 @@ function array_set(&$array, $key, $value)
* @param array $array
* @param callable|string|null $callback
* @return array
*
* @deprecated Arr::sort() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_sort($array, $callback = null)
{
Expand All @@ -296,6 +332,8 @@ function array_sort($array, $callback = null)
*
* @param array $array
* @return array
*
* @deprecated Arr::sortRecursive() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_sort_recursive($array)
{
Expand All @@ -310,6 +348,8 @@ function array_sort_recursive($array)
* @param array $array
* @param callable $callback
* @return array
*
* @deprecated Arr::where() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_where($array, callable $callback)
{
Expand All @@ -323,6 +363,8 @@ function array_where($array, callable $callback)
*
* @param mixed $value
* @return array
*
* @deprecated Arr::wrap() should be used directly instead. Will be removed in Laravel 5.9.
*/
function array_wrap($value)
{
Expand Down Expand Up @@ -365,6 +407,8 @@ function blank($value)
*
* @param string $value
* @return string
*
* @deprecated Str::camel() should be used directly instead. Will be removed in Laravel 5.9.
*/
function camel_case($value)
{
Expand Down Expand Up @@ -572,6 +616,8 @@ function e($value, $doubleEncode = true)
* @param string $haystack
* @param string|array $needles
* @return bool
*
* @deprecated Str::endsWith() should be used directly instead. Will be removed in Laravel 5.9.
*/
function ends_with($haystack, $needles)
{
Expand Down Expand Up @@ -650,6 +696,8 @@ function head($array)
*
* @param string $value
* @return string
*
* @deprecated Str::kebab() should be used directly instead. Will be removed in Laravel 5.9.
*/
function kebab_case($value)
{
Expand Down Expand Up @@ -778,6 +826,8 @@ function retry($times, callable $callback, $sleep = 0)
* @param string $value
* @param string $delimiter
* @return string
*
* @deprecated Str::snake() should be used directly instead. Will be removed in Laravel 5.9.
*/
function snake_case($value, $delimiter = '_')
{
Expand All @@ -792,6 +842,8 @@ function snake_case($value, $delimiter = '_')
* @param string $haystack
* @param string|array $needles
* @return bool
*
* @deprecated Str::startsWith() should be used directly instead. Will be removed in Laravel 5.9.
*/
function starts_with($haystack, $needles)
{
Expand All @@ -806,6 +858,8 @@ function starts_with($haystack, $needles)
* @param string $subject
* @param string $search
* @return string
*
* @deprecated Str::after() should be used directly instead. Will be removed in Laravel 5.9.
*/
function str_after($subject, $search)
{
Expand All @@ -820,6 +874,8 @@ function str_after($subject, $search)
* @param string $subject
* @param string $search
* @return string
*
* @deprecated Str::before() should be used directly instead. Will be removed in Laravel 5.9.
*/
function str_before($subject, $search)
{
Expand All @@ -834,6 +890,8 @@ function str_before($subject, $search)
* @param string $haystack
* @param string|array $needles
* @return bool
*
* @deprecated Str::contains() should be used directly instead. Will be removed in Laravel 5.9.
*/
function str_contains($haystack, $needles)
{
Expand All @@ -848,6 +906,8 @@ function str_contains($haystack, $needles)
* @param string $value
* @param string $cap
* @return string
*
* @deprecated Str::finish() should be used directly instead. Will be removed in Laravel 5.9.
*/
function str_finish($value, $cap)
{
Expand All @@ -862,6 +922,8 @@ function str_finish($value, $cap)
* @param string|array $pattern
* @param string $value
* @return bool
*
* @deprecated Str::is() should be used directly instead. Will be removed in Laravel 5.9.
*/
function str_is($pattern, $value)
{
Expand All @@ -877,6 +939,8 @@ function str_is($pattern, $value)
* @param int $limit
* @param string $end
* @return string
*
* @deprecated Str::limit() should be used directly instead. Will be removed in Laravel 5.9.
*/
function str_limit($value, $limit = 100, $end = '...')
{
Expand All @@ -891,6 +955,8 @@ function str_limit($value, $limit = 100, $end = '...')
* @param string $value
* @param int $count
* @return string
*
* @deprecated Str::plural() should be used directly instead. Will be removed in Laravel 5.9.
*/
function str_plural($value, $count = 2)
{
Expand All @@ -906,6 +972,8 @@ function str_plural($value, $count = 2)
* @return string
*
* @throws \RuntimeException
*
* @deprecated Str::random() should be used directly instead. Will be removed in Laravel 5.9.
*/
function str_random($length = 16)
{
Expand All @@ -921,6 +989,8 @@ function str_random($length = 16)
* @param array $replace
* @param string $subject
* @return string
*
* @deprecated Str::replaceArray() should be used directly instead. Will be removed in Laravel 5.9.
*/
function str_replace_array($search, array $replace, $subject)
{
Expand All @@ -936,6 +1006,8 @@ function str_replace_array($search, array $replace, $subject)
* @param string $replace
* @param string $subject
* @return string
*
* @deprecated Str::replaceFirst() should be used directly instead. Will be removed in Laravel 5.9.
*/
function str_replace_first($search, $replace, $subject)
{
Expand All @@ -951,6 +1023,8 @@ function str_replace_first($search, $replace, $subject)
* @param string $replace
* @param string $subject
* @return string
*
* @deprecated Str::replaceLast() should be used directly instead. Will be removed in Laravel 5.9.
*/
function str_replace_last($search, $replace, $subject)
{
Expand All @@ -964,6 +1038,8 @@ function str_replace_last($search, $replace, $subject)
*
* @param string $value
* @return string
*
* @deprecated Str::singular() should be used directly instead. Will be removed in Laravel 5.9.
*/
function str_singular($value)
{
Expand All @@ -979,6 +1055,8 @@ function str_singular($value)
* @param string $separator
* @param string $language
* @return string
*
* @deprecated Str::slug() should be used directly instead. Will be removed in Laravel 5.9.
*/
function str_slug($title, $separator = '-', $language = 'en')
{
Expand All @@ -993,6 +1071,8 @@ function str_slug($title, $separator = '-', $language = 'en')
* @param string $value
* @param string $prefix
* @return string
*
* @deprecated Str::start() should be used directly instead. Will be removed in Laravel 5.9.
*/
function str_start($value, $prefix)
{
Expand All @@ -1006,6 +1086,8 @@ function str_start($value, $prefix)
*
* @param string $value
* @return string
*
* @deprecated Str::studly() should be used directly instead. Will be removed in Laravel 5.9.
*/
function studly_case($value)
{
Expand Down Expand Up @@ -1080,6 +1162,8 @@ function throw_unless($condition, $exception, ...$parameters)
*
* @param string $value
* @return string
*
* @deprecated Str::title() should be used directly instead. Will be removed in Laravel 5.9.
*/
function title_case($value)
{
Expand Down
Loading