Skip to content

Commit 2034bc5

Browse files
committed
Use known zend_string instead of C string
1 parent da015c2 commit 2034bc5

File tree

21 files changed

+33
-32
lines changed

21 files changed

+33
-32
lines changed

Zend/zend_API.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4560,7 +4560,7 @@ ZEND_API zend_class_constant *zend_declare_typed_class_constant(zend_class_entry
45604560
}
45614561
}
45624562

4563-
if (zend_string_equals_literal_ci(name, "class")) {
4563+
if (zend_string_equals_ci(name, ZSTR_KNOWN(ZEND_STR_CLASS))) {
45644564
zend_error_noreturn(ce->type == ZEND_INTERNAL_CLASS ? E_CORE_ERROR : E_COMPILE_ERROR,
45654565
"A class constant must not be called 'class'; it is reserved for class name fetching");
45664566
}

Zend/zend_ast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_constant(zend_string *name, ze
101101

102102
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_class_const_or_name(zend_ast *class_name, zend_ast *name) {
103103
zend_string *name_str = zend_ast_get_str(name);
104-
if (zend_string_equals_literal_ci(name_str, "class")) {
104+
if (zend_string_equals_ci(name_str, ZSTR_KNOWN(ZEND_STR_CLASS))) {
105105
zend_string_release(name_str);
106106
return zend_ast_create(ZEND_AST_CLASS_NAME, class_name);
107107
} else {

Zend/zend_attributes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ ZEND_METHOD(SensitiveParameterValue, __construct)
114114
Z_PARAM_ZVAL(value)
115115
ZEND_PARSE_PARAMETERS_END();
116116

117-
zend_update_property(zend_ce_sensitive_parameter_value, Z_OBJ_P(ZEND_THIS), "value", strlen("value"), value);
117+
zend_update_property_ex(zend_ce_sensitive_parameter_value, Z_OBJ_P(ZEND_THIS), ZSTR_KNOWN(ZEND_STR_VALUE), value);
118118
}
119119

120120
ZEND_METHOD(SensitiveParameterValue, getValue)

Zend/zend_builtin_functions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ ZEND_FUNCTION(get_defined_functions)
13221322
} ZEND_HASH_FOREACH_END();
13231323

13241324
zend_hash_str_add_new(Z_ARRVAL_P(return_value), "internal", sizeof("internal")-1, &internal);
1325-
zend_hash_str_add_new(Z_ARRVAL_P(return_value), "user", sizeof("user")-1, &user);
1325+
zend_hash_add_new(Z_ARRVAL_P(return_value), ZSTR_KNOWN(ZEND_STR_USER), &user);
13261326
}
13271327
/* }}} */
13281328

Zend/zend_compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ ZEND_API zend_string *zend_type_to_string(zend_type type) {
14291429
}
14301430

14311431
static bool is_generator_compatible_class_type(zend_string *name) {
1432-
return zend_string_equals_literal_ci(name, "Traversable")
1432+
return zend_string_equals_ci(name, ZSTR_KNOWN(ZEND_STR_TRAVERSABLE))
14331433
|| zend_string_equals_literal_ci(name, "Iterator")
14341434
|| zend_string_equals_literal_ci(name, "Generator");
14351435
}

Zend/zend_enum.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ static void zend_verify_enum_properties(zend_class_entry *ce)
6262
zend_property_info *property_info;
6363

6464
ZEND_HASH_MAP_FOREACH_PTR(&ce->properties_info, property_info) {
65-
if (zend_string_equals_literal(property_info->name, "name")) {
65+
if (zend_string_equals(property_info->name, ZSTR_KNOWN(ZEND_STR_NAME))) {
6666
continue;
6767
}
6868
if (
6969
ce->enum_backing_type != IS_UNDEF
70-
&& zend_string_equals_literal(property_info->name, "value")
70+
&& zend_string_equals(property_info->name, ZSTR_KNOWN(ZEND_STR_VALUE))
7171
) {
7272
continue;
7373
}

Zend/zend_interfaces.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,8 @@ static int zend_implement_iterator(zend_class_entry *interface, zend_class_entry
344344
&class_type->function_table, "rewind", sizeof("rewind") - 1);
345345
funcs_ptr->zf_valid = zend_hash_str_find_ptr(
346346
&class_type->function_table, "valid", sizeof("valid") - 1);
347-
funcs_ptr->zf_key = zend_hash_str_find_ptr(
348-
&class_type->function_table, "key", sizeof("key") - 1);
347+
funcs_ptr->zf_key = zend_hash_find_ptr(
348+
&class_type->function_table, ZSTR_KNOWN(ZEND_STR_KEY));
349349
funcs_ptr->zf_current = zend_hash_str_find_ptr(
350350
&class_type->function_table, "current", sizeof("current") - 1);
351351
funcs_ptr->zf_next = zend_hash_str_find_ptr(

ext/curl/interface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
13771377
curl_seek_callback seekfunc = seek_cb;
13781378
#endif
13791379

1380-
prop = zend_read_property(curl_CURLFile_class, Z_OBJ_P(current), "name", sizeof("name")-1, 0, &rv);
1380+
prop = zend_read_property_ex(curl_CURLFile_class, Z_OBJ_P(current), ZSTR_KNOWN(ZEND_STR_NAME), /* silent */ false, &rv);
13811381
ZVAL_DEREF(prop);
13821382
if (Z_TYPE_P(prop) != IS_STRING) {
13831383
php_error_docref(NULL, E_WARNING, "Invalid filename for key %s", ZSTR_VAL(string_key));

ext/dom/node.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,8 @@ static void dom_canonicalization(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{
16221622
zval *tmp;
16231623
char *xquery;
16241624

1625-
tmp = zend_hash_str_find(ht, "query", sizeof("query")-1);
1625+
/* Find "query" key */
1626+
tmp = zend_hash_find(ht, ZSTR_KNOWN(ZEND_STR_QUERY));
16261627
if (!tmp) {
16271628
/* if mode == 0 then $xpath arg is 3, if mode == 1 then $xpath is 4 */
16281629
zend_argument_value_error(3 + mode, "must have a \"query\" key");

ext/ftp/ftp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ ftp_mlsd_parse_line(HashTable *ht, const char *input) {
708708

709709
/* Extract pathname */
710710
ZVAL_STRINGL(&zstr, sp + 1, end - sp - 1);
711-
zend_hash_str_update(ht, "name", sizeof("name")-1, &zstr);
711+
zend_hash_update(ht, ZSTR_KNOWN(ZEND_STR_NAME), &zstr);
712712
end = sp;
713713

714714
while (input < end) {

0 commit comments

Comments
 (0)