laravel-debugbar icon indicating copy to clipboard operation
laravel-debugbar copied to clipboard

PHP8.2 explode(): Passing null to parameter #2 ($string) of type string is deprecated

Open grasebit opened this issue 4 months ago • 2 comments

Hi.

  1. deprecated by PHP8.2
    • local.WARNING: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /*/vendor/barryvdh/laravel-debugbar/src/LaravelDebugbar.php
  2. use PHP-CS-Fixer (LaravelPint) to config/debugbar.php

grasebit avatar Feb 24 '24 03:02 grasebit

Can confirm the issue, even with an identical config file as in the repo.

// returns `null`
$this->app['config']->get('debugbar.remote_sites_path')

// returns `null`
$this->app['config']->get('debugbar.remote_sites_path', '')

// returns null 🤷‍♂️
$this->app['config']->get('debugbar.remote_sites_path', 'uhmmm')

It should fall back to the second parameter, but for some reason it doesn't and you get the deprecation warning in the log.

sebastiaanluca avatar Feb 24 '24 20:02 sebastiaanluca

env() function returns the value if the key exists.

// config/debugbar.php
'remote_sites_path' => env('DEBUGBAR_REMOTE_SITES_PATH')
// remote_sites_path is null

// src/LaravelDebugbar.php
$foo = $this->app['config']->get('debugbar.remote_sites_path', '');
// $foo is null

$bar = $this->app['config']->get('debugbar.remote_sites_path') ?? '';
// $bar is empty string
// config/debugbar.php
'remote_sites_path' => env('DEBUGBAR_REMOTE_SITES_PATH', '')
// remote_sites_path is empty string

// src/LaravelDebugbar.php
$foo = $this->app['config']->get('debugbar.remote_sites_path', '');
// $foo is empty string

$bar = $this->app['config']->get('debugbar.remote_sites_path') ?? '';
// $bar is empty string
// config/debugbar.php
// 'remote_sites_path' => env('DEBUGBAR_REMOTE_SITES_PATH') comment out

// src/LaravelDebugbar.php
$foo = $this->app['config']->get('debugbar.remote_sites_path', '');
// $foo is empty string

$bar = $this->app['config']->get('debugbar.remote_sites_path') ?? '';
// $bar is empty string

grasebit avatar Feb 25 '24 01:02 grasebit