Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82125 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32688 invoked from network); 8 Feb 2015 08:17:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Feb 2015 08:17:30 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.174 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.216.174 mail-qc0-f174.google.com Received: from [209.85.216.174] ([209.85.216.174:55592] helo=mail-qc0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D3/21-24707-99B17D45 for ; Sun, 08 Feb 2015 03:17:29 -0500 Received: by mail-qc0-f174.google.com with SMTP id s11so18380522qcv.5 for ; Sun, 08 Feb 2015 00:17:26 -0800 (PST) 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=8CdpA2xCe9kIe3L0cw0m8WcKqFKjOBi4ofUgYtqqLUk=; b=ES4K981nhYDNxCd9bxUBpwW+ITWFwIH/3aRp1GBxj+0RcfmdkaXVN3Cv/hyPIn6gv5 N5IKWZsyGHuIPE+l16NXZqu71Ml5JKmIpydhIHi7sfVR21pkwuL7P26qBrgRIzlTPrKz 2l2Lrfat0bAAXzCOCPJvzCLw+Vszmk0BUJD3942FBzHG7xs0GkKbRGOTcKaVFS/KLJKc gQ7eIOp7JlpZ4kx+2gqwksMUPAaKAKzfLPSxtWHUhqL+yMW9jWLzMkEjUiDfvtZDXkEP UO//ihJF329GyipbZkuspSrOy6QNQzDOo4y+tcRALNzhfEVBYRWxaWo5TLEG+zuz7QXM I/vA== X-Received: by 10.224.119.199 with SMTP id a7mr11727869qar.68.1423383446359; Sun, 08 Feb 2015 00:17:26 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.229.28.72 with HTTP; Sun, 8 Feb 2015 00:16:45 -0800 (PST) In-Reply-To: References: Date: Sun, 8 Feb 2015 17:16:45 +0900 X-Google-Sender-Auth: 8WNcYHKsceEklZu3fvceFOTZBo8 Message-ID: To: Dmitry Stogov , =?UTF-8?Q?Fran=C3=A7ois_Laupretre?= , guilhermeblanco@gmail.com Cc: PHP Internals Content-Type: multipart/alternative; boundary=001a11c2f9b4b315a2050e8f48d8 Subject: Re: Design by Contract From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a11c2f9b4b315a2050e8f48d8 Content-Type: text/plain; charset=UTF-8 Hi Dimitry, Francois and Guilherme, On Thu, Feb 5, 2015 at 8:14 PM, Dmitry Stogov wrote: > Hi Yasuo, > > Following our conversation, I tried to imagine how DbC should look like in > PHP from user perspective. Finally, I was influenced by the semantic > proposed in D, and syntax proposed for Java. So, these are my initial > thoughts: > > For php it may look like the following: > > function foo() > requre() > ensure() > { > ... > } > > It would require only one new reserved word "ensure". > Should I add D like version to the RFC? I don't care much about syntax as long as we have DbC. https://wiki.php.net/rfc/dbc Like Guilherme suggested, make some decisions first? 1- Doc comments vs. outside? 2- Keep object instance creation the same? IE: @Foo vs new Foo() 3- Is constructor the only way to inject parameters? 4- What if we have optional arguments, like: @Foo("bar", null, null, "woo")? Suppose that you wanna fix the optional arguments by declaring names (like this: @Foo("bar", test="woo")), doesn't it collide with PHP interests of not supporting parametrized arguments? How would parameter skipping proposal address this in a nicer way? 5- How would you deal with inheritance? Should a method inherit the same annotations from parent or not? Should we add ability to flag to inherit or not? What about overrides? Would they be allowed? Is there a vague idea on how this concept could be achieved? 6- Would you be possible to change annotations value at runtime? 7- Would we validate annotation arguments at all? Consider as array? Properties of objects? 8- In case we take the approach of properties of objects... how would we flag that a given class can/cannot be used as annotation: another annotation, interface, any other idea? 9- Would we and/or wow would we flag that a given class could be used only in a class and not in a method? 10- How would it be the syntax to declare a new annotation? Since people's preferences are diverse. It might be a good idea having pre-vote for designs, then we may have final vote with single design. We need some consensuses even for pre-vote. What do you think? Guilherme, is this the RFC you've mentioned? >Whenever you feel ready to get true, complete Annotations into core https://wiki.php.net/rfc/annotations Just making sure. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a11c2f9b4b315a2050e8f48d8--