Remove laravel/helpers dependency
The laravel/helpers
package is described to "provide a backwards compatibility layer for Laravel 5.8 helpers in the latest Laravel release."
Along the years some of the functions defined in that package were added as native PHP functions, with different implementations.
Some examples are:
-
str_contains()
- Added in PHP 8.0
- Its
$needle
argument only supports?string
, whilelaravel/helpers
's supports an array
-
array_first()
- To be added in PHP 8.5
- Laravel recently moved to use it in several places, through the
symfony/polyfill-php85
package - PHP's native implementation only takes one argument, while
laravel/helpers
's takes 3
array_last()
- Same remarks as
array_first()
The only helper from the laravel/helpers
package still use by this package was str_start
.
But for packages requiring this package, they implicitly require the laravel/helpers
package, and if it gets loaded before symfony/polyfill-php85
their implementation gets precedence.
And then, an infinite loop is triggered when calling one of the aforementioned helpers.
For example, laravel/helpers
's array_last
helper, just calls Arr::last()
(from ìlluminate/support
), and that was recently changed to use the native array_last
function.
Starting on PHP 8.5, that would be fine, but by now, it creates an infinite loop as the laravel/helpers
's version is loaded first.
This MR
- Replaces the
laravel/helpers
dependency byìlluminate/support
which was already implicitly required by the former - Changes the
Message::mentions()
method to use theStr::start()
method from theIlluminate\Support\Str
class, instead of thestr_start()
helper from thelaravel/helpers
package