Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options stub doesn't work as expected #322

Open
VincentLanglet opened this issue Jan 9, 2023 · 2 comments
Open

Options stub doesn't work as expected #322

VincentLanglet opened this issue Jan 9, 2023 · 2 comments

Comments

@VincentLanglet
Copy link
Contributor

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 ?

@VincentLanglet
Copy link
Contributor Author

VincentLanglet commented Feb 11, 2023

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 ?

@VincentLanglet
Copy link
Contributor Author

@alexander-schranz Does the Options stub works for you ?

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

No branches or pull requests

1 participant