Crell/AttributeUtils

PHP >8.1 support

Closed this issue · 3 comments

mxr576 commented

I was evaluating this library as a potential building block of a new feature. I had spotted that it only supports PHP 8.1 at this moment, which I considered a warning sign for us - even though I like explicit PHP version support in packages - but I could live with this for now...

However when I used my attribute like #[Foo(Bar::BAZ->value)] I immediately got a Enum field reference in constant expression is allowed only from PHP 8.2 warning from PHPStorm, which means we may need to leverage PHP 8.2 language features sooner than I expected, or I have to avoid usage constants and go with "magic strings" here and there.

So are there any plans for flagging PHP 8.2 (and PHP 8.3) support in this package and if yes, what is the expected timeline?

mxr576 commented

NVM, it is "php": "~8.1", and not "php": "~8.1.0", 🤦

Crell commented

Currently tests are running on 8.1, 8.2, and 8.3, so I'm quite confident that it works correctly in 8.2+. 😄 cf: https://github.com/Crell/AttributeUtils/blob/master/.github/workflows/quality-assurance.yaml#L14

Though I would recommend against pulling the value off the enum in an attribute like that. Why not just pass the enum as is and be done with it? I'm doing that myself in Crell/Serde.

Also note that Enum cases should be CamelCase, not ALLCAPS, per PER-CS 2.0.

mxr576 commented

Though I would recommend against pulling the value off the enum in an attribute like that. Why not just pass the enum as is and be done with it? I'm doing that myself in Crell/Serde.
Also note that Enum cases should be CamelCase, not ALLCAPS, per PER-CS 2.0.

Yep that was just a lazy example :)

As you can see, the end of yesterday was not my brightest moment :D