fix: array shape in ProviderInterface#7150
Conversation
With this syntax `request` and `resource_class` can be detected. Otherwise it just becomes an unsealed associative array.
|
needs #7154 |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
| * @param array<string, mixed> $uriVariables | ||
| * @param array<string, mixed>|array{request?: Request, resource_class?: string} $context | ||
| * @param array<string, mixed> $uriVariables | ||
| * @param array{request?: Request, resource_class?: string, ...array<string, mixed>} $context |
There was a problem hiding this comment.
this syntax doesn't work yet? @VincentLanglet any idea how to fix this and #7151
There was a problem hiding this comment.
No unlike psalm, phpstan doesnt work well with sealed/unsealed syntax for array
(There is some issue about it in phpstn repo)
I can take a look how to solve your issue @soyuka but it will be in one week cause i'm in vacation without a computer atm.
There was a problem hiding this comment.
So I fixed the syntax but unfortunately it causes issues because phpstan only added parsing support, it doesn't make use of it yet.
There was a problem hiding this comment.
Yes so maybe (and unfortunately) the solution will be to only use
Array<string, mixed>
Without more precision...
There was a problem hiding this comment.
The two solutions I have in mind @soyuka are:
-
Just using
@param array<string, mixed> $context -
Or Using
@phpstan-param array<string, mixed> $context
@psalm-param array{request?: Request, resource_class?: string, ...array<string, mixed>} $context
What do you prefer ?
There was a problem hiding this comment.
@param array<string, mixed> $context
@psalm-param array{request?: Request, resource_class?: string, ...array<string, mixed>} $context
Does this work?
There was a problem hiding this comment.
Does this work?
Unfortunately phpstan load @psalm-param over @param.
So it's either
@param array<string, mixed> $context
@phpstan-param array<string, mixed> $context
@psalm-param array{request?: Request, resource_class?: string, ...array<string, mixed>} $context
or just
@phpstan-param array<string, mixed> $context
@psalm-param array{request?: Request, resource_class?: string, ...array<string, mixed>} $context
There was a problem hiding this comment.
I'm missing this precision at this moment...
The ...<string, mixed> trick seems supported by phpstan, at least in version 2.1.33 I currently use.
|
It could be good to fix IriConverterInterface and ParameterProviderInterface too. |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
I think this was already solved by #7366 |
With this syntax
requestandresource_classcan be detected. Otherwise it just becomes an unsealed associative array.See phpstan/phpdoc-parser#250 for the syntax. I reported phpstan/phpstan#13019 because the extra keys aren't working as per the PR that added support, but the known keys do.