Bug #47405 [Ver]: Cannot access parent:: error reports wrong file/line

From: Date: Tue, 18 Feb 2020 05:56:36 +0000
Subject: Bug #47405 [Ver]: Cannot access parent:: error reports wrong file/line
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225606@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=47405&edit=1 ID: 47405 Updated by: carusogabriel@php.net Reported by: dennis at born05 dot nl -Summary: error reports wrong file/line +Summary: Cannot access parent:: error reports wrong file/line Status: Verified Type: Bug Package: Class/Object related Operating System: * -PHP Version: 5.*, 6CVS (2009-04-01) +PHP Version: 7.* Block user comment: N Private report: N New Comment: This is still a bug: https://3v4l.org/mOMRn. Previous Comments: ------------------------------------------------------------------------ [2009-02-16 11:49:21] dennis at born05 dot nl Description: ------------ When creating an instance of a class which tries to access a non- existent parent in the class definition it throws an error on the file/line where the class is instantiated while i would assume it should be thrown where the error occurs, ie where the class tries to access its non-existent parent. Reproduce code: --------------- <?php class myclass { public $foo = parent::BAR; } new myclass(); ?> Expected result: ---------------- Fatal error: Cannot access parent:: when current class scope has no parent in /my/file.php on line 4 (the line which refers to the non- existent parent) Actual result: -------------- Fatal error: Cannot access parent:: when current class scope has no parent in /var/www/html/swish/trunk/bug.php on line 6 (the line which creates the instance of myclass) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=47405&edit=1

« previous php.bugs (#225606) next »