php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54361 Wrong line number in fatal error for bad namespace reference
Submitted: 2011-03-23 17:58 UTC Modified: 2021-07-19 13:45 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: robert at typo3 dot org Assigned: cmb (profile)
Status: Duplicate Package: Class/Object related
PHP Version: 5.3.6 OS: MacOSX
Private report: No CVE-ID: None
 [2011-03-23 17:58 UTC] robert at typo3 dot org
Description:
------------
When referring to a not existing namespace / class in a variable assignment of a 
class (see code example), a fatal error is (correctly) triggered. 

However, the error does not give a hint at where the problem actually lies but 
refers to the location where the faulty class is instantiated.

Test script:
---------------
namespace FooNamespace {
	class FooClass {
		const MYCONST = 1;
	}
}

namespace BarNamespace {

		// this would prevent the fatal error:
#	use FooNamespace as Foo;
	
	class BarClass {
			// the error is triggered by this line:
		protected $variable = Foo\FooClass::MYCONST;
	}
}

namespace {
		// "Fatal error: Class 'BarNamespace\Foo\FooClass' not found in" the following line:
	$bar = new \BarNamespace\BarClass();
}

Expected result:
----------------
Fatal error: Class 'BarNamespace\Foo\FooClass' not found in test.php on line <line 
number of the variable assignment in BarClass>

Actual result:
--------------
Fatal error: Class 'BarNamespace\Foo\FooClass' not found in test.php on line <line 
number of new statement>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-02 18:35 UTC] mail at pmmaga dot net
Related to #47405
 [2021-07-19 13:45 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2021-07-19 13:45 UTC] cmb@php.net
Closing as duplicate of bug #47405.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 19 00:03:39 2021 UTC