Skip to content

Commit a427595

Browse files
committed
Remove dependence on zend_resolve_property_type
We don't want to create dependencies between zend_execute and zend_inheritance...
1 parent 9f2734a commit a427595

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Zend/zend_execute.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -950,23 +950,28 @@ static zend_bool zend_verify_scalar_type_hint(zend_uchar type_hint, zval *arg, z
950950

951951
ZEND_COLD zend_never_inline void zend_verify_property_type_error(zend_property_info *info, zval *property)
952952
{
953+
const char *prop_type1, *prop_type2;
954+
953955
/* we _may_ land here in case reading already errored and runtime cache thus has not been updated (i.e. it contains a valid but unrelated info) */
954956
if (EG(exception)) {
955957
return;
956958
}
957959

960+
// TODO Switch to a more standard error message?
961+
zend_format_type(info->type, &prop_type1, &prop_type2);
962+
(void) prop_type1;
958963
if (ZEND_TYPE_IS_CLASS(info->type)) {
959964
zend_type_error("Typed property %s::$%s must be an instance of %s%s, %s used",
960965
ZSTR_VAL(info->ce->name),
961966
zend_get_unmangled_property_name(info->name),
962-
ZSTR_VAL(ZEND_TYPE_IS_CE(info->type) ? ZEND_TYPE_CE(info->type)->name : zend_resolve_property_type(ZEND_TYPE_NAME(info->type), info->ce)),
967+
prop_type2,
963968
ZEND_TYPE_ALLOW_NULL(info->type) ? " or null" : "",
964969
Z_TYPE_P(property) == IS_OBJECT ? ZSTR_VAL(Z_OBJCE_P(property)->name) : zend_get_type_by_const(Z_TYPE_P(property)));
965970
} else {
966971
zend_type_error("Typed property %s::$%s must be %s%s, %s used",
967972
ZSTR_VAL(info->ce->name),
968973
zend_get_unmangled_property_name(info->name),
969-
zend_get_type_by_const(ZEND_TYPE_CODE(info->type)),
974+
prop_type2,
970975
ZEND_TYPE_ALLOW_NULL(info->type) ? " or null" : "",
971976
Z_TYPE_P(property) == IS_OBJECT ? ZSTR_VAL(Z_OBJCE_P(property)->name) : zend_get_type_by_const(Z_TYPE_P(property)));
972977
}

Zend/zend_inheritance.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ void zend_verify_abstract_class(zend_class_entry *ce);
3333
void zend_check_deprecated_constructor(const zend_class_entry *ce);
3434
void zend_build_properties_info_table(zend_class_entry *ce);
3535

36-
zend_string* zend_resolve_property_type(zend_string *name, zend_class_entry *scope);
37-
3836
END_EXTERN_C()
3937

4038
#endif

0 commit comments

Comments
 (0)