I have written a PHP library using the PHP 8.0 readonly
keyword and then I realised that it would be good to support earlier versions of PHP such as 7.4.
I could easily remove the readonly
keywords from my code but I don't want to do that -- they were put there for a reason!
Having a C background, I immediately thought of macros but PHP doesn't seem to have any. I've googled this answer for adding macro-like behaviour to PHP, but it looks like an overkill. And it's just for one file, and my library has 26 files at present.
Is there an easy way to make PHP 7.4 just ignore the readonly
keyword and make my code cross-version? Something to the effect of this C code?
#if PHP_VERSION < 8
#define readonly /**/
#enif
Perphaps some composer
build option that can pre-process files before packaging them up?