Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82882 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22834 invoked from network); 16 Feb 2015 20:05:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Feb 2015 20:05:39 -0000 Authentication-Results: pb1.pair.com header.from=kontakt@beberlei.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=kontakt@beberlei.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain beberlei.de from 74.125.82.43 cause and error) X-PHP-List-Original-Sender: kontakt@beberlei.de X-Host-Fingerprint: 74.125.82.43 mail-wg0-f43.google.com Received: from [74.125.82.43] ([74.125.82.43:54557] helo=mail-wg0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8E/7D-36518-19D42E45 for ; Mon, 16 Feb 2015 15:05:38 -0500 Received: by mail-wg0-f43.google.com with SMTP id z12so17729009wgg.2 for ; Mon, 16 Feb 2015 12:05:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=jO0JzW4uVSRI5nk8QEXcfYDU9zfobx/5x22rAEnK1+s=; b=L9w7Ixqbp7ZCk+e2vvoCR1oAXQ59c/+JDEMzT0A/HgYaP0fc4Pt6X3RwjG10Q4xwzy 18qEYAGJeRifq3g1CuCDRAfGiGkIbj0TYUUtscnBEW+OqdWK7CKtH/CBgnQ7ots2iULG 0fdWyYLE+SYQcr/2BKg5ALTCrHbTDActFdrCkaMjv1xm6XL3UvNNCSxVy0cta37SK/gh 2SkqTwhKTF20d2bYbSkapoUrbvo5X7/F9iIxNzQSEU+ZnAZOGmWhoP2zsKE8oNXkIRNt FqBQZeM/x1IL4JU8ItZ98zeCwfBOLKVgRFmI7uFwv8jBdjsmLDHqCQonsp5KPbF2X9VB U4Yw== X-Gm-Message-State: ALoCoQmBOcD1R0Oqghm2E4AlB4hoPbZu8upNWWp2GFpXoUwTnkHNbAN5ievkUFy2DfLAgHzF51HZ MIME-Version: 1.0 X-Received: by 10.194.185.68 with SMTP id fa4mr52755702wjc.111.1424117131059; Mon, 16 Feb 2015 12:05:31 -0800 (PST) Received: by 10.194.192.202 with HTTP; Mon, 16 Feb 2015 12:05:30 -0800 (PST) X-Originating-IP: [93.129.131.180] In-Reply-To: References: Date: Mon, 16 Feb 2015 21:05:30 +0100 Message-ID: To: Dmitry Stogov Cc: PHP Internals , Nikita Popov , Guilherme Blanco , Pierrick CHARRON , Alexander Lisachenko , Pierre Joye , Zeev Suraski , Andi Gutmans , Joe Watkins , Yasuo Ohgaki , Sebastian Bergmann , Stanislav Malyshev , Rasmus Lerdorf Content-Type: multipart/alternative; boundary=047d7bacb11eb73c8b050f3a1b26 Subject: Re: [PHP-DEV] Annotations in PHP7 From: kontakt@beberlei.de (Benjamin Eberlei) --047d7bacb11eb73c8b050f3a1b26 Content-Type: text/plain; charset=UTF-8 On Mon, Feb 16, 2015 at 12:07 PM, Dmitry Stogov wrote: > hi, > > During discussion of different ways of implementing "Design by Contract" we > got an idea of using annotations. > > BTW: annotations are useful by their own and may be used for different > purposes. Support for annotations was proposed long time ago: > > https://wiki.php.net/rfc/annotations > https://wiki.php.net/rfc/annotations-in-docblock > https://wiki.php.net/rfc/reflection_doccomment_annotations > > HHVM already implemented similar concept > > http://docs.hhvm.com/manual/en/hack.attributes.php > > I made a quick and dirty PoC that shows how we may implement annotations in > PHP7 and how powerful they may be : > https://gist.github.com/dstogov/dbf2a8f46e43719bd2c2 How about not exposing the AST, and then the userland can pass context to a method $reflection->getAnnotation($name, $context); https://gist.github.com/beberlei/0dc36d4412b8e3454912 That way AST is not exposed to userland. > > > The test there is self explainable. Of course, annotations just provide a > way to add metadata, but doesn't define attribute names or the ways they > are going to be used. Only Reflection API to read. > > There are still a lot of technical problems that have to be solved. > Right now, we just need to answer a question - if we like this in PHP7? > Thought and opinions are welcome... > > Thanks. Dmitry. > --047d7bacb11eb73c8b050f3a1b26--