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

Reply via email to