I think your humor is too subtle for me. I don't understand what you
mean. If I do this:
PHP_METHOD(test_class,__construct);
zend_class_entry *test_class_ce_ptr = NULL;
static zend_function_entry test_class_functions[] = {
PHP_ME(test_class, __construct, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
And then I put this in my MINIT function:
INIT_CLASS_ENTRY(ce, "test_class", test_class_functions);
test_class_ce_ptr = zend_register_internal_class(&ce TSRMLS_CC);
zend_declare_property_null(test_class_ce_ptr, "test_property",
sizeof("test_property")-1, ZEND_ACC_PUBLIC TSRMLS_CC);
And I make test_class's constructor look like this:
PHP_METHOD(test_class, __construct) {
zval *tmp = NULL;
ALLOC_ZVAL(tmp);
tmp->is_ref = 0;
tmp->refcount = 0;
array_init(tmp);
add_next_index_long(tmp, 100);
zend_update_property(test_class_ce_ptr, this_ptr, "test_property",
sizeof("test_property")-1, tmp TSRMLS_CC);
}
Then this PHP program:
$e = new test_class();
print new ReflectionClass($e);
var_dump($e);
Prints:
Class [ <internal> class test_class ] {
- Constants [0] {
}
- Static properties [0] {
}
- Static methods [0] {
}
- Properties [1] {
Property [ <default> public $test_property ]
}
- Methods [1] {
Method [ <internal> <ctor> public method __construct ] {
}
}
}
object(test_class)#1 (1) {
["test_property"]=>
array(1) {
[0]=>
int(100)
}
}
So it would be handy (since all the property creation would be in one
place and there wouldn't be the confusing inference from reading the
code that the property is NULL) if I could create the array zval in
MINIT instead of in the constructor.
David
Marcus Boerger wrote: