Bug #54361 [Com]: Wrong line number in fatal error for bad namespace reference
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)