php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43149 Problem with abstract functions and classes
Submitted: 2007-10-30 19:10 UTC Modified: 2007-11-12 10:06 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: henrik at bonest dot dk Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.2.4 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: henrik at bonest dot dk
New email:
PHP Version: OS:

 

 [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)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-31 16:48 UTC] crescentfreshpot at yahoo dot com
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.
 [2007-11-06 01:30 UTC] crescentfreshpot at yahoo dot com
bug #43200 closes this one
 [2007-11-12 10:06 UTC] tony2001@php.net
See bug #43200.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Oct 05 01:01:30 2024 UTC