Re: [PRE-RFC] Runtime modules
| From: | Rowan Tommins [IMSoP] | Date: | Sun, 28 Jun 2026 15:19:08 +0000 |
| Subject: | Re: [PRE-RFC] Runtime modules | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131562@lists.php.net to get a copy of this message | ||
On 28 June 2026 14:49:18 BST, Alexander Egorov <amego2006@gmail.com> wrote:
>Let's again start simple and temporarily forget about tags. We also load
>this class, either manually by including that same file, or instruct our
>autoloader for that. Now we also have this symbol in our own container:
>\Client. Despite that $client is also a \Client, its original symbol (which
>is remembered by PHP internally) is unavailable to us (like "shadowed") and
>there is no conflict. Moreover, since those are still technically the same
>class (PHP can handle that, I believe), $client instaceof \Client === true;
>And we can use this symbol throughout our main app.
No, PHP can't handle that, at least not trivially. Knowing that it was defined in the same file
is *not* enough to prove it is the same object.
This is in fact why OpCache only optimises and caches individual files: it has to take the compiled
code and run a "linker" to resolve references to other symbols, because they might be
*different* in different processes/threads.
You either have a complex key made up of every symbol the linker needed, recursively; or you just
assume that every time you link the class you get a different result.
Rowan Tommins
[IMSoP]