<?php
abstract class PageObject
{
const X = "Don't print this!";
public function __construct()
{
echo self::X;
echo static::X;
echo parent::X;
}
}
class Test extends PageObject
{
const X = "OMG";
public function __construct()
{
parent::__construct();
}
}
$x = new Test;
Fatal error: Cannot use "parent" when current class scope has no parent in /in/9fLAG on line 11
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Deprecated: Cannot use "parent" when current class scope has no parent in /in/9fLAG on line 11
Don't print this!OMG
Fatal error: Uncaught Error: Cannot access parent:: when current class scope has no parent in /in/9fLAG:11
Stack trace:
#0 /in/9fLAG(21): PageObject->__construct()
#1 /in/9fLAG(27): Test->__construct()
#2 {main}
thrown in /in/9fLAG on line 11
Process exited with code 255.
Don't print this!OMG
Fatal error: Uncaught Error: Cannot access parent:: when current class scope has no parent in /in/9fLAG:11
Stack trace:
#0 /in/9fLAG(21): PageObject->__construct()
#1 /in/9fLAG(27): Test->__construct()
#2 {main}
thrown in /in/9fLAG on line 11
Process exited with code 255.