Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92944 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72497 invoked from network); 29 Apr 2016 16:01:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Apr 2016 16:01:09 -0000 Authentication-Results: pb1.pair.com header.from=derokorian@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=derokorian@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.42 as permitted sender) X-PHP-List-Original-Sender: derokorian@gmail.com X-Host-Fingerprint: 209.85.218.42 mail-oi0-f42.google.com Received: from [209.85.218.42] ([209.85.218.42:36254] helo=mail-oi0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FC/6E-26386-34583275 for ; Fri, 29 Apr 2016 12:01:08 -0400 Received: by mail-oi0-f42.google.com with SMTP id x201so123316203oif.3 for ; Fri, 29 Apr 2016 09:01:07 -0700 (PDT) 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; bh=iL3j5nyPHfPL2NVw2qup7rpKyk7Cxcnv/eCuQfKf8ps=; b=e0fgb8Q/mxFMDEy1XTLvAqcx5gSubqDwc774T41MizgzPSnzM7Z5yiNnY0mIV+vUKv isaiOOxozsv2NbVkjGCnON1nGPibGK6K2qvXh4J5ek8W8KJOEH/cSGvONEC4OHWG8AnM NqCZExCjlTwRtwbIKUcGTC4vHF8VvvPQ81SCOCKayEPbuVc1SnR0j4V1NaOJJgmoi4tf JPzlRCOtQFrI0+NB/8JZ0ClbOtmETE7X9pHC7sBB3qc615I1aS1DzaC/nbB7QWO/QwnP Yzv4t4DA6bOD7KnsM1/8hbdd1U8IYJcSszpqx9SstNH3wcSVaqJt+Ko/Pu8b2Ox0HCJl 77oA== 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; bh=iL3j5nyPHfPL2NVw2qup7rpKyk7Cxcnv/eCuQfKf8ps=; b=f390Qu3Y1HjpqcqfC6O2i6ORCEvxAnQhonkYdxGTYLz2iaPmqowOuZcA09tD2MXcs+ ctI+w+qX085/ZXIKIqlUbk1+lS6DKXSm+Ii3iSn2hok2+PQ9fxvA6x9HPbwTRhcY4wIQ MGQIvhE58uMINRu6XzJ1aV22nK78GOZdR1AQ6W0oui20/ZyuKsOZ6A05Xw1JQm7Ja6Ha B5BMhB4QWDme3913ccWMwpkAnm3hDK0yG86RGjMm9fwjgz5fHvL3jbCRnQD1Gb7FuzlW mQ0lRzd9aTrjRFsOE8jE/3VvVWePPpaqtwpOyRhWdn9QH+IN8vyAlVuzJmvqacd5vEYx H0hA== X-Gm-Message-State: AOPr4FW+ekw7Z/mLnbUXXNCPg/Eu16RytjexzXag0PIGeR+PTX0L8fjGfdjF1h7Fb3hJr/P6nNAJX6R3qXv00A== MIME-Version: 1.0 X-Received: by 10.202.97.69 with SMTP id v66mr8625063oib.172.1461945660724; Fri, 29 Apr 2016 09:01:00 -0700 (PDT) Received: by 10.157.41.73 with HTTP; Fri, 29 Apr 2016 09:01:00 -0700 (PDT) In-Reply-To: <57237B36.1070301@lsces.co.uk> References: <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> <43b9c67f-3ec7-bacc-2608-552abbd1a3fa@gmail.com> <57237B36.1070301@lsces.co.uk> Date: Fri, 29 Apr 2016 10:01:00 -0600 Message-ID: To: Lester Caine Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a113d5940c9e0540531a1bf6a Subject: Re: [PHP-DEV] PHP Attributes -> docBloc alternatives ... From: derokorian@gmail.com (Ryan Pallas) --001a113d5940c9e0540531a1bf6a Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, Apr 29, 2016 at 9:18 AM, Lester Caine wrote: > On 29/04/16 14:51, Rowan Collins wrote: > > 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 al= so > >> 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 nul= l > >> 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 error= s > > 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). > > I think that is part of the problem here. IDE's are currently making > quite good use of existing annotation text, but if they have to be > switched to modes where some other option takes priority then once again > all the code has to be reworked ... which is where I'm stuck at the momen= t. > For what reason would you have to rework all the code? Nothing about this RFC makes the currently used and working implementations invalid. In fact, I have a project written originally in 5.2 that's currently running on 7.0. IIRC, it uses none of the new features from 5.4+. I'm still using long hand array syntax (array() vs []), I'm still using isset based ternaries (isset($foo)?$foo:'default' vs $foo ?? 'default') and such things. However, new code written into this project, since it now runs on 7.0 has the OPTION to take advantage of these new features. > > > 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 migh= t > > be completely wrong, and we have separate syntax for actually enforcing > > checks: > > I was looking at php-annotations having realised that it already had > @range which is the bit I'm trying to automate more. Except it doesn=E2= =80=99t > ... it has stripped the data validation annotations 'because > phpdocumentor2 does not support them'. HENCE asking the question about > this important area here ... > I'm not sure I follow, the RFC is suggesting adding annotations that CAN affect code if a tool or future RFC is written to provide that feature. Currently, it only adds meta-data that can be read more efficiently than using Refelction*::getDocBlock() and then string parsing this yourself. > > > /** > > * @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 jus= t > > functions for parsing the docblock), so that we can return to seeing > > docblocks as just comments, with no meaning for the code. > > To repeat ... what happens where an IDE has code with both styles of > working? You are exactly right but does adding something extra ACTUALLY > make life easy where we have well documented code and IDE's which > support it. > Currently, my IDE supports every feature that has multiple pathways (both long form and short form array works is recognized, mysql_* is still recognized, even though its completely removed from php7). > > 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 > > As with 'strict typing' we add different styles of working which in some > longer term world may be an elegant solution but short term just creates > an annoying different way of doing a bit of the job? The current > proposal is offering a fix for a style of working which I still don't > understand, because I can't 'read' easily the examples being given. > > < 0")>> > function foo($a, $b) { > } > > *I* would expect to be checking the range of $a and $b before adding > some checks combining the data. What is so good about 'test' that adding > an error check inside 'foo' along with the range checks does not > provide? I would expect to ALSO have this limit documented within the > docBloc code anyway as that can include the reason which is absent from > the above example! The comments go hand in hand with the validation so > why not keep them together? > > -- > Lester Caine - G8HFL > ----------------------------- > Contact - http://lsces.co.uk/wiki/?page=3Dcontact > L.S.Caine Electronic Services - http://lsces.co.uk > EnquirySolve - http://enquirysolve.com/ > Model Engineers Digital Workshop - http://medw.co.uk > Rainbow Digital Media - http://rainbowdigitalmedia.co.uk > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > Ryan --001a113d5940c9e0540531a1bf6a--