|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-10-30 19:10 UTC] henrik at bonest dot dk
Description:
------------
An abstract class should hold one abstract methods.
The class that implements it, may not be declared abstract, but this simple structure does not give the results expected
Reproduce code:
---------------
abstract class bizView {
abstract public function getHTML();
}
abstract class bizViewFront extends bizView
{
abstract public function getHTML();
public function somethingelse() {
echo "Something";
}
}
class bizViewOutput extends bizViewFront
{
public function getHTML() {
echo "HTML";
}
}
$test = new bizViewOutput();
$test->getHTML();
Expected result:
----------------
I would expect the text "HTML" to be printed, because the getHTML function is implemented in the child class but declared abstract in the base abstract classes.
This is a common OOP practice.
Actual result:
--------------
Fatal error: Can't inherit abstract function bizView::getHTML() (previously declared abstract in bizViewFront)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 29 22:00:01 2025 UTC |
Smaller Reproduce code: ----------------------- <?php abstract class bizView { abstract public function getHTML(); } abstract class bizViewFront extends bizView { abstract public function getHTML(); } ?> Actual Result: -------------- Fatal error: Can't inherit abstract function bizView::getHTML() (previously declared abstract in bizViewFront) Why one would include the second [duplicate] declaration in the child class is beyond me.