-
Notifications
You must be signed in to change notification settings - Fork 11.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Illuminate\Support\Str::contains crashes on php 8.0.1 #35891
Comments
Can fix. |
If you want to submit a PR feel free but the doc block already says you should only pass a string. I'm not sure there is anything broken here. |
The Request checks in the
So i am forced to send a content-type header with every request? |
No. The isJson method needs updating to check if the header is actually set. Please send a PR to fix that. |
On a clean Laravel installation with just this route on its <?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
Route::get('/', function (Request $request) {
return ($request->isJson() ? 'yes' : 'no') . ' / ' . PHP_VERSION;
}); If I run $ curl http://127.0.0.1:8000/api
no / 8.0.1 No errors are logged. Your issue must be happening somewhere else. |
Same error here !
|
@AEK-BKF are you setting |
@rodrigopedra |
Oh, so this is a bug in the symfony polyfill? |
Description:
The string support method
contains
throws an exception when $haystack is not a string.Example:
Running any request that interacts with the
InteractsWithContentTypes
trait and uses theisJson
method crashes. Make sure to send the request without a content-type header, this causes the $haystack variable to be null and throws an exception.Php 8.0.0 and older always returned
false
Php 8.0.1 throws an exception
Steps To Reproduce:
Install the above php version and laravel version. Request an API without a content-type header. Response should be a 500 server error.
The following code is what crashes.
Exception:
Uncaught TypeError: mb_strpos(): Argument #1 ($haystack) must be of type string, null given
The contains method should either type-hint a string or internally check if its a string.
The text was updated successfully, but these errors were encountered: