php-cors icon indicating copy to clipboard operation
php-cors copied to clipboard

fix #11 pass empty string to strpos() instead of null

Open gigerIT opened this issue 3 years ago • 2 comments

Fixes: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in vendor/fruitcake/php-cors/src/CorsService.php on line 108

gigerIT avatar May 23 '22 06:05 gigerIT

How does your config look like? An array with an explicit null value?

barryvdh avatar May 23 '22 17:05 barryvdh

Yes we have some entries that are only applied when the app/env is in debug mode.

'allowed_origins' => ['prod.domain.com', config('app.debug') ? '*.pages.dev' : null],

I guess we also could use '' instead of null.

gigerIT avatar May 23 '22 18:05 gigerIT

I'm inclined to think you shouldn't pass a null version.

barryvdh avatar Feb 21 '23 07:02 barryvdh

You can keep the null and wrap the whole [] in array_filter()

mfn avatar Feb 21 '23 07:02 mfn