On Thu, Jun 2, 2022 at 8:17 AM Ilija Tovilo <tovilo.il...@gmail.com> wrote:
>
> Hi Nikita
>
> > This looks like a reasonable addition.
> >
> > Could there be any expectation that if -> works, ?-> does as well?
>
> Possibly. The implementation was simple enough so I'll add support for
> completeness.
>
> ---
>
> Hi Côme
>
> > It is not clear to me why this allows using -> on enums but not on other 
> > objects.
>
> The RFC *does* allow using -> on all objects. From the RFC:
>
> > As mentioned, the primary motivation for this feature are enums. However, 
> > the
> > implementation for supporting new is identical and I don't believe
> > arbitrarily restricting how -> can be used in this context makes sense.
>
> > Can you clarify why the following is not allowed:
> >
> > <?php
> >
> > $a = new Thing();
> >
> > class C
> > {
> >   protected $b = $a->var;
> >   static $staticobj = new Thing();
> >   function f($p = self::$staticobj->var) {}
> > }
>
> `protected $b = $a->var;` is not allowed because there can't be local
> variables in the context of context expressions. `function f($p =
> self::$staticobj->var) {}` is not allowed because static variables
> aren't supported in constant expressions. Your examples would already
> fail today without ->.
>
> Ilija
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>

> The RFC *does* allow using -> on all objects. From the RFC:

So, how does this change our mental models when writing PHP? For
example, I generally consider `const` to be a "compile-time" constant
(ie, generated/created before any code is actually executed). So would
this allow code to actually execute before any other code (ie, by
putting code in a __get()) and thus cause issues due to database
drivers and etc to not be loaded yet -- or cause them to be loaded
prematurely?

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to