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

Class extenting stub class is not analyzed #3328

Closed
joehoyle opened this issue May 9, 2020 · 4 comments
Closed

Class extenting stub class is not analyzed #3328

joehoyle opened this issue May 9, 2020 · 4 comments
Labels

Comments

@joehoyle
Copy link
Contributor

joehoyle commented May 9, 2020

When I have a class that extends a class in my stub files, I don't get any analysis or failures on missing types in my subclass. I see Populator could not find dependency (521) when running ./vendor/bin/psalm --debug. I can confirm the stub file is being ingested, because if I remove it, I got an UndefinedClass error.

I uploaded a very simple sample project to https://gist.github.com/joehoyle/203a52d80f21ce56636d45bac81f2b8f, you can clone and test locally with git clone https://gist.github.com/203a52d80f21ce56636d45bac81f2b8f.git

I see #1528 which looks quite related, but then the tests in 39f7296 don't look like they are testing if invalid code shows as failing, when it should, so maybe this isn't be tested for right now.

@psalm-github-bot
Copy link

Hey @joehoyle, can you reproduce the issue on https://psalm.dev ?

@joehoyle
Copy link
Contributor Author

joehoyle commented May 9, 2020

No, this is not reproducible on psalm.dev as there's no way to load Stub files there that I'm aware of.

@weirdan weirdan added the bug label May 9, 2020
joehoyle added a commit to joehoyle/psalm that referenced this issue Jul 8, 2020
Currently project files are scanned before stub files, this means if project files have dependencies on things declared in stubs (such as child classes), analysis essentially fails, as the Populator will bail in `populateDataFromParentClass -> 'Populator could not find dependency ...'`.

I imagine there is some reason behind scanning the project files before the stubs, but I'm not sure what it is. I decided to go ahead and make this change and also add a test demonstrating the problem. without switching the order, the attached test case will not throw any errors (when it should!).

Fixes vimeo#3328.
@orklah
Copy link
Collaborator

orklah commented Oct 11, 2021

Are you sure your stub is self contained? All dependancies of your stubbed class must also be stubbed

EDIT: I could reproduce it indeed

@AndrolGenhald
Copy link
Collaborator

Works with dev-master, probably fixed by #7110.

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 a pull request may close this issue.

4 participants