The dependency for Symfony debug recently made a change that causes problem to laravel.
str_contains function is been added in PHP v8 and Symfony added polyfill v8 dependency in recent update ..but the signature is not same in laravel and if you have str_contains() with one parameter null then an error is thrown
TypeError: Argument 1 passed to str_contains() must be of the type string, null given
This causes a lot of our tests failing and not only...
If you replace the dependency symfony/polyfill-php80 in your composer.json then update fails
` Uncaught Error: Call to undefined function SymfonyComponentDebugExceptionget_debug_type() in vendorsymfonydebugExceptionFatalThrowableError.php:29
Stack trace:
`
Use in some code or in example test the str_contains with 1 parameter null...
Run the test...
Which Symfony version are you using?
Which Symfony version are you using?
I dont specify in composer.json...This version gets installed with laravel...
"symfony/debug": "4.4.9"
But now I had downgrade to 4.4.8 to prevent issues...
I still don't really understand what's happening here. I don't see any mention of str_contains in that diff and we don't use str_contains anywhere in the framework. Nor do we use symfony/polyfill-php80. Can you post some more concrete steps to reproduce?
Ah, nvm you're referring to the helpers package I see. Unfortunately these indeed collide. I'll try to look into a solution to prevent it from being registered when you're on PHP 8.
I still don't really understand what's happening here. I don't see any mention of
str_containsin that diff and we don't usestr_containsanywhere in the framework. Nor do we usesymfony/polyfill-php80. Can you post some more concrete steps to reproduce?
The problem is the replacement of get_class with get_debug_type that exists only in php v8 and in symphony/polyfill-php80
str_contains is added in symphony/polyfill-php80 and conflicts in signature with laravel`s version, it has strict parameters...
Yes i am refering to helper package...i forgot that now are separated... Old laravel user :P hehe
I just realized that there's nothing much we can do here. Since the symfony polyfill package gets loaded first it'll first register its str_contains function. You'll have to choose between the helpers package and the symfony one if you want to use str_contains.
The actual solution to your problem btw is to typecast to a string before attempting to use the function. The type error only happens because you're passing in null. Besides the fact that the newer PHP 8 function doesn't handles multiple needles they should be complementary.
As stated here, while providing the proper type is the right solution, using Str::contains might be helpful in the meantime.
Note str_contains is deprecated...
@lcharette you're looking at 5.8. All helpers got extracted out of the framework in 6.0
@mariosvasiliou note that get_debug_type() doesn't live in Symfony\Component\Debug\Exception namespace, meaning it looks like it wasn't loaded maybe?
Is there a version I can freeze this package at to prevent this collision?
Is there a version I can freeze this package at to prevent this collision?
yes i have set those to prevent issue
"symfony/debug": "4.4.8",
"symfony/options-resolver": "5.0.9"
This problem occurs too with older versions of laravel. We are working on porting over an L4 version to latest and can't even get the vagrant dev boxes working right because of this.
Workaround is to forbid symfony/polyfill-php80 installation in composer.json
"conflict": {
"symfony/polyfill-php80": "*"
}
Workaround is to forbid symfony/polyfill-php80 installation in composer.json
"conflict": { "symfony/polyfill-php80": "*" }
I perfectly works with this str_contains conflict
Wow, I just had this problem and the solution by @grray worked.
I am on laravel 5.7. error still occurred. So I followed @ driesvints and @ lcharette suggestions. Updated my str_contains() methods(only the ones which were passing needles as an array) to use Str::contains() instead
Most helpful comment
Workaround is to forbid symfony/polyfill-php80 installation in composer.json