Re: cvs: ZendEngine2(PHP_5_3) / zend_closures.c /tests closure_022.phpt
Dmitry Stogov <[email protected]>
| Newsgroups | gmane.comp.php.cvs.zend |
|---|---|
| Message-ID | <[email protected]> |
Hi Marcus,
Sorry, but I don't understand what do you propose?
Thanks. Dmitry.
Marcus Boerger wrote:
> Hello Dmitry,
>
> assuming they could, somehow, that would be kind of local static
> variables, right? So that would be keeping state accross calls. Which
> we can do already. But other than that you are of course right that
> they cannot have properties. The last thing you made me wonder about
> is whether setting the handlers to NULL shouldn't trigge the errors
> already so that not all (strange) objects have to do this.
>
> marcus
>
> Tuesday, July 22, 2008, 9:29:31 AM, you wrote:
>
>> dmitry Tue Jul 22 07:29:31 2008 UTC
>
>> Added files: (Branch: PHP_5_3)
>> /ZendEngine2/tests closure_022.phpt
>
>> Modified files:
>> /ZendEngine2 zend_closures.c
>> Log:
>> Closure object cannot have properties
>>
>>
>> http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_closures.c?r1=1.3.2.3&r2=1.3.2.4&diff_format=u
>> Index: ZendEngine2/zend_closures.c
>> diff -u ZendEngine2/zend_closures.c:1.3.2.3 ZendEngine2/zend_closures.c:1.3.2.4
>> --- ZendEngine2/zend_closures.c:1.3.2.3 Mon Jul 14 12:18:20 2008
>> +++ ZendEngine2/zend_closures.c Tue Jul 22 07:29:31 2008
>> @@ -17,7 +17,7 @@
>>
>> +----------------------------------------------------------------------+
>> */
>>
>> -/* $Id: zend_closures.c,v 1.3.2.3 2008/07/14 12:18:20 dmitry Exp $ */
>> +/* $Id: zend_closures.c,v 1.3.2.4 2008/07/22 07:29:31 dmitry Exp $ */
>>
>> #include "zend.h"
>> #include "zend_API.h"
>> @@ -29,6 +29,9 @@
>> #define ZEND_INVOKE_FUNC_NAME "__invoke"
>> #define ZEND_CLOSURE_PRINT_NAME "Closure object"
>>
>> +#define ZEND_CLOSURE_PROPERTY_ERROR() \
>> + zend_error(E_ERROR, "Closure object cannot have properties")
>> +
>> typedef struct _zend_closure {
>> zend_object std;
>> zend_function func;
>> @@ -137,6 +140,39 @@
>> }
>> /* }}} */
>>
>> +static zval *zend_closure_read_property(zval *object, zval *member, int type TSRMLS_DC) /* {{{ */
>> +{
>> + ZEND_CLOSURE_PROPERTY_ERROR();
>> + return NULL;
>> +}
>> +/* }}} */
>> +
>> +static void zend_closure_write_property(zval *object, zval *member, zval *value TSRMLS_DC) /* {{{ */
>> +{
>> + ZEND_CLOSURE_PROPERTY_ERROR();
>> +}
>> +/* }}} */
>> +
>> +static zval **zend_closure_get_property_ptr_ptr(zval *object, zval *member TSRMLS_DC) /* {{{ */
>> +{
>> + ZEND_CLOSURE_PROPERTY_ERROR();
>> + return NULL;
>> +}
>> +/* }}} */
>> +
>> +static int zend_closure_has_property(zval *object, zval *member, int has_set_exists TSRMLS_DC) /* {{{ */
>> +{
>> + ZEND_CLOSURE_PROPERTY_ERROR();
>> + return 0;
>> +}
>> +/* }}} */
>> +
>> +static void zend_closure_unset_property(zval *object, zval *member TSRMLS_DC) /* {{{ */
>> +{
>> + ZEND_CLOSURE_PROPERTY_ERROR();
>> +}
>> +/* }}} */
>> +
>> static void zend_closure_free_storage(void *object TSRMLS_DC) /* {{{ */
>> {
>> zend_closure *closure = (zend_closure *)object;
>> @@ -195,6 +231,11 @@
>> memcpy(&closure_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
>> closure_handlers.get_constructor = zend_closure_get_constructor;
>> closure_handlers.get_method = zend_closure_get_method;
>> + closure_handlers.write_property = zend_closure_write_property;
>> + closure_handlers.read_property = zend_closure_read_property;
>> + closure_handlers.get_property_ptr_ptr = zend_closure_get_property_ptr_ptr;
>> + closure_handlers.has_property = zend_closure_has_property;
>> + closure_handlers.unset_property = zend_closure_unset_property;
>> closure_handlers.compare_objects = zend_closure_compare_objects;
>> closure_handlers.cast_object = zend_closure_cast_object_tostring;
>> closure_handlers.clone_obj = NULL;
>
>> http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/closure_022.phpt?view=markup&rev=1.1
>> Index: ZendEngine2/tests/closure_022.phpt
>> +++ ZendEngine2/tests/closure_022.phpt
>> --TEST--
>> Closure 022: Closure properties
>> --FILE--
>> <?php
>> $a = 0;
>> $foo = function() use ($a) {
>> };
>> $foo->a = 1;
> ?>>
>> --EXPECTF--
>> Fatal error: Closure object cannot have properties in %sclosure_022.php on line 5
>
>
>
>
>
>
>
> Best regards,
> Marcus
>
--
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php