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

fix #210 by including psalm-* annotations to ArrayCollection#map() #211

Merged
merged 1 commit into from
Oct 28, 2019

Conversation

someniatko
Copy link
Contributor

@someniatko someniatko commented Oct 28, 2019

Apparently, psalm cannot reuse @psalm-template from parent's method declaration using @inheritdoc, so we cannot just specify @psalm-return static<TKey, U>.

Fixes #210

@someniatko someniatko force-pushed the fix-psalm-arraycollection-map branch from 8e9d759 to 763af60 Compare October 28, 2019 07:51
@someniatko someniatko changed the title fix #200 by including psalm-* annotations to ArrayCollection#map() fix #210 by including psalm-* annotations to ArrayCollection#map() Oct 28, 2019
@Ocramius
Copy link
Member

Ocramius commented Oct 28, 2019

@muglug can I please get your opinion, before we go ahead and repeat docblocks in inheritance trees?

@muglug
Copy link
Contributor

muglug commented Oct 28, 2019

Looks good to me!

@muglug
Copy link
Contributor

muglug commented Oct 28, 2019

Psalm sees @return static and that always takes precedence over something inherited. This PR will fix the return type.

@Ocramius Ocramius self-assigned this Oct 28, 2019
@Ocramius Ocramius added this to the 1.6.2 milestone Oct 28, 2019
@Ocramius Ocramius added Bug and removed Enhancement labels Oct 28, 2019
@Ocramius Ocramius merged commit 09deece into doctrine:1.6 Oct 28, 2019
@Ocramius
Copy link
Member

Thanks @someniatko!

@Ocramius Ocramius modified the milestones: 1.6.2, 1.6.3 Oct 28, 2019
@someniatko someniatko deleted the fix-psalm-arraycollection-map branch October 28, 2019 14:18
@someniatko
Copy link
Contributor Author

someniatko commented Nov 11, 2019

@muglug @Ocramius I have no idea why, but this issue still reproduces itself on https://github.com/someniatko/doctrine-collections-map-psalm

I found out that if in

    /**
     * @return static
     *
     * @psalm-template U
     * @psalm-param Closure(T=):U $func
     * @psalm-return static<TKey, U>
     */
    public function map(Closure $func)

I replace static with ArrayCollection in psalm-return annotation, psalm does no longer find errors.
I believe this is a bug in psalm.

psalm 3.6.4
doctrine/collections 1.6.3

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

Successfully merging this pull request may close these issues.

3 participants