Skip to content

Commit 9e15b99

Browse files
committed
Addressed Review Comments.
1 parent 6256e24 commit 9e15b99

File tree

6 files changed

+20
-45
lines changed

6 files changed

+20
-45
lines changed

Zend/zend_API.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3515,7 +3515,7 @@ static zend_always_inline zend_bool is_persistent_class(zend_class_entry *ce) {
35153515
&& ce->info.internal.module->type == MODULE_PERSISTENT;
35163516
}
35173517

3518-
ZEND_API int zend_declare_typed_property(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment, zend_type type) /* {{{ */
3518+
ZEND_API zend_property_info *zend_declare_typed_property(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment, zend_type type) /* {{{ */
35193519
{
35203520
zend_property_info *property_info, *property_info_ptr;
35213521

@@ -3614,7 +3614,7 @@ ZEND_API int zend_declare_typed_property(zend_class_entry *ce, zend_string *name
36143614

36153615
zend_hash_update_ptr(&ce->properties_info, name, property_info);
36163616

3617-
return SUCCESS;
3617+
return property_info;
36183618
}
36193619
/* }}} */
36203620

@@ -3747,7 +3747,8 @@ ZEND_API int zend_try_assign_typed_ref_zval_ex(zend_reference *ref, zval *zv, ze
37473747

37483748
ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment) /* {{{ */
37493749
{
3750-
return zend_declare_typed_property(ce, name, property, access_type, doc_comment, (zend_type) ZEND_TYPE_INIT_NONE(0));
3750+
zend_declare_typed_property(ce, name, property, access_type, doc_comment, (zend_type) ZEND_TYPE_INIT_NONE(0));
3751+
return SUCCESS;
37513752
}
37523753
/* }}} */
37533754

@@ -3814,7 +3815,7 @@ ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, const char *nam
38143815
}
38153816
/* }}} */
38163817

3817-
ZEND_API int zend_declare_class_constant_ex(zend_class_entry *ce, zend_string *name, zval *value, int access_type, zend_string *doc_comment) /* {{{ */
3818+
ZEND_API zend_class_constant *zend_declare_class_constant_ex(zend_class_entry *ce, zend_string *name, zval *value, int access_type, zend_string *doc_comment) /* {{{ */
38183819
{
38193820
zend_class_constant *c;
38203821

@@ -3852,24 +3853,22 @@ ZEND_API int zend_declare_class_constant_ex(zend_class_entry *ce, zend_string *n
38523853
"Cannot redefine class constant %s::%s", ZSTR_VAL(ce->name), ZSTR_VAL(name));
38533854
}
38543855

3855-
return SUCCESS;
3856+
return c;
38563857
}
38573858
/* }}} */
38583859

38593860
ZEND_API int zend_declare_class_constant(zend_class_entry *ce, const char *name, size_t name_length, zval *value) /* {{{ */
38603861
{
3861-
int ret;
3862-
38633862
zend_string *key;
38643863

38653864
if (ce->type == ZEND_INTERNAL_CLASS) {
38663865
key = zend_string_init_interned(name, name_length, 1);
38673866
} else {
38683867
key = zend_string_init(name, name_length, 0);
38693868
}
3870-
ret = zend_declare_class_constant_ex(ce, key, value, ZEND_ACC_PUBLIC, NULL);
3869+
zend_declare_class_constant_ex(ce, key, value, ZEND_ACC_PUBLIC, NULL);
38713870
zend_string_release(key);
3872-
return ret;
3871+
return SUCCESS;
38733872
}
38743873
/* }}} */
38753874

Zend/zend_API.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_nam
351351
ZEND_API const char *zend_get_module_version(const char *module_name);
352352
ZEND_API int zend_get_module_started(const char *module_name);
353353

354-
ZEND_API int zend_declare_typed_property(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment, zend_type type);
354+
ZEND_API zend_property_info *zend_declare_typed_property(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment, zend_type type);
355355

356356
ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment);
357357
ZEND_API int zend_declare_property(zend_class_entry *ce, const char *name, size_t name_length, zval *property, int access_type);
@@ -362,7 +362,7 @@ ZEND_API int zend_declare_property_double(zend_class_entry *ce, const char *name
362362
ZEND_API int zend_declare_property_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value, int access_type);
363363
ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_len, int access_type);
364364

365-
ZEND_API int zend_declare_class_constant_ex(zend_class_entry *ce, zend_string *name, zval *value, int access_type, zend_string *doc_comment);
365+
ZEND_API zend_class_constant *zend_declare_class_constant_ex(zend_class_entry *ce, zend_string *name, zval *value, int access_type, zend_string *doc_comment);
366366
ZEND_API int zend_declare_class_constant(zend_class_entry *ce, const char *name, size_t name_length, zval *value);
367367
ZEND_API int zend_declare_class_constant_null(zend_class_entry *ce, const char *name, size_t name_length);
368368
ZEND_API int zend_declare_class_constant_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value);

Zend/zend_attributes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ ZEND_API zend_attribute *zend_add_attribute(HashTable **attributes, zend_bool pe
103103

104104
zend_attribute *attr = pemalloc(ZEND_ATTRIBUTE_SIZE(argc), persistent);
105105

106-
if (persistent == (zend_bool) (GC_FLAGS(name) & IS_STR_PERSISTENT)) {
106+
if (persistent == ((GC_FLAGS(name) & IS_STR_PERSISTENT) != 0)) {
107107
attr->name = zend_string_copy(name);
108108
} else {
109109
attr->name = zend_string_dup(name, persistent);

Zend/zend_attributes.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,35 +59,11 @@ static zend_always_inline zend_attribute *zend_add_property_attribute(zend_class
5959
return zend_add_attribute(&info->attributes, ce->type != ZEND_USER_CLASS, 0, name, argc);
6060
}
6161

62-
static zend_always_inline zend_attribute *zend_add_property_attribute_str(zend_class_entry *ce, const char *key, size_t len, zend_string *name, uint32_t argc)
63-
{
64-
zend_property_info *info = (zend_property_info *) zend_hash_str_find_ptr(&ce->properties_info, key, len);
65-
66-
if (info == NULL) {
67-
zend_error_noreturn(E_ERROR, "Property '%.*s' not found in class '%s'", (int) len, key, ZSTR_VAL(ce->name));
68-
return NULL;
69-
}
70-
71-
return zend_add_attribute(&info->attributes, ce->type != ZEND_USER_CLASS, 0, name, argc);
72-
}
73-
7462
static zend_always_inline zend_attribute *zend_add_class_constant_attribute(zend_class_entry *ce, zend_class_constant *c, zend_string *name, uint32_t argc)
7563
{
7664
return zend_add_attribute(&c->attributes, ce->type != ZEND_USER_CLASS, 0, name, argc);
7765
}
7866

79-
static zend_always_inline zend_attribute *zend_add_class_constant_attribute_str(zend_class_entry *ce, const char *key, size_t len, zend_string *name, uint32_t argc)
80-
{
81-
zend_class_constant *c = (zend_class_constant *) zend_hash_str_find_ptr(&ce->constants_table, key, len);
82-
83-
if (c == NULL) {
84-
zend_error_noreturn(E_ERROR, "Class constant '%.*s' not found in class '%s'", (int) len, key, ZSTR_VAL(ce->name));
85-
return NULL;
86-
}
87-
88-
return zend_add_attribute(&c->attributes, ce->type != ZEND_USER_CLASS, 0, name, argc);
89-
}
90-
9167
void zend_register_attribute_ce(void);
9268

9369
#endif

Zend/zend_compile.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6439,6 +6439,7 @@ void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast, uint32_t flags, z
64396439
}
64406440

64416441
for (i = 0; i < children; ++i) {
6442+
zend_property_info *info;
64426443
zend_ast *prop_ast = list->child[i];
64436444
zend_ast *name_ast = prop_ast->child[0];
64446445
zend_ast *value_ast = prop_ast->child[1];
@@ -6499,10 +6500,9 @@ void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast, uint32_t flags, z
64996500
ZVAL_UNDEF(&value_zv);
65006501
}
65016502

6502-
zend_declare_typed_property(ce, name, &value_zv, flags, doc_comment, type);
6503+
info = zend_declare_typed_property(ce, name, &value_zv, flags, doc_comment, type);
65036504

65046505
if (attr_ast) {
6505-
zend_property_info *info = (zend_property_info *) zend_hash_find_ptr(&ce->properties_info, name);
65066506
zend_compile_attributes(&info->attributes, attr_ast, 0, ZEND_ATTRIBUTE_TARGET_PROPERTY);
65076507
}
65086508
}
@@ -6553,6 +6553,7 @@ void zend_compile_class_const_decl(zend_ast *ast, zend_ast *attr_ast) /* {{{ */
65536553
}
65546554

65556555
for (i = 0; i < list->children; ++i) {
6556+
zend_class_constant *c;
65566557
zend_ast *const_ast = list->child[i];
65576558
zend_ast *name_ast = const_ast->child[0];
65586559
zend_ast *value_ast = const_ast->child[1];
@@ -6566,10 +6567,9 @@ void zend_compile_class_const_decl(zend_ast *ast, zend_ast *attr_ast) /* {{{ */
65666567
}
65676568

65686569
zend_const_expr_to_zval(&value_zv, value_ast);
6569-
zend_declare_class_constant_ex(ce, name, &value_zv, ast->attr, doc_comment);
6570+
c = zend_declare_class_constant_ex(ce, name, &value_zv, ast->attr, doc_comment);
65706571

65716572
if (attr_ast) {
6572-
zend_class_constant *c = (zend_class_constant *) zend_hash_find_ptr(&ce->constants_table, name);
65736573
zend_compile_attributes(&c->attributes, attr_ast, 0, ZEND_ATTRIBUTE_TARGET_CLASS_CONST);
65746574
}
65756575
}

Zend/zend_inheritance.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,6 +1967,7 @@ static void zend_do_traits_property_binding(zend_class_entry *ce, zend_class_ent
19671967
size_t i;
19681968
zend_property_info *property_info;
19691969
zend_property_info *coliding_prop;
1970+
zend_property_info *new_prop;
19701971
zend_string* prop_name;
19711972
const char* class_name_unused;
19721973
zend_bool not_compatible;
@@ -2074,14 +2075,13 @@ static void zend_do_traits_property_binding(zend_class_entry *ce, zend_class_ent
20742075
doc_comment = property_info->doc_comment ? zend_string_copy(property_info->doc_comment) : NULL;
20752076

20762077
zend_type_copy_ctor(&property_info->type, /* persistent */ 0);
2077-
zend_declare_typed_property(ce, prop_name, prop_value, flags, doc_comment, property_info->type);
2078+
new_prop = zend_declare_typed_property(ce, prop_name, prop_value, flags, doc_comment, property_info->type);
20782079

20792080
if (property_info->attributes) {
2080-
zend_property_info *info = (zend_property_info *) zend_hash_find_ptr(&ce->properties_info, prop_name);
2081-
info->attributes = property_info->attributes;
2081+
new_prop->attributes = property_info->attributes;
20822082

2083-
if (!(GC_FLAGS(info->attributes) & IS_ARRAY_IMMUTABLE)) {
2084-
GC_ADDREF(info->attributes);
2083+
if (!(GC_FLAGS(new_prop->attributes) & IS_ARRAY_IMMUTABLE)) {
2084+
GC_ADDREF(new_prop->attributes);
20852085
}
20862086
}
20872087

0 commit comments

Comments
 (0)