Skip to content

Commit e5c2bc4

Browse files
authored
Improve error message when overriding untyped property with typed property (phpGH-16866)
1 parent 4b211a7 commit e5c2bc4

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

Zend/tests/type_declarations/mixed/inheritance/mixed_property_inheritance_error7.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ class Bar extends Foo
1515

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

Zend/tests/type_declarations/typed_properties_035.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ class Baz extends Foo{
1111
}
1212
?>
1313
--EXPECTF--
14-
Fatal error: Type of Baz::$bar must not be defined (as in class Foo) in %s on line 6
14+
Fatal error: Type of Baz::$bar must be omitted to match the parent definition in class Foo in %s on line 6

Zend/zend_inheritance.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1507,7 +1507,7 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke
15071507
}
15081508
} else if (UNEXPECTED(ZEND_TYPE_IS_SET(child_info->type) && !ZEND_TYPE_IS_SET(parent_info->type))) {
15091509
zend_error_noreturn(E_COMPILE_ERROR,
1510-
"Type of %s::$%s must not be defined (as in class %s)",
1510+
"Type of %s::$%s must be omitted to match the parent definition in class %s",
15111511
ZSTR_VAL(ce->name),
15121512
ZSTR_VAL(key),
15131513
ZSTR_VAL(parent_info->ce->name));

0 commit comments

Comments
 (0)