Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95028 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61728 invoked from network); 10 Aug 2016 20:13:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Aug 2016 20:13:51 -0000 Authentication-Results: pb1.pair.com header.from=lester@lsces.co.uk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=lester@lsces.co.uk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lsces.co.uk from 217.147.176.230 cause and error) X-PHP-List-Original-Sender: lester@lsces.co.uk X-Host-Fingerprint: 217.147.176.230 mail4-3.serversure.net Linux 2.6 Received: from [217.147.176.230] ([217.147.176.230:48579] helo=mail4.serversure.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F2/00-61523-DFA8BA75 for ; Wed, 10 Aug 2016 16:13:50 -0400 Received: (qmail 30658 invoked by uid 89); 10 Aug 2016 20:07:05 -0000 Received: by simscan 1.3.1 ppid: 30652, pid: 30655, t: 0.0692s 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; 10 Aug 2016 20:07:05 -0000 To: PHP internals Message-ID: <10fbcb03-5de8-4d9a-da1c-7e2bf77937cb@lsces.co.uk> Date: Wed, 10 Aug 2016 21:07:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Simple variable handling. From: lester@lsces.co.uk (Lester Caine) People keep complaining that I do not contribute any proposals to improve PHP, which to some extent s correct. Except the one thing that I keep trying to get a handle on is tidying validating of the basic variables that are the heart of PHP. validate_var_array() is a case in point, since ALL it should do is handle an array of simple variables for which we can define REAL validation rules rather than just a very restricted 'type' rule. Massaging the way the content of a variable is presented is another part of the basic functions of handling a variable, and simply providing an escape option which can be set as part of the variable rules set eliminates the need for 'New operator (short tag) for context-dependent escaping' and similar tangential matters. If we have a set of rules wrapping a variable then everything else just follows on, and the SQL domain model allows a group of variables to take an identical se of rules. These are the sorts of things any decent user world library can and does provide, but if the clock was rolled back prior to all the trouble created by 'strict typing' and we started again with a more well defined simple variable I'm sure that much of the conflict could have been resolved by allowing full validation checks to control an error or exception depending on the 'style' of PHP a programmer prefers. If a function is going to return a variable and that variable has under the hood a set of validation rules, then one can return an error if the result is faulty. Or even allow a NULL return if a valid answer is not available ... if that is the style of programming one prefers. Exceptions handle unmanaged errors, while proper program flow handles managed ones! Wrap these intelligent variables inside a class and one can create more powerful objects but ones which still use all the basic functionality. Similarly an array of them can be asked to provide a simple 'yes/no' if all of the variables pass their validation check, or an array of elements which need processing. -- 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