Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82348 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37750 invoked from network); 10 Feb 2015 07:46:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Feb 2015 07:46:50 -0000 Authentication-Results: pb1.pair.com header.from=php@bof.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=php@bof.de; spf=pass; 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:46895] helo=mars.intermailgate.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 34/0C-47508-967B9D45 for ; Tue, 10 Feb 2015 02:46:50 -0500 Received: (qmail 29550 invoked by uid 1009); 10 Feb 2015 08:46:46 +0100 Received: from 209.85.216.52 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.216.52):. Processed in 0.274025 secs); 10 Feb 2015 07:46:46 -0000 X-Antivirus-MYDOMAIN-Mail-From: php@bof.de via mars X-Antivirus-MYDOMAIN: 1.25-st-qms (Clear:RC:1(209.85.216.52):. Processed in 0.274025 secs Process 29543) Received: from mail-qa0-f52.google.com (gmail@bof.de@209.85.216.52) by mars.intermailgate.com with RC4-SHA encrypted SMTP; 10 Feb 2015 08:46:46 +0100 Received: by mail-qa0-f52.google.com with SMTP id v10so10642518qac.11 for ; Mon, 09 Feb 2015 23:46:45 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.224.134.202 with SMTP id k10mr51112848qat.32.1423554405027; Mon, 09 Feb 2015 23:46:45 -0800 (PST) Received: by 10.140.104.65 with HTTP; Mon, 9 Feb 2015 23:46:44 -0800 (PST) Received: by 10.140.104.65 with HTTP; Mon, 9 Feb 2015 23:46:44 -0800 (PST) In-Reply-To: References: <54D7ED22.3080001@gmail.com> Date: Tue, 10 Feb 2015 08:46:44 +0100 Message-ID: To: Yasuo Ohgaki Cc: Dmitry Stogov , internals Content-Type: multipart/alternative; boundary=047d7b6740b2a156ac050eb71654 Subject: Re: [PHP-DEV] Design by Contract From: php@bof.de (Patrick Schaaf) --047d7b6740b2a156ac050eb71654 Content-Type: text/plain; charset=UTF-8 Am 10.02.2015 08:25 schrieb "Yasuo Ohgaki" : > >> 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) > > Do you mean enable DbC partially? Like > declare(dbc=1); > At the top of script? Nono. i shouldn't have said declare, sorry. What I meant is this (using a made-up keyword "dbconly" just for exposition): class foo { function normalmethod($arg) require($this->just_for_dbc_check($arg)) { .... } dbconly function just_for_dbc_check($arg) { ... whatever validation code ... return false; } } And then when DbC is inactive (production) metho just_for_dbc_check would not be compiled at all / invisible. I now realize that I'm asking for a way to have arbitrary PHP code for checking, through a backdoor :) But this _would_ permit some nice consolidation of more complex checks, ones that maybe would be shared by several methods with repetition of the expressions in the case we cannot do this. Just thinking out loud, I fully agree with Dmitry's comment of keeping it simple and manageable at the moment, and this is something that could be added later at any time. best regards Patrick --047d7b6740b2a156ac050eb71654--