mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
GH-15992: fix error message for single abstract method not implemented (GH-15993)
This commit is contained in:
@@ -26,4 +26,4 @@ $b->main();
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
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
|
||||
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
|
||||
|
||||
@@ -10,4 +10,4 @@ class test {
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
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
|
||||
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
|
||||
|
||||
@@ -10,4 +10,4 @@ class C extends P {
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
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
|
||||
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
|
||||
|
||||
@@ -12,4 +12,4 @@ class Test {
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
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
|
||||
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
|
||||
|
||||
@@ -14,4 +14,4 @@ class B extends A {}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
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
|
||||
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
|
||||
|
||||
@@ -13,4 +13,4 @@ class B extends A {
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
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
|
||||
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
|
||||
|
||||
@@ -12,4 +12,4 @@ class B extends A {
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
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
|
||||
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
|
||||
|
||||
@@ -16,4 +16,4 @@ $test = new TraitsTest();
|
||||
$test->hello();
|
||||
?>
|
||||
--EXPECTF--
|
||||
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
|
||||
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
|
||||
|
||||
@@ -21,4 +21,4 @@ new bar;
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
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
|
||||
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
|
||||
|
||||
@@ -3009,16 +3009,28 @@ void zend_verify_abstract_class(zend_class_entry *ce) /* {{{ */
|
||||
}
|
||||
|
||||
if (ai.cnt) {
|
||||
zend_error_noreturn(E_ERROR, !is_explicit_abstract && can_be_abstract
|
||||
? "%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 ")"
|
||||
: "%s %s must implement %d abstract private method%s (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")",
|
||||
zend_get_object_type_uc(ce),
|
||||
ZSTR_VAL(ce->name), ai.cnt,
|
||||
ai.cnt > 1 ? "s" : "",
|
||||
DISPLAY_ABSTRACT_FN(0),
|
||||
DISPLAY_ABSTRACT_FN(1),
|
||||
DISPLAY_ABSTRACT_FN(2)
|
||||
if (!is_explicit_abstract && can_be_abstract) {
|
||||
zend_error_noreturn(E_ERROR,
|
||||
"%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 ")",
|
||||
zend_get_object_type_uc(ce),
|
||||
ZSTR_VAL(ce->name), ai.cnt,
|
||||
ai.cnt > 1 ? "s" : "",
|
||||
ai.cnt > 1 ? "s" : "",
|
||||
DISPLAY_ABSTRACT_FN(0),
|
||||
DISPLAY_ABSTRACT_FN(1),
|
||||
DISPLAY_ABSTRACT_FN(2)
|
||||
);
|
||||
} else {
|
||||
zend_error_noreturn(E_ERROR,
|
||||
"%s %s must implement %d abstract private method%s (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")",
|
||||
zend_get_object_type_uc(ce),
|
||||
ZSTR_VAL(ce->name), ai.cnt,
|
||||
ai.cnt > 1 ? "s" : "",
|
||||
DISPLAY_ABSTRACT_FN(0),
|
||||
DISPLAY_ABSTRACT_FN(1),
|
||||
DISPLAY_ABSTRACT_FN(2)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
/* now everything should be fine and an added ZEND_ACC_IMPLICIT_ABSTRACT_CLASS should be removed */
|
||||
ce->ce_flags &= ~ZEND_ACC_IMPLICIT_ABSTRACT_CLASS;
|
||||
|
||||
@@ -30,4 +30,4 @@ class Fails extends Root implements MyInterface {
|
||||
object(Leaf)#%d (0) {
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
@@ -30,4 +30,4 @@ class Fails extends Root implements MyInterface {
|
||||
object(Leaf)#%d (0) {
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
@@ -13,4 +13,4 @@ class derived extends base {
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
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
|
||||
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
|
||||
|
||||
@@ -10,4 +10,4 @@ class fail {
|
||||
echo "Done\n"; // shouldn't be displayed
|
||||
?>
|
||||
--EXPECTF--
|
||||
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
|
||||
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
|
||||
|
||||
@@ -16,4 +16,4 @@ class fail extends pass {
|
||||
echo "Done\n"; // Shouldn't be displayed
|
||||
?>
|
||||
--EXPECTF--
|
||||
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
|
||||
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
|
||||
|
||||
@@ -31,4 +31,4 @@ echo "Done\n"; // shouldn't be displayed
|
||||
--EXPECTF--
|
||||
Call to function show()
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
@@ -12,4 +12,4 @@ class derived_a implements if_a {
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
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
|
||||
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
|
||||
|
||||
@@ -23,4 +23,4 @@ echo "Message: " . $foo->getMessage() . "\n";
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
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
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user