Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/State/ProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
/**
* Provides data.
*
* @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

*
* @return T|PartialPaginatorInterface<T>|iterable<T>|null
*/
public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null;

Check failure on line 37 in src/State/ProviderInterface.php

View workflow job for this annotation

GitHub Actions / PHPStan (PHP 8.4)

PHPDoc tag @param has invalid value (array{request?: Request, resource_class?: string, ...array<string, mixed>} $context): Unexpected token "array", expected '}' at offset 204
}
Loading