Ticket #3583 (closed defect: fixed)
Fatal error: Call to protected method from context of '<derived class>'
| Reported by: | leniviy | Owned by: | weyrick |
|---|---|---|---|
| Priority: | immediate | Milestone: | |
| Component: | PHP Compatability | Version: | |
| Severity: | block | Keywords: | |
| Cc: |
Description
index.php:
<?php
class C1
{
public function __construct()
{
echo "C1 created <br />\n";
$this->addMessage('C1');
}
protected function addMessage($message)
{
echo "C1::addMessage($message) <br />\n";
}
}
class C2 extends C1
{
public function __construct()
{
parent::__construct();
echo "C2 created <br />\n";
$this->addMessage('C2');
}
}
class C3 extends C2
{
public function __construct()
{
parent::__construct();
echo "C3 created <br />\n";
$this->addMessage('C3');
}
}
$c1 = new C3 ();
?>
# pcc -i index.php C1 created <br /> C1::addMessage(C1) <br /> C2 created <br /> Fatal error: Call to protected method C1::addMessage() from context 'C2' in /srv/www/lighttpd/repr/index.php on line 20
Change History
Note: See
TracTickets for help on using
tickets.
