php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #53882 Exception::getLine method returns line where Exception created not Thrown
Submitted: 2011-01-30 01:01 UTC Modified: 2011-02-10 16:03 UTC
From: james at jarofgreen dot co dot uk Assigned: vrana
Status: Closed Package: *General Issues
PHP Version: Irrelevant OS: Ubuntu
Private report: No CVE-ID:
 [2011-01-30 01:01 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-10 16:03 UTC] 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-02-10 16:03 UTC] vrana@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: vrana
 [2011-02-10 16:03 UTC] 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 23:25 UTC] james at jarofgreen dot co dot uk
> 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!
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 24 21:01:55 2014 UTC