Improve error message when overriding untyped property with typed property (GH-16866)

This commit is contained in:
chx 2024-11-20 11:59:29 +01:00 committed by GitHub
parent 4b211a7769
commit e5c2bc41ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 3 deletions

View File

@ -15,4 +15,4 @@ class Bar extends Foo
?>
--EXPECTF--
Fatal error: Type of Bar::$property1 must not be defined (as in class Foo) in %s on line %d
Fatal error: Type of Bar::$property1 must be omitted to match the parent definition in class Foo in %s on line %d

View File

@ -11,4 +11,4 @@ class Baz extends Foo{
}
?>
--EXPECTF--
Fatal error: Type of Baz::$bar must not be defined (as in class Foo) in %s on line 6
Fatal error: Type of Baz::$bar must be omitted to match the parent definition in class Foo in %s on line 6

View File

@ -1507,7 +1507,7 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke
}
} else if (UNEXPECTED(ZEND_TYPE_IS_SET(child_info->type) && !ZEND_TYPE_IS_SET(parent_info->type))) {
zend_error_noreturn(E_COMPILE_ERROR,
"Type of %s::$%s must not be defined (as in class %s)",
"Type of %s::$%s must be omitted to match the parent definition in class %s",
ZSTR_VAL(ce->name),
ZSTR_VAL(key),
ZSTR_VAL(parent_info->ce->name));