-
Notifications
You must be signed in to change notification settings - Fork 72
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
How to Supress PossiblyInvalidArgument for Request Objects? #7
Comments
You'll want to use |
But really the plugin should be able to interpret the rules in a given class. |
That could get tricky as Laravel supports custom rules and require_if / require_with, etc. Maybe limit to support only the basic rules might be a sane option. |
@deleugpn I'm wondering if you still have this issue? If so, I would recommend checking if you could declare your request attributes as <?php
namespace App\Modules\Accounts\Requests;
use App\Http\Requests\FormRequest;
/**
* @property string|null $name
* @property string $email
*/
class SaveAccountRequest extends FormRequest
{
public function rules()
{
return [
'name' => 'string|max:128',
'email' => 'required|string|email',
];
}
} PS: Make sure to enable |
I gave up on using Psalm, sorry. |
I'm sorry to hear that, but maybe you might want to give it another try in about one month? These days, I have resolved a couple of annoying issues, and I'm committed to fixing any other issues you will have. |
Laravel has Form Request classes that can look like the following:
The
input()
method has a return signature declared as* @return string|array|null
. For that reason, Psalm end up givingPossiblyInvalidArgument [...] possibly different type array<array-key, mixed>|string|null provided
.I tried the following:
but that configuration leads to
What can I do to suppress this problem but only for Request objects or for any interaction with the
input
method of a Form Request class?The text was updated successfully, but these errors were encountered: