Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82379 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4558 invoked from network); 10 Feb 2015 12:49:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Feb 2015 12:49:18 -0000 Authentication-Results: pb1.pair.com header.from=lisachenko.it@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=lisachenko.it@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.174 as permitted sender) X-PHP-List-Original-Sender: lisachenko.it@gmail.com X-Host-Fingerprint: 74.125.82.174 mail-we0-f174.google.com Received: from [74.125.82.174] ([74.125.82.174:57853] helo=mail-we0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B5/19-47508-D4EF9D45 for ; Tue, 10 Feb 2015 07:49:18 -0500 Received: by mail-we0-f174.google.com with SMTP id w55so1481032wes.5 for ; Tue, 10 Feb 2015 04:49:14 -0800 (PST) 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=d5mdpamANMG/k84Vc6vWJEDj0WCptdsOV6hflw6p2pI=; b=bwBOt8jFJCNVvzFkqmtNufStsvaOr+vZUFYY+CeYeSuFZLmE++Xxqm9tj6bKHJfUE6 Mzyvi9Oun/eioiD+Li0b4sarNdPKHof0xW0nhEcFGL3B743qGnCZZLLGVum7K68bL187 X8wiWm9h67rCuYR+dNnBgTMAuJUmipGb5FTSaZPFzETY6nl6gYqziupfe89nI+tkaw8A XlvWEl6SIbqoOU/iYZTcVbArjklZFPTvaNk+ks+0aiCujEM9iKsLnW0dPGlHaJ82OBZJ 7Eaitz0i+ScG/Ic8H6Vrweffo49/a3ODT4o5hrn5WEvcXMkTYMh2dlNDgWFGzV09GERc g/vg== MIME-Version: 1.0 X-Received: by 10.181.27.199 with SMTP id ji7mr45329326wid.76.1423572554403; Tue, 10 Feb 2015 04:49:14 -0800 (PST) Received: by 10.194.154.229 with HTTP; Tue, 10 Feb 2015 04:49:14 -0800 (PST) In-Reply-To: References: <54D7ED22.3080001@gmail.com> <54D9DE4B.7030509@lsces.co.uk> Date: Tue, 10 Feb 2015 15:49:14 +0300 Message-ID: To: =?UTF-8?Q?Pavel_Kou=C5=99il?= Cc: Dmitry Stogov , Lester Caine , PHP internals list Content-Type: multipart/alternative; boundary=001a113482666ad587050ebb5087 Subject: Re: [PHP-DEV] Design by Contract From: lisachenko.it@gmail.com (Alexander Lisachenko) --001a113482666ad587050ebb5087 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2015-02-10 15:35 GMT+03:00 Pavel Kou=C5=99il : > Hello, > > maybe you could try to consult your ideas with Ivan Enderlin. He > mentioned in previous emails (for instance > http://news.php.net/php.internals/82245) that he would prefer some > AOP/hook-based approach to DbC as well, so it may be compatible with > your mindset. > Yes, I know about Praspel, it's quite a good implementation, but for specific case. My implementation of DbC is built on top of AOP and can be described with only one (!) aspect and few annotations. If you are interested in it, you could look across wiki https://github.com/lisachenko/php-deal/wiki or even open an aspect class itself https://github.com/lisachenko/php-deal/blob/master/src/PhpDeal/Aspect/Contr= actCheckerAspect.php to see an advices that will be triggered as custom hooks before/after or around original method invocations. I think, that AOP-based solution is pretty nice: it's only for development mode. Annotations are not parsed for production mode and looks like a good documentation, this can be improved later with BDD (Gherkin) to define a contracts in human-readable format. @Contract\Verify("Given $amount is positive") @Contract\Ensure("Result is changed from $old to $old+$amount") So, it can be a good idea to discuss this topic with Ivan Enderlin. Maybe he can help me with RFC too. --001a113482666ad587050ebb5087--