From b8012fe234d5ed7b269d093eefc80a752db3353f Mon Sep 17 00:00:00 2001 From: chx Date: Tue, 19 Nov 2024 22:41:39 +0100 Subject: [PATCH 1/7] Make error message clearer in zend_inheritance.c --- Zend/zend_inheritance.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 3e09206b31566..b8e9d9cc70456 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -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 not be defined (because it is already defined in class %s)", ZSTR_VAL(ce->name), ZSTR_VAL(key), ZSTR_VAL(parent_info->ce->name)); From f169f4ff1f7e7eff775a03aa84cd4e47bbf366b3 Mon Sep 17 00:00:00 2001 From: chx Date: Tue, 19 Nov 2024 22:49:16 +0100 Subject: [PATCH 2/7] Update zend_inheritance.c --- Zend/zend_inheritance.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index b8e9d9cc70456..2f67dfe225e51 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -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 (because it is already defined in class %s)", + "Type of %s::$%s must not be defined (because it is already differently defined in class %s)", ZSTR_VAL(ce->name), ZSTR_VAL(key), ZSTR_VAL(parent_info->ce->name)); From 4445064308931bf72f4f16acbce2586343a575cf Mon Sep 17 00:00:00 2001 From: chx Date: Tue, 19 Nov 2024 22:52:11 +0100 Subject: [PATCH 3/7] Update zend_inheritance.c --- Zend/zend_inheritance.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 2f67dfe225e51..b0ee0b57bcdd9 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -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 (because it is already differently defined in class %s)", + "Type of %s::$%s must not be defined (it must match the definition in class %s)", ZSTR_VAL(ce->name), ZSTR_VAL(key), ZSTR_VAL(parent_info->ce->name)); From 9a770800d0a63c016cd92fcaa9bec9f6acff7ad1 Mon Sep 17 00:00:00 2001 From: chx Date: Tue, 19 Nov 2024 23:03:39 +0100 Subject: [PATCH 4/7] Apply suggestions from code review Co-authored-by: Ilija Tovilo --- Zend/zend_inheritance.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index b0ee0b57bcdd9..d85bfeb6ae2ab 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -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 (it must match the definition 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)); From 2fbea39ff0f3b2e5d4411dcf63e38e67d182b386 Mon Sep 17 00:00:00 2001 From: chx Date: Tue, 19 Nov 2024 23:20:27 +0100 Subject: [PATCH 5/7] Update typed_properties_035.phpt --- Zend/tests/type_declarations/typed_properties_035.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/tests/type_declarations/typed_properties_035.phpt b/Zend/tests/type_declarations/typed_properties_035.phpt index 165479021a77b..ee7085d8837cc 100644 --- a/Zend/tests/type_declarations/typed_properties_035.phpt +++ b/Zend/tests/type_declarations/typed_properties_035.phpt @@ -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 From 085e17d3f02d858978711e32ace2c0967c57f3c8 Mon Sep 17 00:00:00 2001 From: chx Date: Tue, 19 Nov 2024 23:21:19 +0100 Subject: [PATCH 6/7] Update mixed_property_inheritance_error7.phpt --- .../mixed/inheritance/mixed_property_inheritance_error7.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/tests/type_declarations/mixed/inheritance/mixed_property_inheritance_error7.phpt b/Zend/tests/type_declarations/mixed/inheritance/mixed_property_inheritance_error7.phpt index 138952b3df56b..94f98f700111c 100644 --- a/Zend/tests/type_declarations/mixed/inheritance/mixed_property_inheritance_error7.phpt +++ b/Zend/tests/type_declarations/mixed/inheritance/mixed_property_inheritance_error7.phpt @@ -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 be omitted to match the parent definition in class Foo in %s on line %d From fe0941cde189d527bc0c214a07d8ecda65cdd69e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 20 Nov 2024 10:18:08 +0100 Subject: [PATCH 7/7] Fix expectation in mixed_property_inheritance_error7.phpt --- .../mixed/inheritance/mixed_property_inheritance_error7.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/tests/type_declarations/mixed/inheritance/mixed_property_inheritance_error7.phpt b/Zend/tests/type_declarations/mixed/inheritance/mixed_property_inheritance_error7.phpt index 94f98f700111c..0a63cc23df9fd 100644 --- a/Zend/tests/type_declarations/mixed/inheritance/mixed_property_inheritance_error7.phpt +++ b/Zend/tests/type_declarations/mixed/inheritance/mixed_property_inheritance_error7.phpt @@ -15,4 +15,4 @@ class Bar extends Foo ?> --EXPECTF-- -Fatal error: Type of Bar::$property1 be omitted to match the parent definition 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