Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71659 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62842 invoked from network); 28 Jan 2014 07:05:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jan 2014 07:05:46 -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.215.44 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.215.44 mail-la0-f44.google.com Received: from [209.85.215.44] ([209.85.215.44:56474] helo=mail-la0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DC/69-01140-8C657E25 for ; Tue, 28 Jan 2014 02:05:45 -0500 Received: by mail-la0-f44.google.com with SMTP id hm7so5328106lab.31 for ; Mon, 27 Jan 2014 23:05:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to:content-type; bh=aLLBIfG6QH/4/nO44tYzEQvGVE6SMAQWcyhTkmAo/sM=; b=KfZYCZjusdTKgt77Nq6l1Ya7Gtt8mPX8niFNjGhyv3Rax7r1A/K9RkFfun1RdY3HXb FA9KKolL52reIcf64qAf0tebQfkuFMf7zD9G/hhc49Gk/2y7dMRq+0Axu5tr1Ghn4o89 xGhIpsCeAc0hNrH6RTP0cmHAIteipKAC/8CTTXu0oVcGjzRzVSZoZh0a460BtmPmxnRm 4Xk+C/tPwKxmcBhDtH63/t5rAC9aJiUOwLG5cLsv4tXuWtPyu0sCvVg207+7U82EOpRM uvL3yg4clOpKKZn0eaaGe5s7Fm1DDr+qPQOw5lMIH6hevsHhKTviOQuOrx3Tsnnay9U6 P91Q== X-Received: by 10.112.89.42 with SMTP id bl10mr19239321lbb.18.1390892741409; Mon, 27 Jan 2014 23:05:41 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.199.37 with HTTP; Mon, 27 Jan 2014 23:05:01 -0800 (PST) Date: Tue, 28 Jan 2014 16:05:01 +0900 X-Google-Sender-Auth: _TB-DEC5dWY9I5jFg8tLXtLFxiI Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11c374a6c5c22e04f1027332 Subject: DbC for PHP? From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a11c374a6c5c22e04f1027332 Content-Type: text/plain; charset=UTF-8 Hi all, I'm wandering if we could have DbC (Design by Contract) for PHP 6. http://en.wikipedia.org/wiki/Design_by_contract There is user land implementation already. https://gitorious.org/higher-order-php/php-contracts/source/5b0a53b9732f0e4dbe79345212c84c74526def3b: It could be done with dbc mode INI switch as follows. When dbc=on, automatically includes include __dbc_ . __SCRIPT_NAME__; when a script is loaded. No error if there is not the script. When function/method is called __dbc_pre_. __FUNCTION__() is called before calling function(). __dbc_post_.___FUNCTION__() is called after function() call. No error if there is not the function. Class methods would be more complex, but basic idea is the same. Issue would be what we should do with $this with class methods. Automatic namespace might be nice to have for both function and class. When dbc=off, these would be skipped at all. It does not sacrifice performance at all for production while it could catch various errors during development. It could do more complex assertion than assert() and it could check post condition that is difficult to achieve by assert(). User could have their own strong type safety as long as they have strict input validation. It could be used as complement of annotation. Just an idea. Any comments? Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a11c374a6c5c22e04f1027332--