Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82338 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22090 invoked from network); 10 Feb 2015 07:07:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Feb 2015 07:07:06 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@bof.de; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=php@bof.de; sender-id=pass Received-SPF: pass (pb1.pair.com: domain bof.de designates 80.242.145.70 as permitted sender) X-PHP-List-Original-Sender: php@bof.de X-Host-Fingerprint: 80.242.145.70 mars.intermailgate.com Received: from [80.242.145.70] ([80.242.145.70:46287] helo=mars.intermailgate.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DD/98-47508-81EA9D45 for ; Tue, 10 Feb 2015 02:07:06 -0500 Received: (qmail 14388 invoked by uid 1009); 10 Feb 2015 08:07:01 +0100 Received: from 209.85.192.49 by mars (envelope-from , uid 89) with qmail-scanner-1.25-st-qms (clamdscan: 0.96.2/20051. spamassassin: 3.3.1. perlscan: 1.25-st-qms. Clear:RC:1(209.85.192.49):. Processed in 0.261124 secs); 10 Feb 2015 07:07:01 -0000 X-Antivirus-MYDOMAIN-Mail-From: php@bof.de via mars X-Antivirus-MYDOMAIN: 1.25-st-qms (Clear:RC:1(209.85.192.49):. Processed in 0.261124 secs Process 14366) Received: from mail-qg0-f49.google.com (gmail@bof.de@209.85.192.49) by mars.intermailgate.com with RC4-SHA encrypted SMTP; 10 Feb 2015 08:07:01 +0100 Received: by mail-qg0-f49.google.com with SMTP id q107so14435523qgd.8 for ; Mon, 09 Feb 2015 23:06:59 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.140.102.170 with SMTP id w39mr47015457qge.100.1423552019457; Mon, 09 Feb 2015 23:06:59 -0800 (PST) Received: by 10.140.104.65 with HTTP; Mon, 9 Feb 2015 23:06:59 -0800 (PST) Received: by 10.140.104.65 with HTTP; Mon, 9 Feb 2015 23:06:59 -0800 (PST) In-Reply-To: References: <54D7ED22.3080001@gmail.com> Date: Tue, 10 Feb 2015 08:06:59 +0100 Message-ID: To: Yasuo Ohgaki Cc: internals , Dmitry Stogov Content-Type: multipart/alternative; boundary=001a11c1672c707041050eb68845 Subject: Re: [PHP-DEV] Design by Contract From: php@bof.de (Patrick Schaaf) --001a11c1672c707041050eb68845 Content-Type: text/plain; charset=UTF-8 Am 10.02.2015 07:25 schrieb "Yasuo Ohgaki" : > > https://wiki.php.net/rfc/dbc2 First of all, thanks for your effort so far. Some questions, after reading the RFC, with no particular order: 1) Regarding invariants: those will be called for method calls on objects. What about static class methods? Could we have static class invariants (static require(.....))? Would these be called for both static and nonstatic method calls (nonstatic method calls can change static class state, too) 2) the pre- and postconditions could be useful for ordinary, non-OO functions, too, to check parameters, return, and global state invariants 3) I think that method preconditions are not sufficient. Pretty often, public methods first sanitize and validate their input parameters, and rightly so. In these cases, it would be useful to have the checking, in the same general framework, at an arbitrary point in the function body. In other words, assert (with an expression as the first argument, instead of a string....). 4) regarding the error message second argument to the condition definitions, it would be useful to have these not only as plain (extrapolated) strings, but as full expressions-that-evaluate-to-string. That would permit hooking to arbitrary private logging and log formatting methods. 5) and a bit off-topic, it would be useful to be able to declare (sic) whole methods to be nonproduction only: Methods that will only be used in pre/post/invariant condition expresions (or error formatters a la my point 4) best regards Patrick --001a11c1672c707041050eb68845--