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

Known properties on implicit enum interfaces #7364

Closed
Tracked by #6425
weirdan opened this issue Jan 10, 2022 · 2 comments
Closed
Tracked by #6425

Known properties on implicit enum interfaces #7364

weirdan opened this issue Jan 10, 2022 · 2 comments

Comments

@weirdan
Copy link
Collaborator

weirdan commented Jan 10, 2022

Hm, my bad, looked into wrong stubs. So only this one should not give any error https://psalm.dev/r/461a456ffb?php=8.1 .

Originally posted by @simPod in #6425 (comment)

Also, UnitEnum has $name: https://psalm.dev/r/aa5cf3a7ed?php=8.1

@psalm-github-bot
Copy link

psalm-github-bot bot commented Jan 10, 2022

I found these snippets:

https://psalm.dev/r/461a456ffb
<?php

function value(BackedEnum $e): int|string {
    return $e->value;
}

function name(BackedEnum $e): string {
    return $e->name;
}
Psalm output (using commit 206332b):

ERROR: NoInterfaceProperties - 4:12 - Interfaces cannot have properties

ERROR: NoInterfaceProperties - 8:12 - Interfaces cannot have properties

INFO: MixedReturnStatement - 8:12 - Could not infer a return type

INFO: MixedInferredReturnType - 7:31 - Could not verify return type 'string' for name
https://psalm.dev/r/aa5cf3a7ed
<?php
function f(UnitEnum $e): void {
    echo $e->name;
}
Psalm output (using commit 206332b):

ERROR: NoInterfaceProperties - 3:10 - Interfaces cannot have properties

@weirdan
Copy link
Collaborator Author

weirdan commented Jan 24, 2022

Fixed in #7467

@weirdan weirdan closed this as completed Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant