laruence ยท GitHub

Hi!

@Majkl578

Also, there seems to be a conflict in trait resolution for constants and methods with same name (based on an example from http://news.php.net/php.internals/88906). What will this code do?

First of all: currently, traits cannot have constants so the problem doesn't even exists https://3v4l.org/gCvYH.

Even if we add constants to traits one day (and I hope this day never comes), we could have:

trait TestTrait {
    const foo = 'const';
    function foo() { echo 'method'; }
}
class TestClass {
    use TestTrait {
        const foo as bar;
        foo as bar;
    }
}

I don't see any issue here ๐Ÿ˜‰

Regarding the Reflection API break, @nikic proposed an alternative. Instead of changing the return values of existing methods, we could just include ReflectionClass::getReflectionConstants() and ReflectionClass::getReflectionConstant($constant_name).

Seems reasonable, even though I prefer the BC break.

Read the original on github.com โ†—