From: frase at cs dot wisc dot edu Operating system: Ubuntu 7.10 PHP version: 5.2.5 PHP Bug Type: Class/Object related Bug description: class compilation notices refer to wrong line number
Description: ------------ If a class definition generates a notice, the line number printed with the notice corresponds to the first line in which the class is instantiated, and NOT the line which truly gives rise to the notice. Reproduce code: --------------- class OtherClass { // etc... } class TestClass { static $linkedClass = OtherClass; function __construct() { echo "I am linked to " . self::$linkedClass; } } $obj = new TestClass(); Expected result: ---------------- I am linked to OtherClass Actual result: -------------- Notice: Use of undefined constant OtherClass - assumed 'OtherClass' in test.php on line 10 I am linked to OtherClass Line 10 does not contain the phrase 'OtherClass' to begin with, as an undefined constant or otherwise, so the notice is confusing. The line on which the notice actually arises is line 5, where the class' static member is incorrectly initialized (it should, in fact, have been a string). Disclaimer: The need to have one class refer to another by name, as in this example, may seem odd but is irrelevant to this bug report (it arose for me because of a more complicated class inheritance need). I suspect any notice arising during a class' static member initialization will have the same wrong line-number; errors other than E_NOTICE might as well, I haven't taken the time to check exhaustively. -- Edit bug report at http://bugs.php.net/?id=44396&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44396&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44396&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44396&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44396&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44396&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44396&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44396&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44396&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44396&r=support Expected behavior: http://bugs.php.net/fix.php?id=44396&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44396&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44396&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44396&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44396&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44396&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44396&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44396&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44396&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44396&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44396&r=mysqlcfg