Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83024 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33322 invoked from network); 18 Feb 2015 06:38:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Feb 2015 06:38:56 -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.213.53 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.213.53 mail-yh0-f53.google.com Received: from [209.85.213.53] ([209.85.213.53:40725] helo=mail-yh0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5F/D1-18888-C7334E45 for ; Wed, 18 Feb 2015 01:38:54 -0500 Received: by yhot59 with SMTP id t59so1671915yho.7 for ; Tue, 17 Feb 2015 22:38:50 -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=3nICP5bvuXZneqCXVQFN/Phw2vAs6+PI+UPBzyRW2pw=; b=EFVmCVj50cFV4NGyQKE0DmcncRwhtABR7NJd0z6gUXlj/ozlDwKSzbOJxZhLAaYmUN 73PxIokHViId/88xN972MOEmwrqVlljjePo9e59w7UJUKsk6BPyJpEwVMcZ5kYEg633V bsGVcPw4FaSHMKLFiiFoNwHNcbYxL3Y1n18Nulyo5PZEK6JCda6aM2t52iVb9Q1I4ce7 8wIOUxUskcA2G5d7FdJFPRex9I3tvr/4uu7N3tnBsq0qct+59rFyjxXe+/MQSoNvE/rm SaZucTPaqsj6RgCcpZ1kaeQQdUnS31VOYxRk2tLeVOBE1QO6QkQ/6d6zPiGD6zWTweQ4 Pp9A== X-Gm-Message-State: ALoCoQmGRG1Edm8d6TsnR4RHnu7K0hRcEyEis5JzoBD+rqsqy9GOvQrRe5SELYxQrATctYUdLQuxp6J2x4kpBsPE6Jk6wW2ThkzaEbkraaRs5I2x44vLzRgbyQXWypvpaExZVGKi1fNZjuXNtOGRWg1nONeuqsaQDQ== MIME-Version: 1.0 X-Received: by 10.221.44.65 with SMTP id uf1mr21599924vcb.46.1424241530438; Tue, 17 Feb 2015 22:38:50 -0800 (PST) Received: by 10.52.74.73 with HTTP; Tue, 17 Feb 2015 22:38:50 -0800 (PST) In-Reply-To: References: Date: Wed, 18 Feb 2015 10:38:50 +0400 Message-ID: To: Alexander Lisachenko Cc: Nikita Popov , Benjamin Eberlei , PHP Internals , Guilherme Blanco , Pierrick CHARRON , Pierre Joye , Zeev Suraski , Andi Gutmans , Joe Watkins , Yasuo Ohgaki , Sebastian Bergmann , Stanislav Malyshev , Rasmus Lerdorf Content-Type: multipart/alternative; boundary=001a11c3ea3c7f21e1050f5712b4 Subject: Re: [PHP-DEV] Annotations in PHP7 From: dmitry@zend.com (Dmitry Stogov) --001a11c3ea3c7f21e1050f5712b4 Content-Type: text/plain; charset=UTF-8 On Tue, Feb 17, 2015 at 10:13 PM, Alexander Lisachenko < lisachenko.it@gmail.com> wrote: > > 2015-02-17 19:25 GMT+03:00 Dmitry Stogov : > >> I think yes, >> However, Alexander thinks differently >> https://wiki.php.net/rfc/parser-extension-api >> Of course this is not for 7.0 >> > > This RFC consists of two parts: parsing API and parser extension API. Last > one can be rejected, however it can be perfectly connected with annotation > RFC (if AST will be used as values) > firs part may be accepted. The second can't be accepted for 7.0 just because of time limit. (we have feature freeze in a month) > As for annotations, general use-case is appreciated. This can be extended > later in future versions of PHP. Therefore, annotation syntax should allow > to define key and values. Value can be valid expression (AST? concrete > node? compiled value?) or can recursively contain nested annotations. > Annotaion syntax: "php-expression-value" is parsed by standard PHP parser into AST. This AST is stored in annotations table at slot "key". Constant expressions are evaluated at compile-time and we store only the resulting constant value. Then it's possible to retrieve this AST (or value) using Reflection API. ReflectionMethod->getAnnotations(); ReflectionMethod->hasAnnotation(string $key); ReflectionMethod->getAnnotation(string $key); Then it's possible to traverse AST using some API like https://github.com/nikic/php-ast It also should be possible to evaluate retrieved "php-expression-value" in some context and reconstruct PHP source for any AST node. Thanks. Dmitry. --001a11c3ea3c7f21e1050f5712b4--