Bug #54361 [Com]: Wrong line number in fatal error for bad namespace reference

From: Date: Thu, 02 Mar 2017 18:35:57 +0000
Subject: Bug #54361 [Com]: Wrong line number in fatal error for bad namespace reference
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207668@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=54361&edit=1

 ID:                 54361
 Comment by:         mail at pmmaga dot net
 Reported by:        robert at typo3 dot org
 Summary:            Wrong line number in fatal error for bad namespace
                     reference
 Status:             Open
 Type:               Bug
 Package:            Class/Object related
 Operating System:   MacOSX
 PHP Version:        5.3.6
 Block user comment: N
 Private report:     N

 New Comment:

Related to #47405


Previous Comments:
------------------------------------------------------------------------
[2011-03-23 17:58:39] 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>


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=54361&edit=1


Thread (3 messages)

« previous php.bugs (#207668) next »