Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92934 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50215 invoked from network); 29 Apr 2016 13:54:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Apr 2016 13:54:07 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.50 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.50 mail-wm0-f50.google.com Received: from [74.125.82.50] ([74.125.82.50:36394] helo=mail-wm0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 61/BA-26386-F7763275 for ; Fri, 29 Apr 2016 09:54:07 -0400 Received: by mail-wm0-f50.google.com with SMTP id n129so28751425wmn.1 for ; Fri, 29 Apr 2016 06:54:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=7kNY9FQT3td+tQX7Z6Yn4NdLVUFSHS3BdYbNKj71GnY=; b=CErD764eVBaVyYjniu9aTW8xzLc5jXO30/hAS0et5MYQlbZom+dfCmWIu1FbYnFk77 Kt8BTxZT4V/kUmRyPxcxRYK3cPnUQlQdOaFlcE8eUpmhgYf1D6d5IdAU48GzCIe35yDq 41tNJu8bF5Phl4w/G4CNYXvOj52kNlT/2yYSXl1ihM9bnGACeu2SQ0T0NEt/9y2Bnwll 7dgBu92+ZNjm1tptdQvRfBPAbYdaa6IsgpbImigDuctB5f8+LzEtvkhcaIvzIG2gkCm4 e2LTh13gu1SEglB+uYkHaJd6CLtc7pnjgW/Caixpj05DxnK+sTjKC/gQMKHG3TlD440H b1Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=7kNY9FQT3td+tQX7Z6Yn4NdLVUFSHS3BdYbNKj71GnY=; b=lSJPKmUjc9yrU78KQg/A5ZH8vkP3TvkfZdTNJWivnFh/b40+b0Vip7pUDnkDvU1U8N fBlxpBuXGnZFYF4n2aSeODZPCw1aXB0VS9AIqJEx/kKSZck/T/fozlwBpgrChy8i3rYZ Nk5VqRlLQUfhvVUBihAa9/eYaKXZRJNNwrLoBSxciJKq709yrIRIb7mkX5Pz/SHYHoUk lsaeobNk4+DWOw6oo9MDHwz5z77XFxnUvClkQ7mgjb7yh/d/qhBYli60kWRVF0Xj6qVQ TjB5YoEUttmr37VBLnEEIRY2NnRAa/NVtfd/UrKhRb6EPDDhYYkBuTEp/zDHqHiV/iLP cuNQ== X-Gm-Message-State: AOPr4FW9wsMemLlwoInetBUBIawGRC9AK+6CCQrOny7OCwlwIzGwevZDYF0/Bl7/LEURSQ== X-Received: by 10.28.127.80 with SMTP id a77mr4382354wmd.66.1461938044446; Fri, 29 Apr 2016 06:54:04 -0700 (PDT) Received: from [192.168.0.82] ([93.188.182.58]) by smtp.googlemail.com with ESMTPSA id b124sm3773215wmb.1.2016.04.29.06.54.03 for (version=TLSv1/SSLv3 cipher=OTHER); Fri, 29 Apr 2016 06:54:03 -0700 (PDT) To: internals@lists.php.net References: <571E35D8.8080504@zend.com> <571E4A83.3080304@garfieldtech.com> <571E64A2.2040505@gmail.com> <5720A6B4.4000307@lsces.co.uk> <5721B9DD.3050300@lsces.co.uk> <57231ADD.9040006@lsces.co.uk> <572326A3.7000809@lsces.co.uk> <57234D3D.1070602@lsces.co.uk> <79c9df57-ee45-f415-3172-95f8229bbece@gmail.com> <57235F20.5080707@lsces.co.uk> Message-ID: <43b9c67f-3ec7-bacc-2608-552abbd1a3fa@gmail.com> Date: Fri, 29 Apr 2016 14:51:40 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <57235F20.5080707@lsces.co.uk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] PHP Attributes -> docBloc alternatives ... From: rowan.collins@gmail.com (Rowan Collins) Lester Caine wrote on 29/04/2016 14:18: > But where will annotations like @range(0,110) fit in the new model? > Along with the likes of '@notnull' and similar annotations that are also > currently being planned to be spread around the rest of the code? If a > variable is defined via the metadata as 'not null', then assigning null > to it is an error Hi Lester, Do you mean you are currently using these attributes / annotations with a reflection library to generate assertions in the code and throw errors at runtime? If so, yes, the native syntax will be used for that going forward, once the tools catch up (though they're likely to provide backwards compatibility modes for a fairly long time). However, there's no support built into the core for doing the actual checks now, and there's no plan (that I know of) to build one in in future. All that's proposed is to add more support in the language for a general syntax which can be used by such tools, to avoid them doing so much string parsing. If you're just using these annotations for documentation (as your references to phpDocumentor imply), then nothing will change: you'll still be able to use them for that, and they still won't be enforced. This is exactly the same as has been true since PHP 5.0 for argument types; the engine never validates anything in the docblock, and it might be completely wrong, and we have separate syntax for actually enforcing checks: /** * @param Foo $foo */ function test(Bar $bar) {} Even if there were no other downsides to the syntax, it would probably be a bad idea for the core to start enforcing things based on docblocks, because it would potentially break a lot of code that had them written wrong. Indeed, it is for precisely this reason that a new syntax is being proposed for general machine-readable attributes (rather than just functions for parsing the docblock), so that we can return to seeing docblocks as just comments, with no meaning for the code. In short: - if you're generating documentation from docblocks, it's up to the program doing the generating what to interpret, and nothing is going to change that - if you're generating behaviour from docblocks, it's up to the library doing the generating what to interpret, and what will change is them recommending the new dedicated syntax if it's implemented, because it will be more efficient to process Regards, -- Rowan Collins [IMSoP]