Skip to content

Commit a4562be

Browse files
author
cpriest
committed
Implementing classes can now satisfy guarded property declarations with
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
1 parent fb07b3b commit a4562be

8 files changed

+43
-2
lines changed

Zend/tests/accessors/accessor_isset_unset_default_implemented_basic.phpt

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
ZE2 Tests that isset/unset default implementations work as expected, also ensures that isset/unset call the getter/setter accessors
3+
--XFAIL--
4+
Waiting on https://github.com/cpriest/php-src/issues/12
35
--FILE--
46
<?php
57

Zend/tests/accessors/accessor_object_get_undefined_isset_called_error.phpt

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
ZE2 Tests that a undefined getter produces an error upon isset()
3+
--XFAIL--
4+
Waiting on https://github.com/cpriest/php-src/issues/12
35
--FILE--
46
<?php
57

Zend/tests/accessors/accessor_object_set_defined_parent_get_called_error.phpt

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
ZE2 Tests that access to a undefined parent getter produces an error
3+
--XFAIL--
4+
No support for parent:: self:: static:: or Shape:: at the moment
35
--FILE--
46
<?php
57

Zend/tests/accessors/accessor_object_set_defined_self_get_called_error.phpt

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
ZE2 Tests that access to a undefined self getter produces an error
3+
--XFAIL--
4+
No support for parent:: self:: static:: or Shape:: at the moment
35
--FILE--
46
<?php
57

Zend/tests/accessors/accessor_object_set_undefined_unset_called_error.phpt

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
ZE2 Tests that an undefined setter produces an error on unset()
3+
--XFAIL--
4+
Waiting on https://github.com/cpriest/php-src/issues/12
35
--FILE--
46
<?php
57

Zend/tests/accessors/accessor_std_parent_basic.phpt

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
ZE2 Tests that a getter/setter can access parent class getter/setter
3+
--XFAIL--
4+
No support for parent:: self:: static:: or Shape:: at the moment
35
--FILE--
46
<?php
57

Zend/zend_compile.c

+30-1
Original file line numberDiff line numberDiff line change
@@ -1774,7 +1774,6 @@ void zend_do_end_accessor_declaration(znode *function_token, znode *var_name, zn
17741774
}
17751775
/* }}} */
17761776

1777-
17781777
void zend_finalize_accessor(znode *var_name TSRMLS_DC) { /* {{{ */
17791778
zend_property_info *property_info;
17801779

@@ -3745,6 +3744,16 @@ static zend_bool do_inherit_method_check(HashTable *child_function_table, zend_f
37453744
TSRMLS_FETCH();
37463745

37473746
if (zend_hash_quick_find(child_function_table, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void **) &child)==FAILURE) {
3747+
if(IS_ACCESSOR_FN(parent)) {
3748+
zend_property_info *property_info;
3749+
const char *acc_name = ZEND_ACC_NAME(parent);
3750+
zend_uint acc_name_len = strlen(acc_name);
3751+
3752+
if(zend_hash_find(&child_ce->properties_info, acc_name, acc_name_len+1, (void **) &property_info) == SUCCESS) {
3753+
if(!property_info->ai)
3754+
return 0; /* Do not copy */
3755+
}
3756+
}
37483757
if (parent_flags & (ZEND_ACC_ABSTRACT)) {
37493758
child_ce->ce_flags |= ZEND_ACC_IMPLICIT_ABSTRACT_CLASS;
37503759
}
@@ -4057,6 +4066,24 @@ static int do_interface_constant_check(zval **val TSRMLS_DC, int num_args, va_li
40574066
}
40584067
/* }}} */
40594068

4069+
4070+
4071+
/*static int prune_dangling_accessors(zend_function *zf, zend_class_entry *ce TSRMLS_DC) { {{{
4072+
if(IS_ACCESSOR_FN(zf)) {
4073+
zend_property_info *property_info;
4074+
const char *acc_name = ZEND_ACC_NAME(zf);
4075+
zend_uint acc_name_len = strlen(acc_name);
4076+
4077+
if(zend_hash_find(&ce->properties_info, acc_name, acc_name_len+1, (void **) &property_info) == SUCCESS) {
4078+
if(property_info->ai)
4079+
return ZEND_HASH_APPLY_KEEP;
4080+
return ZEND_HASH_APPLY_REMOVE;
4081+
}
4082+
}
4083+
return ZEND_HASH_APPLY_KEEP;
4084+
}
4085+
}}} */
4086+
40604087
ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC) /* {{{ */
40614088
{
40624089
zend_uint i, ignore = 0;
@@ -4093,6 +4120,8 @@ ZEND_API void zend_do_implement_interface(zend_class_entry *ce, zend_class_entry
40934120

40944121
do_implement_interface(ce, iface TSRMLS_CC);
40954122
zend_do_inherit_interfaces(ce, iface TSRMLS_CC);
4123+
4124+
//zend_hash_apply_with_argument(&ce->function_table, (apply_func_arg_t) prune_dangling_accessors, (void*)ce);
40964125
}
40974126
}
40984127
/* }}} */

Zend/zend_compile.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

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

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

3939
#define INIT_ZNODE(zn) \
4040
{ \

0 commit comments

Comments
 (0)