php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47405 Cannot access parent:: error reports wrong file/line
Submitted: 2009-02-16 11:49 UTC Modified: 2021-12-14 13:33 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: dennis at born05 dot nl Assigned: cmb (profile)
Status: Duplicate Package: Class/Object related
PHP Version: 7.* OS: *
Private report: No CVE-ID: None
 [2009-02-16 11:49 UTC] 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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-02-18 05:56 UTC] carusogabriel@php.net
-Summary: error reports wrong file/line +Summary: Cannot access parent:: error reports wrong file/line -PHP Version: 5.*, 6CVS (2009-04-01) +PHP Version: 7.*
 [2020-02-18 05:56 UTC] carusogabriel@php.net
This is still a bug: https://3v4l.org/mOMRn.
 [2021-12-14 13:33 UTC] cmb@php.net
-Status: Verified +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2021-12-14 13:33 UTC] cmb@php.net
Closing as duplicate of <https://github.com/php/php-src/issues/7771>.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 05:01:29 2024 UTC