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

Enable ClassLikes to properly detect implementing class aliases #6327

Merged
merged 5 commits into from
Aug 17, 2021

Conversation

boesing
Copy link
Contributor

@boesing boesing commented Aug 17, 2021

Fixes #6325

…ases

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
@boesing
Copy link
Contributor Author

boesing commented Aug 17, 2021

Early on, I was thinking if it would be a thing to have class_alias interfaces as part of class_implements as well. So that the map wont just contain the FQCN but also the alias.

So in my example I've created in the unit test:

$classStorage = new ClassLikeStorage('Baz');
$classStorage->class_implements = [
    'bar' => 'Bar',
    'foo' => 'Foo',
];

But this would somehow require psalm to detect class_alias and then iterating over all classes it already infered (and cached) and adding additional details based on all detected class_alias. Not sure if this would be doable and thus, I've added the detection to the ClassLikes logic instead.

src/Psalm/Internal/Codebase/ClassLikes.php Outdated Show resolved Hide resolved
src/Psalm/Internal/Codebase/ClassLikes.php Outdated Show resolved Hide resolved
tests/Internal/Codebase/ClassLikesTest.php Outdated Show resolved Hide resolved
tests/Internal/Codebase/ClassLikesTest.php Outdated Show resolved Hide resolved
tests/Internal/Codebase/ClassLikesTest.php Outdated Show resolved Hide resolved
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
…like_aliases`

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
@boesing boesing requested a review from weirdan August 17, 2021 19:46
@weirdan weirdan merged commit e5b797c into vimeo:master Aug 17, 2021
@weirdan
Copy link
Collaborator

weirdan commented Aug 17, 2021

Thanks!

@boesing boesing deleted the bugfix/class-alias branch August 17, 2021 20:39
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

Successfully merging this pull request may close these issues.

Psalm cannot properly infer interfaces when these are declared via class_alias
2 participants