Strange Behavior In Laravel 7.2 Illuminate\Foundation\Http\FormRequest

- 1 answer

I have a project with a fairly standard Dev-on-Homestead to Staging to Production workflow. All are using Laravel 7.2.2/Ubuntu 18.04/PHP 7.4.3

This cropped up today with some form requests.

Type of App\Http\Requests\CreateHighlight::$errorBag must be string (as in class Illuminate\Foundation\Http\FormRequest)

This is a named $errorBag that we've been using since 5.4 or so?

I changed the $errorBag to protected string $errorBag='highlightCreate'; and proceeded to test and deploy.

That same code kicked this back from the staging error logs:

staging.ERROR: Type of App\Http\Requests\CreateHighlight::$errorBag must not be defined (as in class Illuminate\Foundation\Http\FormRequest)

I have checked and rechecked and checked a fourth, fifth, sixth time. Everything appears to be identical between the two environments, yet I cannot for the life of me understand why this is happening. They're the same error except they're contradicting each other.



Based on FormRequest it clearly seems like errorBag is not defined as a string. This clearly seems like it is something with your local file there is wrong. Never the less the errorBag should not be defined as a string.