On Wed, Jun 15, 2022 at 6:59 PM Ilija Tovilo <tovilo.il...@gmail.com> wrote:
> Hi > > > Just a question. > > Would this also be allowed? > > > > https://3v4l.org/RGdIA > > <?php > > > > class A {public int $i = 42;} > > const BARE_CONSTANT = new A; > > class B { > > const ClassConstant = BARE_CONSTANT; > > } > > class C { > > const ClassConstantViaPropertyFetching1 = BARE_CONSTANT->i; > > const ClassConstantViaPropertyFetching2 = B::ClassConstant->i; > > } > > Yes, that would work fine. > > Ilija > > Hey, sorry to bump here on this topic. My assumption was that the use of `->` in initializers would bear the same limitations as using `new`. That would mean it would not be supported for - class constant initializers - instance property initializers - static property initializers For `new` clarifications are here: https://wiki.php.net/rfc/new_in_initializers#unsupported_positions My assumption is that `->` would only work for: - static variable initializers - global constant initializers - parameter default values - attribute arguments The examples shared by Shinji are for class constant initializers in class C and I'm guessing it would not work. If that's the case, I think we should clarify this in the RFC as well. Regards, Alex