Drop support for inheriting classes without functions and vice versa
Classes and functions are inseparably linked.
- Methods in classes may declare anonymous functions in their methods which have to be inherited (fixed by SirSnyder a few years ago)
- Functions may declare anonymous classes (currently broken when only PTHREADS_INHERIT_FUNCTIONS is used)
- Functions may refer to classes in their parameter and return typehints (I don't think these currently directly refer to CEs, but if they did we aren't copying them, which would lead to crashes)
- Functions may instantiate classes
- Class methods may call functions
- Methods/functions may also declare named classes and functions (a rare case, but one that currently results in faults in copied code).
The bottom line is that functions and classes are coupled in some (a lot of) cases, and shouldn't therefore be copyable separately.
In particular, the ability to do this has resulted in various faults, assertion failures in php-src, differences in pthreads behaviour with/without opcache, and more besides.
There's a weaker argument for disallowing separate constant inheritance (constants don't circularly depend on anything, but they can be referenced via AST from copied classes).
In the past my proposed solution to this was to copy just the classes and functions needed given a particular class (or function) as a starting point. However, with OPcache in the mix (and especially with JIT), it's difficult to determine what classes or functions are referenced by user code, so we end up needing to copy all of them anyway.