Skip to content

Commit 3b349db

Browse files
phpGH-15992: fix error message for single abstract method not implemented (phpGH-15993)
1 parent e035a95 commit 3b349db

18 files changed

+38
-26
lines changed

Zend/tests/bug69084.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ $b->main();
2626

2727
?>
2828
--EXPECTF--
29-
Fatal error: Class Bar contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Bar::doOtherStuff) in %s on line %d
29+
Fatal error: Class Bar contains 1 abstract method and must therefore be declared abstract or implement the remaining method (Bar::doOtherStuff) in %s on line %d

Zend/tests/errmsg_018.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ class test {
1010
echo "Done\n";
1111
?>
1212
--EXPECTF--
13-
Fatal error: Class test contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (test::foo) in %s on line %d
13+
Fatal error: Class test contains 1 abstract method and must therefore be declared abstract or implement the remaining method (test::foo) in %s on line %d

Zend/tests/property_hooks/abstract_get_set_readonly.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ class C extends P {
1010
}
1111
?>
1212
--EXPECTF--
13-
Fatal error: Class C contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (P::$prop::set) in %s on line %d
13+
Fatal error: Class C contains 1 abstract method and must therefore be declared abstract or implement the remaining method (P::$prop::set) in %s on line %d

Zend/tests/property_hooks/abstract_hook_in_non_abstract_class.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ class Test {
1212

1313
?>
1414
--EXPECTF--
15-
Fatal error: Class Test contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Test::$prop::get) in %s on line %d
15+
Fatal error: Class Test contains 1 abstract method and must therefore be declared abstract or implement the remaining method (Test::$prop::get) in %s on line %d

Zend/tests/property_hooks/abstract_hook_not_implemented.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ class B extends A {}
1414

1515
?>
1616
--EXPECTF--
17-
Fatal error: Class B contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (A::$prop::get) in %s on line %d
17+
Fatal error: Class B contains 1 abstract method and must therefore be declared abstract or implement the remaining method (A::$prop::get) in %s on line %d

Zend/tests/property_hooks/invalid_abstract_indirect.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ class B extends A {
1313

1414
?>
1515
--EXPECTF--
16-
Fatal error: Class B contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (A::$prop::get) in %s on line %d
16+
Fatal error: Class B contains 1 abstract method and must therefore be declared abstract or implement the remaining method (A::$prop::get) in %s on line %d

Zend/tests/property_hooks/invalid_abstract_indirect_2.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ class B extends A {
1212

1313
?>
1414
--EXPECTF--
15-
Fatal error: Class B contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (A::$prop::get) in %s on line %d
15+
Fatal error: Class B contains 1 abstract method and must therefore be declared abstract or implement the remaining method (A::$prop::get) in %s on line %d

Zend/tests/traits/bugs/abstract-methods01.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ $test = new TraitsTest();
1616
$test->hello();
1717
?>
1818
--EXPECTF--
19-
Fatal error: Class %s contains %d abstract method and must therefore be declared abstract or implement the remaining methods (%s) in %s on line %d
19+
Fatal error: Class %s contains %d abstract method and must therefore be declared abstract or implement the remaining method (%s) in %s on line %d

Zend/tests/traits/interface_002.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ new bar;
2121

2222
?>
2323
--EXPECTF--
24-
Fatal error: Class bar contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (baz::abc) in %s on line %d
24+
Fatal error: Class bar contains 1 abstract method and must therefore be declared abstract or implement the remaining method (baz::abc) in %s on line %d

Zend/zend_inheritance.c

+21-9
Original file line numberDiff line numberDiff line change
@@ -3009,16 +3009,28 @@ void zend_verify_abstract_class(zend_class_entry *ce) /* {{{ */
30093009
}
30103010

30113011
if (ai.cnt) {
3012-
zend_error_noreturn(E_ERROR, !is_explicit_abstract && can_be_abstract
3013-
? "%s %s contains %d abstract method%s and must therefore be declared abstract or implement the remaining methods (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")"
3014-
: "%s %s must implement %d abstract private method%s (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")",
3015-
zend_get_object_type_uc(ce),
3016-
ZSTR_VAL(ce->name), ai.cnt,
3017-
ai.cnt > 1 ? "s" : "",
3018-
DISPLAY_ABSTRACT_FN(0),
3019-
DISPLAY_ABSTRACT_FN(1),
3020-
DISPLAY_ABSTRACT_FN(2)
3012+
if (!is_explicit_abstract && can_be_abstract) {
3013+
zend_error_noreturn(E_ERROR,
3014+
"%s %s contains %d abstract method%s and must therefore be declared abstract or implement the remaining method%s (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")",
3015+
zend_get_object_type_uc(ce),
3016+
ZSTR_VAL(ce->name), ai.cnt,
3017+
ai.cnt > 1 ? "s" : "",
3018+
ai.cnt > 1 ? "s" : "",
3019+
DISPLAY_ABSTRACT_FN(0),
3020+
DISPLAY_ABSTRACT_FN(1),
3021+
DISPLAY_ABSTRACT_FN(2)
3022+
);
3023+
} else {
3024+
zend_error_noreturn(E_ERROR,
3025+
"%s %s must implement %d abstract private method%s (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")",
3026+
zend_get_object_type_uc(ce),
3027+
ZSTR_VAL(ce->name), ai.cnt,
3028+
ai.cnt > 1 ? "s" : "",
3029+
DISPLAY_ABSTRACT_FN(0),
3030+
DISPLAY_ABSTRACT_FN(1),
3031+
DISPLAY_ABSTRACT_FN(2)
30213032
);
3033+
}
30223034
} else {
30233035
/* now everything should be fine and an added ZEND_ACC_IMPLICIT_ABSTRACT_CLASS should be removed */
30243036
ce->ce_flags &= ~ZEND_ACC_IMPLICIT_ABSTRACT_CLASS;

tests/classes/abstract_by_interface_001.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ class Fails extends Root implements MyInterface {
3030
object(Leaf)#%d (0) {
3131
}
3232

33-
Fatal error: Class Fails contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (MyInterface::MyInterfaceFunc) in %sabstract_by_interface_001.php on line %d
33+
Fatal error: Class Fails contains 1 abstract method and must therefore be declared abstract or implement the remaining method (MyInterface::MyInterfaceFunc) in %sabstract_by_interface_001.php on line %d

tests/classes/abstract_by_interface_002.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ class Fails extends Root implements MyInterface {
3030
object(Leaf)#%d (0) {
3131
}
3232

33-
Fatal error: Class Fails contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (MyInterface::MyInterfaceFunc) in %sabstract_by_interface_002.php on line %d
33+
Fatal error: Class Fails contains 1 abstract method and must therefore be declared abstract or implement the remaining method (MyInterface::MyInterfaceFunc) in %sabstract_by_interface_002.php on line %d

tests/classes/abstract_derived.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ class derived extends base {
1313
?>
1414
===DONE===
1515
--EXPECTF--
16-
Fatal error: Class derived contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (derived::show) in %sabstract_derived.php on line %d
16+
Fatal error: Class derived contains 1 abstract method and must therefore be declared abstract or implement the remaining method (derived::show) in %sabstract_derived.php on line %d

tests/classes/abstract_not_declared.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ class fail {
1010
echo "Done\n"; // shouldn't be displayed
1111
?>
1212
--EXPECTF--
13-
Fatal error: Class fail contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (fail::show) in %s on line %d
13+
Fatal error: Class fail contains 1 abstract method and must therefore be declared abstract or implement the remaining method (fail::show) in %s on line %d

tests/classes/abstract_redeclare.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ class fail extends pass {
1616
echo "Done\n"; // Shouldn't be displayed
1717
?>
1818
--EXPECTF--
19-
Fatal error: Class fail contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (fail::show) in %sabstract_redeclare.php on line %d
19+
Fatal error: Class fail contains 1 abstract method and must therefore be declared abstract or implement the remaining method (fail::show) in %sabstract_redeclare.php on line %d

tests/classes/abstract_static.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ echo "Done\n"; // shouldn't be displayed
3131
--EXPECTF--
3232
Call to function show()
3333

34-
Fatal error: Class fail contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (fail::func) in %sabstract_static.php(%d) : eval()'d code on line %d
34+
Fatal error: Class fail contains 1 abstract method and must therefore be declared abstract or implement the remaining method (fail::func) in %sabstract_static.php(%d) : eval()'d code on line %d

tests/classes/interface_must_be_implemented.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ class derived_a implements if_a {
1212

1313
?>
1414
--EXPECTF--
15-
Fatal error: Class derived_a contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (if_a::f_a) in %s on line %d
15+
Fatal error: Class derived_a contains 1 abstract method and must therefore be declared abstract or implement the remaining method (if_a::f_a) in %s on line %d

tests/classes/interfaces_002.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ echo "Message: " . $foo->getMessage() . "\n";
2323
?>
2424
===DONE===
2525
--EXPECTF--
26-
Fatal error: Class Exception_foo contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (ThrowableInterface::getErrno) in %s on line %d
26+
Fatal error: Class Exception_foo contains 1 abstract method and must therefore be declared abstract or implement the remaining method (ThrowableInterface::getErrno) in %s on line %d

0 commit comments

Comments
 (0)