Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92949 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83334 invoked from network); 29 Apr 2016 16:50:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Apr 2016 16:50:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=lester@lsces.co.uk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=lester@lsces.co.uk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lsces.co.uk from 217.147.176.214 cause and error) X-PHP-List-Original-Sender: lester@lsces.co.uk X-Host-Fingerprint: 217.147.176.214 mail4-2.serversure.net Linux 2.6 Received: from [217.147.176.214] ([217.147.176.214:46845] helo=mail4.serversure.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6A/60-26386-0E093275 for ; Fri, 29 Apr 2016 12:50:41 -0400 Received: (qmail 11658 invoked by uid 89); 29 Apr 2016 16:50:37 -0000 Received: by simscan 1.3.1 ppid: 11652, pid: 11655, t: 0.1016s scanners: attach: 1.3.1 clamav: 0.96/m:52/d:10677 Received: from unknown (HELO ?10.0.0.7?) (lester@rainbowdigitalmedia.org.uk@81.138.11.136) by mail4.serversure.net with ESMTPA; 29 Apr 2016 16:50:37 -0000 To: internals@lists.php.net References: <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> <0d71618b-2ffa-7273-f9b9-aeabc35f4211@gmail.com> Message-ID: <572390DC.1020108@lsces.co.uk> Date: Fri, 29 Apr 2016 17:50:36 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: <0d71618b-2ffa-7273-f9b9-aeabc35f4211@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] PHP Attributes -> docBloc alternatives ... From: lester@lsces.co.uk (Lester Caine) On 29/04/16 16:42, Rowan Collins wrote: > function foo($a) { > if ( $a < 42 ) { throw new Exception; } // Must not reach The Answer > ... > } > > vs > > <> // 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. -- 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