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

[PHP 8.1] Add Dummy class to ENUM migration #5395

Closed
2 tasks done
TomasVotruba opened this issue Jan 31, 2021 · 5 comments
Closed
2 tasks done

[PHP 8.1] Add Dummy class to ENUM migration #5395

TomasVotruba opened this issue Jan 31, 2021 · 5 comments
Labels

Comments

@TomasVotruba
Copy link
Member

TomasVotruba commented Jan 31, 2021

Todo

Most used packages in PHP userland

Asked: https://twitter.com/rectorphp/status/1388876287477944325

@TomasVotruba
Copy link
Member Author

Ref nikic/PHP-Parser#758

@TomasVotruba
Copy link
Member Author

Not priority ATM, this might take a while to merge in php-parser

@TomasVotruba
Copy link
Member Author

TomasVotruba commented May 1, 2021

The nikic/PHP-Parser#758 got merged ✔️

@aLmonndo
Copy link

aLmonndo commented May 6, 2021

Quote from "Tomasz Kowalczyk" on LinkedIn:

"Platenum: https://github.com/thunderer/Platenum. I analyzed many popular enum libraries on Packagist with a detailed benchmark here: https://github.com/thunderer/PhpEnumerations. There was no single library that provided desired guarantees (truly single instance, strict equality, etc.) and complete feature set, that's why I wrote one which does."

Quote from "Petru Szemereczki" on FB:

"this one got mentioned in symfony's issue tracking: Elao/PhpEnums#124
in package's readme they mention other 3 libs
but mostly, my "enum" are only plain php class / interface that has public const with either UPPERCASE_SNAKE or (since 8.1 enum rfc) UpperCamelCase. and in code i reference the actual data type behind an enum (mostly string) and use either JetBrains' ExpectedValues attribute or psalm's @psalm-xxx MyEnum::* (or both).
another personal take would be to have class constants + an constant array of valid values and some static methods that ensures the validity during runtime: https://github.com/hktr92/oopize/blob/master/src/Util/EnumUtil.php?fbclid=IwAR24p3v3HasVOzVN24l2_ucfAbdsCLSBjSK02RWY1qbtcnZxch-UUXwVGd4
it's used mostly by very few projects I've made. the idea was fine back in php 7, but now it doesn't really make any sense to have / use such a library.
i personally won't make such a feature in rector because it's such a wide possibility to exist."

"Quote from "Tobias Pogadl" on FB:

"if you don’t have any yet, think about to skip this for a few months or only choosing one that is compatible with enums in php 8.1"

@TomasVotruba
Copy link
Member Author

Closing as MyClabs looks like only major candidate now and Rector already covers it 👍

TomasVotruba added a commit that referenced this issue Dec 26, 2023
rectorphp/rector-src@9cebe92 [DX] Add RectorConfig::autotagInterfaces() for automated tagging of instances (#5395)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants