php-src/tests/classes/property_override_public_protected.phpt
Nikita Popov 380e705fc2 Use consistent line numbers for early binding errors
Non-early-bound classes report inheritance errors at the first line
of the class, if no better line information is available (we should
really store line numbers for properties at least...) Early bound
classes report it at the last line of the class instead.

Make the error reporting consistent by always reporting at the
first line.
2021-07-28 12:35:20 +02:00

33 lines
492 B
PHP

--TEST--
Redeclare inherited public property as protected.
--FILE--
<?php
class A
{
public $p = "A::p";
function showA()
{
echo $this->p . "\n";
}
}
class B extends A
{
protected $p = "B::p";
function showB()
{
echo $this->p . "\n";
}
}
$a = new A;
$a->showA();
$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 11