Propaganistas/Laravel-Phone

strtoupper - null as parameter is deprecated

stanislawduda opened this issue · 2 comments

strtoupper(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/vendor/propaganistas/laravel-phone/src/Traits/ParsesCountries.php on line 39

protected function parseCountries($countries)
    {
        return Collection::make(is_array($countries) ? $countries : func_get_args())
                         ->map(function ($country) {
                             return strtoupper($country);
                         })
                         ->filter(function ($value) {
                             return static::isValidCountryCode($value);
                         })->toArray();
    }

@Propaganistas I just ran into this issue as well. What was the resolution? I encountered this on upgrading to PHP 8.1, doing a fairly straightforward validation: 'phone' => 'nullable:email|phone:AUTO,US,mobile'. Are you saying this is not a bug in the package?

Edit: parseCountries was getting called twice, the first time with ['auto', 'us', 'mobile'] and the second time with [null]. Removing AUTO let the validation pass, but it was still called twice, this time the second time it was called with ['us']. I'm not sure why.

Fixed. Thank you for providing additional details.