Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95058 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91028 invoked from network); 12 Aug 2016 07:51:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Aug 2016 07:51:24 -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.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:40404] helo=mail4.serversure.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 79/34-56950-AFF7DA75 for ; Fri, 12 Aug 2016 03:51:23 -0400 Received: (qmail 12889 invoked by uid 89); 12 Aug 2016 07:51:20 -0000 Received: by simscan 1.3.1 ppid: 12882, pid: 12886, t: 0.0894s 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; 12 Aug 2016 07:51:20 -0000 To: internals@lists.php.net References: <10fbcb03-5de8-4d9a-da1c-7e2bf77937cb@lsces.co.uk> Message-ID: Date: Fri, 12 Aug 2016 08:51:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Simple variable handling. From: lester@lsces.co.uk (Lester Caine) On 12/08/16 03:27, Yasuo Ohgaki wrote: > It sounds you are looking for autoboxing (or at least something similar) > > https://wiki.php.net/rfc/autoboxing That is interesting, and is probably something I would expect to come out in the wash with making a more intelligent variable. Except with PHP's loose casting style I would expect 'array_sum' to simply take a loose cast numeric version of every element. The tidy I think I am looking for is that 'is_num' rules on each variable would control the result. if any is 'null' the result is 'null' in normal SQL practice, or switch strict mode on and the first 'is_num' that fails throws an exception. > I like this proposal, BTW. I'm not sure performance impact, though. What I am still missing is an understanding of just how the global library of functions which act on a variable works internally with the 'list' of declared variables. People keep saying 'you just create a new object' but in my book still that object is a fixed set of code - the code library - and a variable set of data - the variable. Yes if the variable now has a flag which says 'constrained' then there will be an additional set of data with the constraints and as Rowan says, one has to decide where that is processed and what you do with the result, but the global code will check the 'constraint' element and see 'null' if it has not been processed, valid, or some failure message such as 'over limit'. CURRENTLY the constraint element is handled in user code working with a data set provided by docblock or other external storage means, SQL schema for example. From a performance point of view I still prefer that a lot of this is done in the IDE and that IS managing a lot of what we are talking about and has been since the 2004 date of that rfc. But almost every form I code on every website has a set of rules to constrain each input and that data needs to be used in the code to validate the variables being created, so isn't now the time to simply add global functions that provide a single built in standard for handling this problem? From a practical point of view of cause, the validation of inputs may well be done in the browser so that the constraints get passed TO some html5 check, or javascript function. So having uploaded the form one COULD simply tag a variable as valid? Or run the PHP validation as a safety check. All of this is workflow and that workflow could include a simple array function on the input array, but that still requires that there are a set of constraint rules for each element of the array ... applied to each variable ... so why can't we simply improve the variable? -- 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