Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92831 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79196 invoked from network); 27 Apr 2016 05:25:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Apr 2016 05:25:09 -0000 Authentication-Results: pb1.pair.com header.from=pierrick@webstart.fr; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=pierrick@webstart.fr; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain webstart.fr from 209.85.161.174 cause and error) X-PHP-List-Original-Sender: pierrick@webstart.fr X-Host-Fingerprint: 209.85.161.174 mail-yw0-f174.google.com Received: from [209.85.161.174] ([209.85.161.174:34841] helo=mail-yw0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B3/F0-20013-33D40275 for ; Wed, 27 Apr 2016 01:25:07 -0400 Received: by mail-yw0-f174.google.com with SMTP id g133so50855701ywb.2 for ; Tue, 26 Apr 2016 22:25:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=webstart-fr.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc; bh=kNQKpve87VBPTwvUlTiX72reSMb0KjCmQNxxdRwWhSM=; b=uLFKlCN43HjI2qjLDkYvv6XKTjOSyKamejLudx3ljtBQFWQ5ken34Wcfj6Df3EzQdv dyCOD3Jv1QqyCIc2CpKjJFILPOmtYCkBU+eT3S3Qi+pQaRSh2LuddzLputE9zeG1yCo+ 6FkvbGGYCDoePeX+0XP0aPjirSrQ6ugK6rT3rUSLYwCXuUJNVBsSwxaZqaI1trSp6d1O lEuYAKxyyr7krjOXzPvnHDGHikfpbmPBVzaqRCy+I0ebw9U2Lk4Gd1mLLROaQnPleo3W oL6c7Os+UD0KO+W39lLDhnoOEW79/KavB63Q5P9656VtPoP3NzDal8K7rY2tluMaqJyC /h5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc; bh=kNQKpve87VBPTwvUlTiX72reSMb0KjCmQNxxdRwWhSM=; b=djqhvta1/Ag4LxaC6aG0Wad1iiuZEOVlu0Pq5CKVEIVMBpq6sWi7tMMQBCenN3x5sT OaWwjTBbPTMHgttAqXG4jIBse9RvkFvFHtLBhkpm32KWBauTG8dNladSOxwJ/YIeYMvk wrJS2e8+J8LnSGLkpVpm2PJ4NnpT20vXaRasEM5iRJd7hMa4p/4L4MRjfABtxO/tSo28 lo1bVGPipiF0kJc9NHhndXwdFCSC8zxNhWqPOujijqMwVD0IRhRsSrIHqBPJLbtJfOIX OiZTW+dSEAGtokrWuepTrW1oqQaVJB1qX62zPdSbR1Dl3VABeV0WRoUYgDsBOXyvj3Ow I3CQ== X-Gm-Message-State: AOPr4FUPiGA4GP4Art+ieZdrZiBenWUL/9g8ku/oeLW9UtqA3q8ea50er6lhOlieh6VdIv4tbJRPdYFgDAgwdQ== MIME-Version: 1.0 X-Received: by 10.129.132.137 with SMTP id u131mr3539516ywf.105.1461734704584; Tue, 26 Apr 2016 22:25:04 -0700 (PDT) Sender: pierrick@webstart.fr Received: by 10.37.81.7 with HTTP; Tue, 26 Apr 2016 22:25:04 -0700 (PDT) In-Reply-To: References: <571DD94B.3060604@zend.com> <571E63D0.8080800@gmail.com> <9c24f969-cb0e-cb46-a23c-6e06e7de7d79@gmail.com> <571E7C08.6010309@gmail.com> <571F1B95.9030203@zend.com> Date: Wed, 27 Apr 2016 01:25:04 -0400 X-Google-Sender-Auth: Amq3nAXeZ5AaPxKlAjQYNxxqFLQ Message-ID: To: Dominic Grostate Cc: PHP internals , Dmitry Stogov Content-Type: multipart/alternative; boundary=001a114f0e8cd2ca7b053170a1df Subject: Re: [PHP-DEV] [RFC] PHP Attributes From: pierrick@adoy.net (Pierrick Charron) --001a114f0e8cd2ca7b053170a1df Content-Type: text/plain; charset=UTF-8 Hi all, First of all thanks dmitry for your great work and for bringing the RFC back to life. I think it would be great to allow users to define their own annotations and give them some structure (what the annotation is made of). For example let's say I apply an annotation to define that a property is a string with a length. In the proposed RFC I will have something like this : class Foo { <> public string $bar; } But how could i know for example that StringLength can take an extra parameters I would have to read the code of the annotation framework see how it parse, use it etc... But if I can define the structure (this is a quickly invented pseudo syntax and I'm not proposing it) annotation MyAnnotation\StringLength { private int $length; private string $comment = "Default value"; } With this definition I know that the Annotation take 2 parameters one int and one string, that the comment has a default value and can be omitted etc... Also what I dislike about using a simple array with no definition is that you can't annotate an annotation since there is no definition. I know it can look complex but think about the power you can add to the system. It would help us solve some problems that could not be solved (or at least I can't see any way of doing it) if you can't have a definition you can't attach behaviour/metadata to it. Here are some problems we could solve (those are just examples) 1. Are annotations inhereted or not ? Some will say yes, some now but I think they actually both make sense. For example we could imagine that if I annotate a method of my interface as deprecated I want it to be inhereted because all implementations are, but author annotation should not be inherited because I'm not necessarily the author of the implementation. So we could say that annotations are by default not inherited and we could have an <> annotation <> annotation deprecated { } annotation author { public string $name; public string $mail; } 2. Is a specific kind of annotation applicable to only one kind of statement or multiple ? JIT don't make sense on a property... <> annotation jit { } 3. Current version of the RFC propose that we could either have AST or to execute the AST but we could imagine to get both annotation assert { <> public ast\node $node; public string $message; } Again, this is just a couple of quick ideas, but this would make things less magic/obscure with a definition and far more flexible. If we agree that we want a definition we could work on how to create this definition (we could use some stuff from the old Annotations RFC https://wiki.php.net/rfc/annotations?rev=1302087566) to update this one with a new syntax or use interface as proposed in the first implementation class Deprecated implements Annotation { } Maybe Pierrick --001a114f0e8cd2ca7b053170a1df--