-
Notifications
You must be signed in to change notification settings - Fork 27
Closed
Description
A nested array like:
/**
* @param mixed[] $requestData
*
* @return array{
* accountId: int,
* errorColor: string|null,
* theme: array{
* backgroundColor: string|null,
* textColor: string|null,
* headerImage: array{id: int}|null,
* },
* }
*/
https://phpstan.org/r/652f74f8-c926-4802-99b9-bab73da329dd
As requested the none webmozart assert implementation: https://phpstan.org/r/f535c1bb-82e3-4e49-a1d6-ee31c25339fe / https://phpstan.org/r/371acae7-1694-46bc-9d4e-2aa2c653134e (more dumps)
Is not possible to be validated as it seems to lost type after:
Assert::keyExists($requestData['theme'], 'headerImage');
Assert::nullOrIsArray($requestData['theme']['headerImage']);
\Phpstan\dumpType($requestData);
\Phpstan\dumpType($requestData['theme']);
\Phpstan\dumpType($requestData['theme']['headerImage']);
4 Dumped type: array&hasOffset('errorColor')&hasOffset('theme')
5 Dumped type: mixed
6 Dumped type: mixed
Not sure if this is even possible. I see the complexness and also know that my solution is not the best. And should maybe go with json validation or something like that instead of validating array manually. Still I thought about reporting it.
PS: any possibility to enable Webmozart/Assert
on https://phpstan.org/ ?
Metadata
Metadata
Assignees
Labels
No labels