Skip to content

Commit

Permalink
Implementing classes can now satisfy guarded property declarations with
Browse files Browse the repository at this point in the history
a traditional property declaration.

Also added XFAIL sections to a few tests that are expected to fail for
now until other tickets are closed.

fixes php#13
  • Loading branch information
cpriest committed Jan 4, 2013
1 parent fb07b3b commit a4562be
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
--TEST--
ZE2 Tests that isset/unset default implementations work as expected, also ensures that isset/unset call the getter/setter accessors
--XFAIL--
Waiting on https://github.com/cpriest/php-src/issues/12
--FILE--
<?php

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
--TEST--
ZE2 Tests that a undefined getter produces an error upon isset()
--XFAIL--
Waiting on https://github.com/cpriest/php-src/issues/12
--FILE--
<?php

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
--TEST--
ZE2 Tests that access to a undefined parent getter produces an error
--XFAIL--
No support for parent:: self:: static:: or Shape:: at the moment
--FILE--
<?php

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
--TEST--
ZE2 Tests that access to a undefined self getter produces an error
--XFAIL--
No support for parent:: self:: static:: or Shape:: at the moment
--FILE--
<?php

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
--TEST--
ZE2 Tests that an undefined setter produces an error on unset()
--XFAIL--
Waiting on https://github.com/cpriest/php-src/issues/12
--FILE--
<?php

Expand Down
2 changes: 2 additions & 0 deletions Zend/tests/accessors/accessor_std_parent_basic.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
--TEST--
ZE2 Tests that a getter/setter can access parent class getter/setter
--XFAIL--
No support for parent:: self:: static:: or Shape:: at the moment
--FILE--
<?php

Expand Down
31 changes: 30 additions & 1 deletion Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,6 @@ void zend_do_end_accessor_declaration(znode *function_token, znode *var_name, zn
}
/* }}} */


void zend_finalize_accessor(znode *var_name TSRMLS_DC) { /* {{{ */
zend_property_info *property_info;

Expand Down Expand Up @@ -3745,6 +3744,16 @@ static zend_bool do_inherit_method_check(HashTable *child_function_table, zend_f
TSRMLS_FETCH();

if (zend_hash_quick_find(child_function_table, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void **) &child)==FAILURE) {
if(IS_ACCESSOR_FN(parent)) {
zend_property_info *property_info;
const char *acc_name = ZEND_ACC_NAME(parent);
zend_uint acc_name_len = strlen(acc_name);

if(zend_hash_find(&child_ce->properties_info, acc_name, acc_name_len+1, (void **) &property_info) == SUCCESS) {
if(!property_info->ai)
return 0; /* Do not copy */
}
}
if (parent_flags & (ZEND_ACC_ABSTRACT)) {
child_ce->ce_flags |= ZEND_ACC_IMPLICIT_ABSTRACT_CLASS;
}
Expand Down Expand Up @@ -4057,6 +4066,24 @@ static int do_interface_constant_check(zval **val TSRMLS_DC, int num_args, va_li
}
/* }}} */



/*static int prune_dangling_accessors(zend_function *zf, zend_class_entry *ce TSRMLS_DC) { {{{
if(IS_ACCESSOR_FN(zf)) {
zend_property_info *property_info;
const char *acc_name = ZEND_ACC_NAME(zf);
zend_uint acc_name_len = strlen(acc_name);
if(zend_hash_find(&ce->properties_info, acc_name, acc_name_len+1, (void **) &property_info) == SUCCESS) {
if(property_info->ai)
return ZEND_HASH_APPLY_KEEP;
return ZEND_HASH_APPLY_REMOVE;
}
}
return ZEND_HASH_APPLY_KEEP;
}
}}} */

ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC) /* {{{ */
{
zend_uint i, ignore = 0;
Expand Down Expand Up @@ -4093,6 +4120,8 @@ ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry

do_implement_interface(ce, iface TSRMLS_CC);
zend_do_inherit_interfaces(ce, iface TSRMLS_CC);

//zend_hash_apply_with_argument(&ce->function_table, (apply_func_arg_t) prune_dangling_accessors, (void*)ce);
}
}
/* }}} */
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#define FREE_PNODE(znode) zval_dtor(&znode->u.constant);

#define IS_ACCESSOR_FN(fn) ( fn->common.purpose >= ZEND_FNP_PROP_GETTER && fn->common.purpose <= ZEND_FNP_PROP_UNSETTER )
#define IS_ACCESSOR_FN(fn) ( (fn)->common.purpose >= ZEND_FNP_PROP_GETTER && (fn)->common.purpose <= ZEND_FNP_PROP_UNSETTER )

#define INIT_ZNODE(zn) \
{ \
Expand Down

0 comments on commit a4562be

Please sign in to comment.