Skip to content

Instantly share code, notes, and snippets.

@mul14
Last active January 4, 2024 12:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mul14/93a3f335a55eca18400ecb88010193eb to your computer and use it in GitHub Desktop.
Save mul14/93a3f335a55eca18400ecb88010193eb to your computer and use it in GitHub Desktop.
Replace Laravel String and Array Helpers to Facade with regex

In Laravel 5.8 string and array helpers will be deprecated, and will removed in Laravel 5.9 https://laravel-news.com/laravel-5-8-deprecates-string-and-array-helpers

In this gist I will show you how to replace string helpers with Facade by using regex.

Replace Array Helpers

Copy this line put into find dialog, enable regex mode.

array_(add|collapse|divide|dot|except|first|flatten|forget|get|has|last|only|pluck|prepend|pull|random|set|sort|sort_recursive|where|wrap)

Replace with Array::$1.

Replace String Helpers

Copy this line put into find dialog, enable regex mode.

str_(after|before|contains|finish|is|limit|plural|random|replace_array|replace_first|replace_last|singular|slug|start)

Replace with Str::$1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment