2008-01-30 22:25:57 +08:00
|
|
|
--TEST--
|
|
|
|
Redeclare inherited public property as protected.
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
class A
|
|
|
|
{
|
|
|
|
public $p = "A::p";
|
|
|
|
function showA()
|
|
|
|
{
|
|
|
|
echo $this->p . "\n";
|
|
|
|
}
|
|
|
|
}
|
2018-10-14 23:45:48 +08:00
|
|
|
|
2008-01-30 22:25:57 +08:00
|
|
|
class B extends A
|
|
|
|
{
|
|
|
|
protected $p = "B::p";
|
|
|
|
function showB()
|
|
|
|
{
|
|
|
|
echo $this->p . "\n";
|
|
|
|
}
|
|
|
|
}
|
2018-10-14 23:45:48 +08:00
|
|
|
|
|
|
|
|
2008-01-30 22:25:57 +08:00
|
|
|
$a = new A;
|
|
|
|
$a->showA();
|
2018-10-14 23:45:48 +08:00
|
|
|
|
2008-01-30 22:25:57 +08:00
|
|
|
$b = new B;
|
|
|
|
$b->showA();
|
|
|
|
$b->showB();
|
|
|
|
?>
|
|
|
|
--EXPECTF--
|
|
|
|
Fatal error: Access level to B::$p must be public (as in class A) in %s on line 18
|