Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82888 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35619 invoked from network); 16 Feb 2015 21:02:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Feb 2015 21:02:39 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.171 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.171 mail-vc0-f171.google.com Received: from [209.85.220.171] ([209.85.220.171:40209] helo=mail-vc0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F5/AF-36518-EEA52E45 for ; Mon, 16 Feb 2015 16:02:39 -0500 Received: by mail-vc0-f171.google.com with SMTP id kv19so11356018vcb.2 for ; Mon, 16 Feb 2015 13:02:36 -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=4uTZZCghosbyaeZkK/ztgimhFQH6HTs+JOtRc7WxqYk=; b=THuw6aFipketQSwhBFiYRwSPjSaDxM+ZHgYNHE/747+Z2RdAbsYJ8dO2Rjdr4J0G1O a8hIOmqWjUQTEJ3JaWSWIIQ4v46w+sr+v3q3MNCUK4vHIwpPVlOwzFBcR3+JWsv6fJea TeAVk+pjGG5Yw4FXxS7N3Pk+ll80TI8wMYqsPatPX6daxgu4gd2COLLzW2I07fcDNOLJ jDnYl3u7C8YZS1bokmnTGs4sV1XH4DX2a1sgkxX/YXlBTK9h7LNHzEPIpGWxSrCad3Cj P/H8aJjHSt6fFQtN/zgcexi/JTi8fSTRxv2KagryJaJrGedQgw5pZE3M+m4pbVOnoAXK op1w== X-Gm-Message-State: ALoCoQlwqu7C03SUR68iHTl5KN9DcVL3apJqfpd34Jb9npdJNrNCBFtSEatwANWAhY3RHAd0AmXggnA77CErILkKPRybJUZQDS/gvMbNK97KE32aUKwbtZ8IYnB/6G+5bxDHwsYFeupmmZIejnVAOTrpXPwIMjLSkg== MIME-Version: 1.0 X-Received: by 10.52.162.72 with SMTP id xy8mr14418964vdb.12.1424120556494; Mon, 16 Feb 2015 13:02:36 -0800 (PST) Received: by 10.52.74.73 with HTTP; Mon, 16 Feb 2015 13:02:36 -0800 (PST) In-Reply-To: References: Date: Tue, 17 Feb 2015 01:02:36 +0400 Message-ID: To: Benjamin Eberlei 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=089e01628326e33d9e050f3ae731 Subject: Re: [PHP-DEV] Annotations in PHP7 From: dmitry@zend.com (Dmitry Stogov) --089e01628326e33d9e050f3ae731 Content-Type: text/plain; charset=UTF-8 On Mon, Feb 16, 2015 at 11:05 PM, Benjamin Eberlei wrote: > > > 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. > Your example handles just particular use-case. I would like to provide a general solution. Thanks. Dmitry. > >> >> 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. >> > > --089e01628326e33d9e050f3ae731--