Re: [RFC][Vote announcement] Arbitrary static variable initializers
| From: | Ilija Tovilo | Date: | Wed, 15 Mar 2023 17:21:20 +0000 |
| Subject: | Re: [RFC][Vote announcement] Arbitrary static variable initializers | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-119712@lists.php.net to get a copy of this message | ||
Hi Tim
> >
> > https://wiki.php.net/rfc/arbitrary_static_variable_initializers
> > https://externals.io/message/118976
>
> There is an unresolved "question":
>
> > Side note: It's been suggested that expressions that can be evaluated constantly
> > continue to do so. This would mean that some expressions in getStaticVariables are evaluated and
> > some are not. The upside is that this would avoid the backward incompatibility. I will check if this
> > is technically feasible.
Ah, thanks for catching this. This has been partially implemented. PHP
will attempt to evaluate the constant expression at compile time. If
successful, the value will continue to be available from
ReflectionFunction::getStaticVariables() right away. Only when the
expression isn't known at compile time (including class constants from
other files) will it contain null until the function is called. This
reduces the BC incompatibility but doesn't completely avoid it.
Ilija