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

ADT / tagged union emulation? #8340

Closed
someniatko opened this issue Jul 29, 2022 · 5 comments
Closed

ADT / tagged union emulation? #8340

someniatko opened this issue Jul 29, 2022 · 5 comments

Comments

@someniatko
Copy link
Contributor

I'd like to mark somehow that my abstract class, or an interface, has only a restricted set of available extenders / implementers.

This can also be achieved on a language level by further extension of the enum concept as Larry Garfield planned. Also, another option is to use a union type, but it's too cumbersome to type each time.

@psalm-github-bot
Copy link

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

@AndrolGenhald
Copy link
Collaborator

Also, another option is to use a union type, but it's too cumbersome to type each time.

We have type aliases for that, though admittedly they could use some improvement.

I swear this has come up before, but I can't find anything right now.

@ZebulanStanphill
Copy link
Contributor

DaveLiddament/php-language-extensions has an attribute called Sealed for this purpose. Sadly, there's no Psalm extension for this package yet (only a PHPStan one), but one for Psalm is planned.

@klimick
Copy link
Contributor

klimick commented Aug 6, 2022

See #1450

@someniatko
Copy link
Contributor Author

Oh, thank you, that's a duplicate then!

@someniatko someniatko closed this as not planned Won't fix, can't repro, duplicate, stale Aug 7, 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

4 participants