php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47294 Class inheritence isn't consistent
Submitted: 2009-02-03 19:03 UTC Modified: 2009-02-03 22:11 UTC
From: dmsuperman at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.2.8 OS: Linux Ubuntu
Private report: No CVE-ID: None
 [2009-02-03 19:03 UTC] dmsuperman at gmail dot com
Description:
------------
Class inheritence isn't consistent. The attach code basically explains it all.

Why would it choose to use the child class in the first case, but the parent class in the second? This seems wrong to me, like it's deciding when to use one over the other which makes for a confusing programming environment.

Reproduce code:
---------------
<?PHP
class blah {
    public $test = "A";
    public function __construct(){
        echo($this->test);
    }
}
class tacos extends blah {
    public $test = "B";
}
$tacos = new tacos();
//Output: B
//Expected output: B

class P {
    public function __construct() {
        $this->fun();
    }
    private function fun() {
        echo 'funny';
    }
}
class C extends P {
    public function fun(){
        echo "oranges";
    }
};
$var = new C();
//Output: funny
//Expected output: oranges
?>

Expected result:
----------------
Boranges

Actual result:
--------------
Bfunny

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-03 22:11 UTC] jani@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 10:01:32 2024 UTC