dshafik / bag

Immutable Value Objects for PHP
https://bagvalueobjects.com/
MIT License
70 stars 6 forks source link

feat: support PHP 8.2 #6

Closed elazar closed 5 months ago

elazar commented 5 months ago

It's not currently possible to use this library with PHP < 8.3. While upgrading to PHP 8.3 is the obvious desirable solution, it's not an immediately available or feasible option for many PHP developers.

It would be nice to be able to use this library through PHP 8.2's official end-of-life: active support will continue through 8 Dec 2024 (a bit over 6 months from the date of this writing) and security support for another year after that.

It appears that supporting PHP 8.2 is currently possible with one small change (included in this PR) to code that causes a syntax error under PHP < 8.3. It's worth noting that the affected line does not presently appear to have all branches or paths covered by tests. However, with the change, all existing tests pass under PHP 8.2. If I understand the function of the affected line correctly, using constant() is an equivalent backward-compatible way of producing the same behavior.

dshafik commented 5 months ago

Thanks for this!