Re: [RFC] Keep type of reference params
| From: | Thomas Gutbier | Date: | Fri, 08 May 2020 11:03:59 +0000 |
| Subject: | Re: [RFC] Keep type of reference params | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-110083@lists.php.net to get a copy of this message | ||
Am 08.05.2020 um 12:37 schrieb G. P. B.:
I think everyone can agree this is useful. But the issue here is the implementation. Because from what I know PHP's references are aspecial kind of pain in the engine. That's why the common wisdom is to use references in PHP as least as possible. And IIRC what you are trying to achieve would need a major overhaul of how references work and someone who wanted to tackle this would have done it on their own and propose an RFC at the same time. So sadly unless something semi-concrete shows up, I'm considering this a pipe dream. But I'd gladly be shown otherwise.Isn't that already solved for typed properties? Consider this: class A { public static int $number = 5; } $num = &A::$number; $num = "String"; This will result in an uncaught TypeError, see https://3v4l.org/XC6hk I would think, it would be consistent if referenced parameters behaved in exactly the same way. Regards, Thomas