Class Constant Visibility BC Break

From: Date: Sun, 21 Aug 2016 20:57:30 +0000
Subject: Class Constant Visibility BC Break
Groups: php.internals 
Request: Send a blank email to internals+get-95357@lists.php.net to get a copy of this message
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::getReflectionConstant[s]() 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

« previous php.internals (#95357) next »