Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93396 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67935 invoked from network); 19 May 2016 11:14:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 May 2016 11:14:37 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.218.41 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.218.41 mail-oi0-f41.google.com Received: from [209.85.218.41] ([209.85.218.41:33654] helo=mail-oi0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 28/50-61050-C10AD375 for ; Thu, 19 May 2016 07:14:36 -0400 Received: by mail-oi0-f41.google.com with SMTP id v145so122618240oie.0 for ; Thu, 19 May 2016 04:14:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mindplay-dk.20150623.gappssmtp.com; s=20150623; h=mime-version:date:message-id:subject:from:to; bh=6Qfsy4x5R3sP8TUeWIFoRIobr5ePtnZS9m7xEgqGC9Q=; b=Y5WgbIwlzl0fUxf1in/tRvIGcugzylm4V/Ei/0xyeXlTeDDxiN8Ugh/5QXfm1KQHrs MfJMSEud5pSG0y2g/XGOd9pXE/QMdKOIMPuhdSY1mmNF5+x/oO4yXMgf0ooQ4uvXU3Gj BXxkFMMs21iIXqlacfeS/ZPkwqyR8ndSL11QbFNXuIcHpJ1piUdO7zfUtW38uTXuQO+X aHSja74V3MmV4p2LGFE7UisXQV4Gwnt0k8X9zjjMimCKEtf8YtLHyFVJVkQBH/piiMZk t8+vk38rJMB8FrCh0tDVNUmB+iRp44UqskcLwFvZ1gBqJskQ9AhpMomheJL9CrTWX/Xi XMQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=6Qfsy4x5R3sP8TUeWIFoRIobr5ePtnZS9m7xEgqGC9Q=; b=fcxNGRpKiRa5ZuEBErnZgjHQPc2lP0y58VFew2TBML0gbJ+Edns9pvvWzY3aPc7OiH pRnEHaeEkbr9FibMqytPtXAAdQXR8UfftKJYhBUBhL6KLtWqC4avI4ruFJjF0z/s4c5j umkudoqbiNRCOU5GAPu4srkGUJcm1BR6o1rSTe16qu3lU3tl3gkARvA7LWlwYPH7J//5 eCU9PjiMFnpTolMhVIm2uB6Tq7pM5v9hWi0KwFNr9mrbpUoLFLMdOQZZb23+hNkRlU1V zOfwhd9CwAiM5mkj7ujX643rkFcrANmwiE24dGsizPzNdyCL8o9bWjST9CfrVFlUJccs uy3g== X-Gm-Message-State: AOPr4FWrsvNAX+SHDl4s3U0V5WZpLVzGyhiZxQDcVt7RJYJExN9hfN7G2/9+MDiDT1MB6OS6TLyb9qQPU1SBCw== MIME-Version: 1.0 X-Received: by 10.157.20.202 with SMTP id r10mr4241756otr.59.1463656473372; Thu, 19 May 2016 04:14:33 -0700 (PDT) Received: by 10.157.44.214 with HTTP; Thu, 19 May 2016 04:14:33 -0700 (PDT) Date: Thu, 19 May 2016 13:14:33 +0200 Message-ID: To: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Exception::getLine() From: rasmus@mindplay.dk (Rasmus Schultz) Does this work as intended? function create_exception() { return new RuntimeException(); // line 2 } try { throw create_exception(); // line 6 } catch (Exception $e) { var_dump($e); // => 2 } I would have expected Exception::getLine() to return 6 in this case - the line where the exception was thrown. I know that I can dig in via e.g. Exception::getStackTrace()[0]["line"] and pull the relevant line-number myself, but I'm wondering why the line-number 2 is relevant, important or interesting at all? It's not uncommon to have e.g. static factory methods inside the exception itself, which would cause the exception instance to report the line-number of the new-statement inside the factory constructor, which has no particular importance or relevance for any purpose, as far as I can figure. Apparently this has been reported as a bug before: https://bugs.php.net/bug.php?id=53882 There was talk of a fix in the comments, but it looks like this issue went stale and was closed without any further explanation? The documentation is also a little ambiguous on this point: http://php.net/manual/en/exception.getline.php At the top of the page, it says "Gets the line in which the exception occurred", which isn't correct. (The rest of the page correctly says "the line number where the exception was created") Would it adversely affect anything to fix this? It's technically a BC break, I guess. Perhaps adding a dedicated getLineThrown() method would be better with regards to BC?