Hi,
I encountered a problem of my library with the new class constant
visibility functionality.
The problem is that I'm using ReflectionClass::getConstants() to detect
class constants but I'm only interested in public constants.
Before class constants were public by definition but now it can be
private and protected, too.
I know the new methods ReflectionClass::getReflectionConstants are
available to detect exactly what I need and that's fine!
But of course using ReflectionClass::getConstants() no longer returns
public class constants by default.
So for me this is a BC break but it wasn't listed in the RFC.
I don't know if it was discussed before but it could be avoided by
adding an argument to ReflectionClass::getConstants() to filter by
visibility which defaults to public.
Thoughts?
PS: I'm talking my library to emulate enumerations
https://github.com/marc-mabe/php-enum/blob/master/src/Enum.php#L295-L327
but this BC break happens to all using ReflectionClass::getConstants()
for public constants only e.g. accessing values later with constant()
.
Cheers
Marc
Hi Marc
So for me this is a BC break
So that we're clear about what we're discussing, please can you post
some example code that:
i) Works in PHP 7.0.x
ii) Won't work in PHP 7.1.x
cheers
Dan