Skip to content

Conversation

nesl247
Copy link
Contributor

@nesl247 nesl247 commented May 15, 2025

Q A
Branch? 4.1
Tickets N/A
License MIT
Doc PR N/A

With this syntax request and resource_class can 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.

@nesl247 nesl247 marked this pull request as draft May 15, 2025 14:17
@nesl247 nesl247 changed the title fix: #7119 array shape in ProviderInterface fix: array shape in ProviderInterface May 15, 2025
With this syntax `request` and `resource_class` can be detected. Otherwise it just becomes an unsealed associative array.
@nesl247 nesl247 marked this pull request as ready for review May 15, 2025 14:18
@soyuka
Copy link
Member

soyuka commented May 16, 2025

needs #7154

Copy link

stale bot commented Jul 25, 2025

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.

@stale stale bot added the stale label Jul 25, 2025
@stale stale bot removed the stale label Jul 25, 2025
* @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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this syntax doesn't work yet? @VincentLanglet any idea how to fix this and #7151

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I fixed the syntax but unfortunately it causes issues because phpstan only added parsing support, it doesn't make use of it yet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes so maybe (and unfortunately) the solution will be to only use

Array<string, mixed>

Without more precision...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two solutions I have in mind @soyuka are:

  1. Just using @param array<string, mixed> $context

  2. Or Using

@phpstan-param array<string, mixed> $context
@psalm-param array{request?: Request, resource_class?: string, ...array<string, mixed>} $context

What do you prefer ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@param array<string, mixed> $context
@psalm-param array{request?: Request, resource_class?: string, ...array<string, mixed>} $context

Does this work?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@VincentLanglet
Copy link
Contributor

It could be good to fix IriConverterInterface and ParameterProviderInterface too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants