Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87471 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27214 invoked from network); 31 Jul 2015 23:44:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Jul 2015 23:44:03 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.182 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.160.182 mail-yk0-f182.google.com Received: from [209.85.160.182] ([209.85.160.182:36016] helo=mail-yk0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 85/D1-17913-2480CB55 for ; Fri, 31 Jul 2015 19:44:02 -0400 Received: by ykay190 with SMTP id y190so71441493yka.3 for ; Fri, 31 Jul 2015 16:43:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=nhLSl6w9Mla6xD3EweTeCwUIVXY/Ba1hjshrz0fkDAI=; b=v2S6A6Cs42nckpOo0vhqZWBcISOkE6IjVglZKymqjPOIqrzfH+/74PAZgTGM+RM/RV e60nun4b8/COtJNrQboSwiKPsdQhr137rq7XNjUSCETn/eXtIcJigdFxySSVnaw7/Hol ZCpJbd3jRisIsyVYh5uQ4mhcCSKnqUwZNI0w9t1x32L1fl9kvH0beKNxGAMrP/074OZt CESlc3WyPA5kps+Ppfdbn9fl5gPUrpTgnNRD5fVV3d/iMRyyrN5KHyNfHAaGHAvhiYtE PsezcIbYeUFwmeY4BN/EQ1y4CYCrJMModw9vCyjQD3oNlCXL05k9P8EIpNBkcp3B9vXa OtOA== X-Received: by 10.170.185.134 with SMTP id b128mr6606745yke.85.1438386239291; Fri, 31 Jul 2015 16:43:59 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.129.40.77 with HTTP; Fri, 31 Jul 2015 16:43:19 -0700 (PDT) In-Reply-To: References: <836BA21C-AE99-4E7B-AB06-EBC30E41BA0E@icicle.io> <0AD335F5-35F3-4D98-8F82-800A1EDF8FD8@icicle.io> <05f101d0c838$fcdab5e0$f69021a0$@belski.net> <55B63FDF.6050100@gmail.com> <55B66494.1020106@gmail.com> <55B6707A.3040405@gmail.com> Date: Sat, 1 Aug 2015 08:43:19 +0900 X-Google-Sender-Auth: GDi9gU1RB6OUVkRlM5hj60TliNQ Message-ID: To: Niklas Keller Cc: Scott Arciszewski , Rowan Collins , Anthony Ferrara , PHP Internals Content-Type: multipart/alternative; boundary=001a11399576d7c7c0051c346487 Subject: Re: [PHP-DEV] Core functions throwing exceptions in PHP7 From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a11399576d7c7c0051c346487 Content-Type: text/plain; charset=UTF-8 Hi Niklas, On Sat, Aug 1, 2015 at 8:27 AM, Yasuo Ohgaki wrote: > They should totally be handled. You need to catch the error and throw a >> defined exception, otherwise your public API will break if you choose to >> use another internal implementation. >> Additionally, you seem to assume that the library doesn't have to do >> things like cleanups in such a case. >> > > My thought is based on Design by Contract (Contract programming). > When parameter or environment does not satisfy contract, contract error > should be > resulted in program/process termination. > > Fixing inappropriate parameter or environment is not library/framework > author's > responsibility, but the developer's. i.e. > Caller(function/programmer/system admin) > has the responsibility that satisfies parameter/environment requirement. > If > requirement is not met, it's perfectly OK for library/framework to raise > fatal > errors/exceptions. e.g. "You need PHP 5.6 or greater" error. > I'll be more specific for "CSPRNG not available" error. If a author would like to handle the error and fallback to non crypt safe RNG, he/she should detect environment and execute alternative code for the environment. Catching exception and fallback to non crypt safe RNG is not optimal way for handling unsatisfactory environment. IMHO. If we need function that checks environment, we are better to provide one rather than let users to use exception. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a11399576d7c7c0051c346487--