Skip to content

Commit 518d7ea

Browse files
committed
Update wording for error message
1 parent d1bae38 commit 518d7ea

6 files changed

+14
-12
lines changed

Zend/tests/type_declarations/abstract_generics/constraints/implicit_interface_no_bound_types.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ class C implements I2<float>, I1 {
2020

2121
?>
2222
--EXPECTF--
23-
Fatal error: Cannot implement I1 as the number of generic arguments specified (0) does not match the number of generic parameters declared on the interface (1) in %s on line %d
23+
Fatal error: Interface I1 expects 1 generic parameters, 0 given in %s on line %d

Zend/tests/type_declarations/abstract_generics/constraints/implicit_interface_no_bound_types2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ class C implements I1, I2<float> {
1818

1919
?>
2020
--EXPECTF--
21-
Fatal error: Cannot implement I1 as it has generic parameters which are not specified in %s on line %d
21+
Fatal error: Interface I1 expects 1 generic parameters, 0 given in %s on line %d

Zend/tests/type_declarations/abstract_generics/errors/no_bound_abstract_generic_type.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ class C implements I {
1313

1414
?>
1515
--EXPECTF--
16-
Fatal error: Cannot implement I as it has generic parameters which are not specified in %s on line %d
16+
Fatal error: Interface I expects 1 generic parameters, 0 given in %s on line %d

Zend/tests/type_declarations/abstract_generics/errors/no_bound_abstract_generic_type_with_constraint.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ class C implements I {
1313

1414
?>
1515
--EXPECTF--
16-
Fatal error: Cannot implement I as it has generic parameters which are not specified in %s on line %d
16+
Fatal error: Interface I expects 1 generic parameters, 0 given in %s on line %d

Zend/tests/type_declarations/abstract_generics/errors/no_bound_abstract_generic_type_with_prior_bound_types.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ class C implements I1<float>, I2 {
1717

1818
?>
1919
--EXPECTF--
20-
Fatal error: Cannot implement I2 as it has generic parameters which are not specified in %s on line %d
20+
Fatal error: Interface I2 expects 1 generic parameters, 0 given in %s on line %d

Zend/zend_inheritance.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2323,25 +2323,27 @@ static void do_interface_implementation(zend_class_entry *ce, zend_class_entry *
23232323
if (iface->num_generic_parameters > 0) {
23242324
if (UNEXPECTED(ce->bound_types == NULL)) {
23252325
zend_error_noreturn(E_COMPILE_ERROR,
2326-
"Cannot implement %s as it has generic parameters which are not specified",
2327-
ZSTR_VAL(iface->name)
2326+
"Interface %s expects %" PRIu32 " generic parameters, 0 given",
2327+
ZSTR_VAL(iface->name),
2328+
iface->num_generic_parameters
23282329
);
23292330
}
23302331
HashTable *bound_types = zend_hash_find_ptr_lc(ce->bound_types, iface->name);
23312332
if (UNEXPECTED(bound_types == NULL)) {
23322333
zend_error_noreturn(E_COMPILE_ERROR,
2333-
"Cannot implement %s as it has generic parameters which are not specified",
2334-
ZSTR_VAL(iface->name)
2334+
"Interface %s expects %" PRIu32 " generic parameters, 0 given",
2335+
ZSTR_VAL(iface->name),
2336+
iface->num_generic_parameters
23352337
);
23362338
}
23372339
const uint32_t num_bound_types = zend_hash_num_elements(bound_types);
23382340
if (UNEXPECTED(num_bound_types != iface->num_generic_parameters)) {
23392341
// TODO Need to handle implicit inherited interfaces
23402342
zend_error_noreturn(E_COMPILE_ERROR,
2341-
"Cannot implement %s as the number of generic arguments specified (%" PRIu32 ") does not match the number of generic parameters declared on the interface (%" PRIu32 ")",
2343+
"Interface %s expects %" PRIu32 " generic parameters, %" PRIu32 " given",
23422344
ZSTR_VAL(iface->name),
2343-
num_bound_types,
2344-
iface->num_generic_parameters
2345+
iface->num_generic_parameters,
2346+
num_bound_types
23452347
);
23462348
}
23472349
for (uint32_t i = 0; i < num_bound_types; i++) {

0 commit comments

Comments
 (0)