On Fri, Apr 29, 2016 at 10:50 AM, Lester Caine <les...@lsces.co.uk> wrote:
> On 29/04/16 16:42, Rowan Collins wrote: > > function foo($a) { > > if ( $a < 42 ) { throw new Exception; } // Must not reach The Answer > > ... > > } > > > > vs > > > > <<test($a < 42)>> // Must not reach The Answer > > function foo($a) { ... } > > The first version is my current code base, although it's unlikely to > throw an exception, more likely to have already validated the data > before using it so the check is redundant as it is already in the code > to handle the problem data. But in the second example just where does > the error redirect traffic? At least with in-line checks you control > flow ... but just how do you add a range? Does that need different > 'test' elements? > > My main target here IS to add a reliable mechanism to allow every > variable to have it's own validation attributes. The only current route > is as php-annotations nicely provided and which dovetails nicely into > the existing documentation process. Simply adding comments in line is > useless for the on-line documentation, and it's adding these annotations > to the documentation in parallel with making the data available in the > code which I'm trying to address. TRYING to find this even if it is > commented in the code on 15 year old code is a problem, and being able > to ADD docBloc annotation which can then be used later provides a > practical way forward. > > I've no problem with an alternate annotation method ... as long as in > PHP7 it is optional ... but I don't think this 'in-line' approach is > ACTUALLY the right long term solution to data validation. > But his RFC is about adding meta-data, which can be used up to the USER. The language here is providing no validation, just a means of defining metadata, which may in the future be expanded to some built in annotations. Validation is not specifically the point of this RFC, and the fact that a system could be built to provide this validation using the meta-data this RFC provides, does not limit it to that scope. > > -- > Lester Caine - G8HFL > ----------------------------- > Contact - http://lsces.co.uk/wiki/?page=contact > 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 > >