@@ -1167,7 +1167,15 @@ static zend_string *resolve_class_name(zend_string *name, zend_class_entry *scop
11671167 name = scope -> parent -> name ;
11681168 }
11691169 }
1170- return name ;
1170+
1171+ /* The resolved name for anonymous classes contains null bytes. Cut off everything after the
1172+ * null byte here, to avoid larger parts of the type being omitted by printing code later. */
1173+ size_t len = strlen (ZSTR_VAL (name ));
1174+ if (len != ZSTR_LEN (name )) {
1175+ ZEND_ASSERT (scope && "This should only happen with resolved types" );
1176+ return zend_string_init (ZSTR_VAL (name ), len , 0 );
1177+ }
1178+ return zend_string_copy (name );
11711179}
11721180
11731181zend_string * zend_type_to_string_resolved (zend_type type , zend_class_entry * scope ) {
@@ -1179,11 +1187,13 @@ zend_string *zend_type_to_string_resolved(zend_type type, zend_class_entry *scop
11791187 if (ZEND_TYPE_HAS_CE (* list_type )) {
11801188 str = add_type_string (str , ZEND_TYPE_CE (* list_type )-> name );
11811189 } else {
1182- str = add_type_string (str , resolve_class_name (ZEND_TYPE_NAME (* list_type ), scope ));
1190+ zend_string * resolved = resolve_class_name (ZEND_TYPE_NAME (* list_type ), scope );
1191+ str = add_type_string (str , resolved );
1192+ zend_string_release (resolved );
11831193 }
11841194 } ZEND_TYPE_LIST_FOREACH_END ();
11851195 } else if (ZEND_TYPE_HAS_NAME (type )) {
1186- str = zend_string_copy ( resolve_class_name (ZEND_TYPE_NAME (type ), scope ) );
1196+ str = resolve_class_name (ZEND_TYPE_NAME (type ), scope );
11871197 } else if (ZEND_TYPE_HAS_CE (type )) {
11881198 str = zend_string_copy (ZEND_TYPE_CE (type )-> name );
11891199 }
0 commit comments