Options stub doesn't work as expected
VincentLanglet opened this issue · 2 comments
Related to phpstan/phpstan#7650
and PR #294
cc @alexander-schranz and @ondrejmirtes
I saw the following example https://phpstan.org/r/95a7bcea-3198-4297-8770-823861adacfb
(btw now it's full of error: https://phpstan.org/r/339c6e0b-c988-4a01-b203-1047ec4f71ee)
I wrote the following code
/**
* @param Options<array{
* page: PageInterface|null,
* site: SiteInterface|null,
* choice_translation_domain: bool,
* filter_choice: array{current_page: false, request_method: string, dynamic: bool, hierarchy: string},
* }> $options
*
* @return array<PageInterface>
*/
private function getChoices(Options $options): array
{
\PHPStan\dumpType($options['site']);
And I'm getting
Dumped type: array{current_page: false, request_method: string, dynamic: bool, hierarchy:
string}|bool|Sonata\PageBundle\Model\PageInterface|Sonata\PageBundle\Model\SiteInterface|null
But I cannot reproduce the issue in the phpstan reproducer.
If you look at this PR: sonata-project/SonataPageBundle#1654,
you'll see that
- When using the Options from Symfony, I get the wrong inference.
- When using my Options, it works fine.
Am I missing something ?
I think it's related to phpstan/phpstan#8549
Since the example given https://phpstan.org/r/95a7bcea-3198-4297-8770-823861adacfb
is now throwing errors: https://phpstan.org/r/c121a4ee-398d-4fa5-88d9-313f2d21d04c
@ondrejmirtes Until the bug is fixed shouldn't the stub be disabled ?
Or at least is there a way to keep this line https://github.com/phpstan/phpstan-symfony/blob/1.2.x/extension.neon#L16
with bleedingEdge ?
@alexander-schranz Does the Options stub works for you ?