Re: Trait constants

From: Date: Wed, 12 May 2021 09:38:16 +0000
Subject: Re: Trait constants
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-114431@lists.php.net to get a copy of this message
On Sun, Jun 28, 2020 at 2:34 PM Nikita Popov <nikita.ppv@gmail.com> wrote: > On Sat, Jun 27, 2020 at 3:53 PM Stephen Reay <php-lists@koalephant.com> > wrote: > > > Hi, > > > > It’s always struck me as slightly odd that traits don’t support constants > > the way classes and interfaces do. > > I tried to find an explanation of the lack of support in the original > RFC, > > and came up empty. > > > > A consequent discussion in R11 has led me here. > > Can anyone working on internals explain why traits don’t allow constants > > (either technically or philosophically)? > > Moreover, what’s the opinion(s) of the list, on adding support for this? > > Would an RFC be needed? > > > > Sounds like a reasonable addition. An RFC will be needed to specify the > details, which tend to be tricky whenever traits are involved. Some > suggestions: > > * Constants mustn't be accessible directly on the trait, i.e. > TraitName::FOOBAR throws. > Sorry for asking so late, but: why? Note that currently both TraitName::$foobar and TraitName::foobar() work: https://3v4l.org/eGlYm Thanks, -- Guilliam Xavier

« previous php.internals (#114431) next »