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

Handle inherited docblock method #7391

Merged
merged 1 commit into from Jan 15, 2022

Conversation

vincent4vx
Copy link
Contributor

See: #7198

In current version, psalm will only search for pseudo methods on current class, so if a docblock method is declared on implemented interface, or parent class, it will be ignored, and infered return type or parameters will be ignored.

This PR will add search of the pseudo method and declaring class on ancestors (interfaces + parents) if not defined on the current class. Static and instance calls are handled.

<?php
/**
 * @method int bar()
 */
class A {}

class B extends A {
    public function __call(string $method, array $args) {}
}

function consumeInt(int $i): void {}

$b = new B();

consumeInt($b->bar());

@orklah
Copy link
Collaborator

orklah commented Jan 14, 2022

Was there a good reason to have the function findPseudoMethodAndClassStorages declared twice? Could we mutualize?

@vincent4vx
Copy link
Contributor Author

Was there a good reason to have the function findPseudoMethodAndClassStorages declared twice? Could we mutualize?

The method declared into AtomicStaticCallAnalyzer reads method storage from pseudo_static_methods, unlike MissingMethodCallHandler which reads from pseudo_methods.

So it may be possible to mutualize, but I don't know if the readability will be better...

@orklah orklah added the release:fix The PR will be included in 'Fixes' section of the release notes label Jan 15, 2022
@orklah orklah merged commit 75947c9 into vimeo:4.x Jan 15, 2022
@orklah
Copy link
Collaborator

orklah commented Jan 15, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:fix The PR will be included in 'Fixes' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants