@@ -7210,18 +7210,33 @@ static zval *_reflection_write_property(zend_object *object, zend_string *name,
7210
7210
7211
7211
ZEND_METHOD (ReflectionConstant , __construct )
7212
7212
{
7213
- zend_string * const_name ;
7213
+ zend_string * name ;
7214
7214
7215
7215
zval * object = ZEND_THIS ;
7216
7216
reflection_object * intern = Z_REFLECTION_P (object );
7217
7217
7218
7218
ZEND_PARSE_PARAMETERS_START (1 , 1 )
7219
- Z_PARAM_STR (const_name )
7219
+ Z_PARAM_STR (name )
7220
7220
ZEND_PARSE_PARAMETERS_END ();
7221
7221
7222
- zval * const_zv = zend_get_constant (const_name );
7222
+ /* Build name with lowercased ns. */
7223
+ bool backslash_prefixed = ZSTR_VAL (name )[0 ] == '\\' ;
7224
+ char * source = ZSTR_VAL (name ) + backslash_prefixed ;
7225
+ size_t source_len = ZSTR_LEN (name ) - backslash_prefixed ;
7226
+ zend_string * lc_name = zend_string_alloc (source_len , /* persistent */ false);
7227
+ const char * ns_end = zend_memrchr (source , '\\' , source_len );
7228
+ size_t ns_len = 0 ;
7229
+ if (ns_end ) {
7230
+ ns_len = ns_end - ZSTR_VAL (name );
7231
+ zend_str_tolower_copy (ZSTR_VAL (lc_name ), source , ns_len );
7232
+ }
7233
+ memcpy (ZSTR_VAL (lc_name ) + ns_len , source + ns_len , source_len - ns_len );
7234
+
7235
+ zval * const_zv = zend_get_constant (lc_name );
7236
+ zend_string_release_ex (lc_name , /* persistent */ false);
7237
+
7223
7238
if (!const_zv ) {
7224
- zend_throw_exception_ex (reflection_exception_ptr , 0 , "Constant \"%s\" does not exist" , ZSTR_VAL (const_name ));
7239
+ zend_throw_exception_ex (reflection_exception_ptr , 0 , "Constant \"%s\" does not exist" , ZSTR_VAL (name ));
7225
7240
RETURN_THROWS ();
7226
7241
}
7227
7242
@@ -7230,7 +7245,7 @@ ZEND_METHOD(ReflectionConstant, __construct)
7230
7245
intern -> ptr = const_ ;
7231
7246
intern -> ref_type = REF_TYPE_OTHER ;
7232
7247
7233
- ZVAL_STR_COPY (reflection_prop_name (object ), const_name );
7248
+ ZVAL_STR_COPY (reflection_prop_name (object ), name );
7234
7249
}
7235
7250
7236
7251
ZEND_METHOD (ReflectionConstant , getName )
0 commit comments