> > This would break as soon as we have two versions of a class, and a > runtime choice which of them to use. > (see also Mark Randall's comment)
That's why I'm suggesting to only make these optimizations when preloading <https://wiki.php.net/rfc/preload>is in use, which means that you know ahead of time the class definitions, and you cannot have 2 runtime definitions of a given class. No preloading = no optimizations. Full preloading (whole codebase) = maximum optimizations. Partial preloading = the compiler should still be able to optimize *some *of the code involving only the preloaded classes. We already have, since PHP 7.4, a mechanism to know static class definitions on startup, so why not build further optimizations on top of it? — Benjamin