FAQ
If I define a descendant class, I *obviously* know what create_object should
do, as this should only effect internal classes. So could anybody please
explain to me why the parent's create_object is enforced?

It causes to write hacks like:

---8<---
zend_class_entry *ce;
zend_object_value (*__create_object)(zend_class_entry *ce TSRMLS_DC);

INIT_CLASS_ENTRY(ce, "classname", php_my_method_entry);
ce.create_object = php_my_object_new;
/* hack starts here */
__create_object = parent_ce->create_object;
parent_ce->create_object = php_my_object_new;
php_my_class_entry = zend_register_internal_class_ex(&ce, parent_ce, NULL TSRMLS_CC);
parent->create_object = __create_object;
--->8---

If this limitation is there without a really good reason, I'd like to get rid of it.

Thanks,
Mike

Search Discussions

  • Etienne Kneuss at Sep 2, 2010 at 5:29 pm

    On Sep 02 18:04:12, Michael Wallner wrote:
    If I define a descendant class, I *obviously* know what create_object should
    do, as this should only effect internal classes. So could anybody please
    explain to me why the parent's create_object is enforced?

    It causes to write hacks like:

    ---8<---
    zend_class_entry *ce;
    zend_object_value (*__create_object)(zend_class_entry *ce TSRMLS_DC);

    INIT_CLASS_ENTRY(ce, "classname", php_my_method_entry);
    ce.create_object = php_my_object_new;
    /* hack starts here */
    __create_object = parent_ce->create_object;
    parent_ce->create_object = php_my_object_new;
    php_my_class_entry = zend_register_internal_class_ex(&ce, parent_ce, NULL TSRMLS_CC);
    parent->create_object = __create_object;
    --->8---
    Why can't you simply overwrite it afterwards? Just like it's done in
    SPL:

    http://php-og.mgdm.net/opengrok/xref/PHP_5_3/ext/spl/spl_functions.c#41

    Best,
    If this limitation is there without a really good reason, I'd like to get rid of it.

    Thanks,
    Mike

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
    --
    Etienne Kneuss
  • Michael Wallner at Sep 3, 2010 at 7:56 am

    On 09/02/2010 07:29 PM, Etienne Kneuss wrote:
    Why can't you simply overwrite it afterwards? Just like it's done in
    SPL:

    http://php-og.mgdm.net/opengrok/xref/PHP_5_3/ext/spl/spl_functions.c#41
    doh! Thanks for pointing a lame duck to the obvious. :)

    Mike

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedSep 2, '10 at 4:04p
activeSep 3, '10 at 7:56a
posts3
users2
websitephp.net

2 users in discussion

Michael Wallner: 2 posts Etienne Kneuss: 1 post

People

Translate

site design / logo © 2022 Grokbase