lisachenko / z-engine

:zap: PHP Engine Direct API
MIT License
448 stars 22 forks source link

[Feature] Interface gets implemented handler #24

Closed lisachenko closed 4 years ago

lisachenko commented 4 years ago

In the engine, each class entry has a union field:

    union {
        zend_object* (*create_object)(zend_class_entry *class_type);
        int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type); /* a class implements this interface */
    };

Whereas create_object handler is used for object initialization, theinterface_gets_implemented handler is used for interfaces as a general callback when class implements this concrete interface. This callback can be used for interesting features like automatic class registration/configuration via callback.

There is a requirement for this handler (and interfaces): it should be installed before the first declaration of any class that implements this interface, otherwise you will receive a segfault on second call in FPM, because handler will