Ticket #3583 (closed defect: fixed)

Opened 9 months ago

Last modified 2 months ago

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

Changed 9 months ago by weyrick

  • owner changed from anonymous to weyrick
  • status changed from new to assigned
  • milestone set to 2.9.7

Changed 9 months ago by weyrick

  • status changed from assigned to closed
  • resolution set to fixed

fixed in r506, thanks for the test case

Changed 2 months ago by anonymous

  • milestone 2.9.7 deleted

Milestone 2.9.7 deleted

Note: See TracTickets for help on using tickets.