Doc #53882 [Com]: Exception::getLine method returns line where Exception created not Thrown

From: Date: Thu, 10 Feb 2011 22:25:33 +0000
Subject: Doc #53882 [Com]: Exception::getLine method returns line where Exception created not Thrown
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-5971@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53882&edit=1 ID: 53882 Comment by: james at jarofgreen dot co dot uk Reported by: james at jarofgreen dot co dot uk Summary: Exception::getLine method returns line where Exception created not Thrown Status: Closed Type: Documentation Problem Package: *General Issues Operating System: Ubuntu PHP Version: Irrelevant Assigned To: vrana Block user comment: N Private report: N New Comment: > Valid also for getFile(). Yeah, I assumed it'd apply to a couple of functions on the Exception class but this was the easiest to prove so I thought I'd do this first and see if it got picked up. Thanks! Previous Comments: ------------------------------------------------------------------------ [2011-02-10 16:03:48] vrana@php.net This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Valid also for getFile(). ------------------------------------------------------------------------ [2011-02-10 16:03:44] vrana@php.net Automatic comment from SVN on behalf of vrana Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=308198 Log: Exception informs about the point of creation not throwing (doc bug #53882) ------------------------------------------------------------------------ [2011-01-30 01:01:28] james at jarofgreen dot co dot uk Description: ------------ http://www.php.net/manual/en/exception.getline.php says "Returns line number where the exception was thrown." However it seems to be returning the line number the Exception was created, not thrown. Either: A) This is a code bug. B) This is a documentation bug. I am using PHP Version 5.3.3-1ubuntu9.3 I found http://bugs.php.net/bug.php?id=33407 which seems to suggest this is how the code is meant to work. In this case the documentation is wrong. Test script: --------------- Change the sample code from that page slightly to: <?php try { $e = new Exception("Some error message"); throw $e; } catch(Exception $e) { echo "The exception was thrown on line: " . $e->getLine(); } ?> Expected result: ---------------- The exception was thrown on line: 4 Because line 4 is the line where the Exception was Thrown. Actual result: -------------- The exception was thrown on line: 3 That's the line where the Exception was created. This contradicts the documentation. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53882&edit=1

« previous php.doc.bugs (#5971) next »