Bug #47405 [Ver->Dup]: Cannot access parent:: error reports wrong file/line
Edit report at https://bugs.php.net/bug.php?id=47405&edit=1
ID: 47405
Updated by: cmb@php.net
Reported by: dennis at born05 dot nl
Summary: Cannot access parent:: error reports wrong file/line
-Status: Verified
+Status: Duplicate
Type: Bug
Package: Class/Object related
Operating System: *
PHP Version: 7.*
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Closing as duplicate of <https://github.com/php/php-src/issues/7771>.
Previous Comments:
------------------------------------------------------------------------
[2021-07-19 13:45:37] cmb@php.net
Related To: Bug #54361
------------------------------------------------------------------------
[2020-02-18 05:56:36] carusogabriel@php.net
This is still a bug: https://3v4l.org/mOMRn.
------------------------------------------------------------------------
[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
Thread (4 messages)