Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69776 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56729 invoked from network); 22 Oct 2013 18:41:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Oct 2013 18:41:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.47 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.219.47 mail-oa0-f47.google.com Received: from [209.85.219.47] ([209.85.219.47:36252] helo=mail-oa0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 73/5A-10840-6F6C6625 for ; Tue, 22 Oct 2013 14:41:58 -0400 Received: by mail-oa0-f47.google.com with SMTP id i18so4071487oag.34 for ; Tue, 22 Oct 2013 11:41:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=ug4+UKTZlpeFIXKd8g0XYe8uFmKGX9iTBNmJ+THAd2I=; b=UjM5/KgXH+V0amXjdYU9zL8TVSwCmyJxXpD26mFusO4lXAAzPGd0F2h3XBsYng3qHi bIPni2ddp2ar0joUXLnuda9rcqxmCzo1eDxOgs9rvM7X2y238nDdl4J2q4v1Hb6IRvXX iZymy2IbwmrcpPAaGls0Y28y8XY4vQQVhBkjLfbcoWRCIssanaf2iZYVjhoHF5PatOnV BZZv6BzFkRuLqpck8AGxkyXA0YAZgcRD4rMDiDokZL7mKQPHJfuiQW05fpiZFm4qJTGg qhaNxxwvfRhtLRnF2l5HI0443sJCjijC7hM33kEOg/jpVkGXlfby+KGsWZoZ5JmOydqs PIpg== MIME-Version: 1.0 X-Received: by 10.182.165.5 with SMTP id yu5mr512000obb.93.1382467315620; Tue, 22 Oct 2013 11:41:55 -0700 (PDT) Received: by 10.182.54.112 with HTTP; Tue, 22 Oct 2013 11:41:55 -0700 (PDT) In-Reply-To: References: <3D.BC.23638.84CA1625@pb1.pair.com> <5264FE65.8050808@php.net> <5266B6A8.4010607@pthreads.org> <5266BECD.8000204@php.net> Date: Tue, 22 Oct 2013 20:41:55 +0200 Message-ID: To: Patrick Schaaf Cc: Joe Watkins , Adam Harvey , internals Content-Type: multipart/alternative; boundary=001a11c2ff22433a5604e958c10b Subject: Re: [PHP-DEV] RFC: Expectations From: nikita.ppv@gmail.com (Nikita Popov) --001a11c2ff22433a5604e958c10b Content-Type: text/plain; charset=ISO-8859-1 On Tue, Oct 22, 2013 at 8:32 PM, Patrick Schaaf wrote: > Am 22.10.2013 20:07 schrieb "Joe Watkins" : > > > > You can catch exceptions, and log them. > > You can do that without impacting everything around you, you can do that, > or whatever else you like. > > You can do that handling when you have only a few toplevel scripts, like > when you have a setup with a small number of toplevel controllers and > almost no CLI stuff around. But due to the scoped nature of try/catch you > cannot reasonably / painlessly do that when you have 270 toplevel web and > CLI entry points that then each need such a try/catch block. > > Also, there is the problem with catch (Exception) blocks, which you might > easily dismiss as bad form, but which I'm sure are widespread in the field > - I certainly know they are in our codebase... > > On the other hand, setup of an assertion-failed callback can easily go into > an auto_prepend file, or into any other standard include (autoloader or > something) you might have - exactly because it is something done on the > global level instead of the scoped try/catch requirement. > If you want to handle uncaught exceptions via auto_prepend_file you can use set_exception_handler(). It will register a global handler that is invoked on an uncaught exception. So you can have your functionality, if that's how you like to handle things, but you also have the option of fine-grained control of assertion failures by use of catch-blocks. One use case that I have repeatedly mentioned in the previous thread is that PHPUnit will want to catch the assertion failure but still continue running other tests. Generally anything that uses a global handler (e.g. for assertion failures...) turns out to be a PITA when you try to combine multiple libraries which want different handlers. In the end you can't really use any such handlers in a portable library. I'd like assertions to be usable in libraries. Thanks, Nikita --001a11c2ff22433a5604e958c10b--