-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Closed
Description
- Laravel Version: 8.21.0 (latest)
- PHP Version: 8.0.0
- Database Driver & Version: MySQL 5.7
Description:
When using the 'JSON' rule validation in PHP 8, you will get a TypeError when submitting an empty field:
method_exists(): Argument #1 ($object_or_class) must be of type object|string, null given
in vendor/laravel/framework/src/Illuminate/Validation/Concerns/ValidatesAttributes.php:1149
According to php.watch:
Union types are used when they are deemed necessary. For example, method_exists()
function accepts either a class name (string
) or an object (object
). This is enforced as a Union Type of string|object
. [...] Prior to PHP 8, it returned false if the provided parameter is not a string or an object, but did not raise any warnings.
Steps To Reproduce:
- Create a form with an input field that contains no value (
hidden
in my case). - Add a json rule for this field (
json|required
in my case). - Submit the form.
The website will returnmethod_exists(): Argument #1 ($object_or_class) must be of type object|string, null given
Metadata
Metadata
Assignees
Labels
No labels