Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82836 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13260 invoked from network); 16 Feb 2015 12:40:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Feb 2015 12:40:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=lisachenko.it@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=lisachenko.it@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.54 as permitted sender) X-PHP-List-Original-Sender: lisachenko.it@gmail.com X-Host-Fingerprint: 74.125.82.54 mail-wg0-f54.google.com Received: from [74.125.82.54] ([74.125.82.54:57770] helo=mail-wg0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CF/93-29513-535E1E45 for ; Mon, 16 Feb 2015 07:40:22 -0500 Received: by mail-wg0-f54.google.com with SMTP id y19so29027215wgg.13 for ; Mon, 16 Feb 2015 04:40:18 -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=ewMNn2uzTZWDGjfYblMcqITvde3bPPgkxDp+7LqKO/E=; b=e6t3B35JYZ/KN8XinctIQXxWDwF9JucF3Y+iVG8q2It7Ox/X970ZF8HF3c2r1yPTEP 2XI7LF4CrY8I3xfVAdk4Ra0Di83JlvC9/XCkO9BthkQT36hH632s/o7cGqEeN/92YaEF 74L0tUw+gADf7tJBuvFhHhhyKd7vyL46z89vN1sYsHo/UvR+OUsaquudGXynrfpoxS4F mzC9VXJSpiGW4QI25oocte5s/CQMZOtH/pRdyB66iH1Lv1r6yTQMk2FThnmCNY8fYeTU LFeGEfcRXo1EVdXJFeQzjmLv7VrGc7A+PdUOwSVt/F5qXBqV13/SarNHB6P/H1TxIpwZ gEHw== MIME-Version: 1.0 X-Received: by 10.194.75.193 with SMTP id e1mr36118874wjw.126.1424090418638; Mon, 16 Feb 2015 04:40:18 -0800 (PST) Received: by 10.194.154.229 with HTTP; Mon, 16 Feb 2015 04:40:18 -0800 (PST) In-Reply-To: References: Date: Mon, 16 Feb 2015 15:40:18 +0300 Message-ID: To: Benjamin Eberlei Cc: Dmitry Stogov , PHP Internals , Nikita Popov , 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=047d7bb03ea887f795050f33e345 Subject: Re: [PHP-DEV] Annotations in PHP7 From: lisachenko.it@gmail.com (Alexander Lisachenko) --047d7bb03ea887f795050f33e345 Content-Type: text/plain; charset=UTF-8 2015-02-16 15:31 GMT+03:00 Benjamin Eberlei : > > My question is how do i evaluate this at runtime? I suppose a function is > necessary like evaluate_ast(...), but that requires passing the context. > many many open questions and as nikic points out this should probably be > delayed to 7.1 because it all should be discussed and specified. > This will be like pretty simple to parse: // For scalars: $attributes = (new ReflectionMethod(some::class, 'method))->getAttributes(); $cacheableNode = $attributes[Cacheable::class] ?? new Php\Parser\Node(AST_TYPE_VALUE, 50); $cacheTime = $cacheableNode->value; // For more complex things, like expressions or constant, runtime evaluation can be performed. $codeNode = $attributes[Php\Contract\Requires::class] ?? new Php\Parser\Node(AST_TYPE_STATEMENT, '$this->value >=0'); $code = (string) $codeNode; $result = eval($code); --047d7bb03ea887f795050f33e345--