Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67367 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40738 invoked from network); 7 May 2013 23:00:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 May 2013 23:00:52 -0000 Authentication-Results: pb1.pair.com smtp.mail=zelnaga@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=zelnaga@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.173 as permitted sender) X-PHP-List-Original-Sender: zelnaga@gmail.com X-Host-Fingerprint: 209.85.212.173 mail-wi0-f173.google.com Received: from [209.85.212.173] ([209.85.212.173:37493] helo=mail-wi0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 37/CD-06696-3A789815 for ; Tue, 07 May 2013 19:00:51 -0400 Received: by mail-wi0-f173.google.com with SMTP id ey16so4362557wid.6 for ; Tue, 07 May 2013 16:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=8sexphgoa1MDw+e1uwdTJ3FH6hlqLLwx7asrgwEi2sw=; b=SerHvzFCupfdo6QlRT3VZcdJoWrCfQ7Ew6doa5z7ddickPmpkrQBlBd5shuNTSvaW4 uHA+yjqqnjEgwzwoNbRXni0TQEvGMIldBH5S+vcGa268YPdNtn9Gb5pE3bbZOd/ywr/5 ecxWJlguc7Ir/7CSYX6dezFQSjoLkt6F380VAyGKYbwpewel+tql9mYrqc4UoU/AI3CK //0j68KOPlpYOz7jgCJarcFvrfKgnMqt0ka6tUstYe3W3ZkIcD4TPmo1LgZcbCxFnTAC 6CisCn0KFc8mY+me4v8WWJvKyAaBMwvSvTFJy0pAB6IOgLysGhPU5vXu8YQd2g4YtSq0 OfYg== MIME-Version: 1.0 X-Received: by 10.180.37.109 with SMTP id x13mr15727339wij.20.1367967648285; Tue, 07 May 2013 16:00:48 -0700 (PDT) Received: by 10.194.77.48 with HTTP; Tue, 7 May 2013 16:00:48 -0700 (PDT) In-Reply-To: References: <51895FF2.3080809@sugarcrm.com> Date: Tue, 7 May 2013 18:00:48 -0500 Message-ID: To: Sebastian Krebs Cc: Bob Weinand , Stas Malyshev , PHP Mailing List Developers Content-Type: multipart/alternative; boundary=e89a8f6473f5bd8a0804dc28c96b Subject: Re: [PHP-DEV] idea: letting the line number and file name be set via user_error From: zelnaga@gmail.com (Thomas Anderson) --e89a8f6473f5bd8a0804dc28c96b Content-Type: text/plain; charset=ISO-8859-1 On Tue, May 7, 2013 at 4:30 PM, Sebastian Krebs wrote: > 2013/5/7 Bob Weinand > > > > > Am 7.5.2013 um 22:11 schrieb Stas Malyshev : > > > > > Hi! > > > > > >> And today we have the problem that we cannot use in any useful manner > > >> trigger_error in libraries, when we don't know where the error > > >> originates from. You debug today trigger_error's in libraries with > > >> putting a debug_print_backtrace behind the trigger_error. I think you > > > > > > Why not use a debugger to debug? Debuggers have backtrace tools. > > > > > >> (there you can add a backtrace) too, but you have to catch them, if > > >> not your script will abort; but I only need a notice...) > > > > > > If you need additional information in the notice, you can always add it > > > to the text of the notice. > > > > > > -- > > > Stanislav Malyshev, Software Architect > > > SugarCRM: http://www.sugarcrm.com/ > > > (408)454-6900 ext. 227 > > > > > > -- > > > PHP Internals - PHP Runtime Development Mailing List > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > nothing against the debugger, but it'd be something really time saving to > > see the entry point instantly instead of having to use the debugger > first... > > > > And yes, I can add it to the text (I can even add a function between > which > > analyses the backtrace first), but I think we need more useful (= more > > information) error throwing in PHP? > > > > How do you want to find out, which call _initially_ set the invalid values? > Is this even (reliable) possible? I've given an example, that it isn't that > trivial. > So even if you have the two additional parameters, what will you set there > (except maybe something like "__LINE__-4", which is as trivial as useless)? > With this in mind: How do you think the additional parameters _can_ help? > > Another example > > function foo() { > return 0; > } > > function bar($a) { > div($a); > } > > function div($a) { > if ($a == 0) trigger_error(''); > } > > div(bar(foo())); > > Which line should the message report now: > > - bar() because it calls div()? > - or foo() because it is the function, that returns the invalid value, that > is used later? But 0 is maybe a valid return value for foo()? > - or div(bar(foo()));, but how to find out, that foo() _really_ returned > the invalid value? > > Like in my other example you can report any file and line you want and > which is maybe/probably involved, but in most if not all cases it doesn't > prevent you from debugging. > PHP wouldn't auto-magically be figuring it out - the person writing the PHP code would be the one to figure it out. If you wrote a bigint library and of those three functions the only one you wrote was div() then presumably you - as the author of that bigint library - would make it show the line number on which the div() was called. Maybe bar() and foo() trigger errors as well.. who knows. Just because you have everything on the same line doesn't mean you can't have multiple errors on the same line. That's really the business of the end-user using the bigint lib. And if you, as a PHP developer, wrote all three functions - foo(), bar() and div()... it's up to you which one shows up as being the call that caused the error. PHP shouldn't be trying to auto-magically figure it out nor was that my proposal. It's like... if someone writes a callback function for preg_replace() the person who wrote that function is going to be the one who decides what subpattern - if any - that function is going to look at. I don't know why anyone would expect PHP to auto-magically figure it out. --e89a8f6473f5bd8a0804dc28c96b--