Skip to content

Commit 8e93e4b

Browse files
committed
Address review comments
1 parent 8661114 commit 8e93e4b

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

Zend/zend_attributes.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static void attribute_ptr_dtor(zval *v) /* {{{ */
7373
ZEND_API void zend_compiler_attribute_register(zend_class_entry *ce, zend_attributes_internal_validator validator)
7474
{
7575
if (ce->type != ZEND_INTERNAL_CLASS) {
76-
return;
76+
zend_error_noreturn(E_ERROR, "Only internal classes can be registered as compiler attribute");
7777
}
7878

7979
zend_string *lcname = zend_string_tolower_ex(ce->name, 1);
@@ -87,10 +87,10 @@ ZEND_API void zend_compiler_attribute_register(zend_class_entry *ce, zend_attrib
8787
zend_hash_init(ce->attributes, 8, NULL, attribute_ptr_dtor, 1);
8888
}
8989

90-
zend_attribute *attr = emalloc(ZEND_ATTRIBUTE_SIZE(0));
90+
zend_attribute *attr = pemalloc(ZEND_ATTRIBUTE_SIZE(0), 1);
9191

9292
attr->name = zend_string_copy(zend_ce_php_attribute->name);
93-
attr->lcname = zend_string_tolower(attr->name);
93+
attr->lcname = zend_string_tolower_ex(attr->name, 1);
9494
attr->offset = 0;
9595
attr->argc = 0;
9696

ext/reflection/php_reflection.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,8 @@ static void reflection_attribute_factory(zval *object, zend_attribute *data, zen
10921092
static int read_attributes(zval *ret, HashTable *attributes, zend_class_entry *scope,
10931093
uint32_t offset, zend_string *name, zend_class_entry *base) /* {{{ */
10941094
{
1095+
ZEND_ASSERT(attributes != NULL);
1096+
10951097
zend_attribute *attr;
10961098
zval tmp;
10971099

@@ -1110,10 +1112,6 @@ static int read_attributes(zval *ret, HashTable *attributes, zend_class_entry *s
11101112
return SUCCESS;
11111113
}
11121114

1113-
if (!attributes) {
1114-
return SUCCESS;
1115-
}
1116-
11171115
ZEND_HASH_FOREACH_PTR(attributes, attr) {
11181116
if (attr->offset != offset) {
11191117
continue;
@@ -4180,15 +4178,9 @@ ZEND_METHOD(ReflectionClass, getAttributes)
41804178
reflection_object *intern;
41814179
zend_class_entry *ce;
41824180

4183-
HashTable *attributes = NULL;
4184-
zend_class_entry *scope = NULL;
4185-
41864181
GET_REFLECTION_OBJECT_PTR(ce);
41874182

4188-
attributes = ce->attributes;
4189-
scope = ce;
4190-
4191-
reflect_attributes(INTERNAL_FUNCTION_PARAM_PASSTHRU, attributes, 0, scope);
4183+
reflect_attributes(INTERNAL_FUNCTION_PARAM_PASSTHRU, ce->attributes, 0, ce);
41924184
}
41934185
/* }}} */
41944186

0 commit comments

Comments
 (0)