Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95062 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98544 invoked from network); 12 Aug 2016 08:36:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Aug 2016 08:36:33 -0000 Authentication-Results: pb1.pair.com header.from=michal@brzuchalski.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=michal@brzuchalski.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain brzuchalski.com designates 188.165.245.118 as permitted sender) X-PHP-List-Original-Sender: michal@brzuchalski.com X-Host-Fingerprint: 188.165.245.118 ns220893.ip-188-165-245.eu Received: from [188.165.245.118] ([188.165.245.118:43152] helo=poczta.brzuchalski.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 03/B5-56950-D8A8DA75 for ; Fri, 12 Aug 2016 04:36:31 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by poczta.brzuchalski.com (Postfix) with ESMTP id 33E46298423F for ; Fri, 12 Aug 2016 10:36:25 +0200 (CEST) Received: from poczta.brzuchalski.com ([127.0.0.1]) by localhost (poczta.brzuchalski.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WoTvW92YnE4s for ; Fri, 12 Aug 2016 10:36:22 +0200 (CEST) Received: from mail-qt0-f173.google.com (unknown [209.85.216.173]) by poczta.brzuchalski.com (Postfix) with ESMTPSA id C8F5C298423B for ; Fri, 12 Aug 2016 10:36:21 +0200 (CEST) Received: by mail-qt0-f173.google.com with SMTP id u25so9526703qtb.1 for ; Fri, 12 Aug 2016 01:36:21 -0700 (PDT) X-Gm-Message-State: AEkooutgVQnNyzOg7FTbDFmgeAUld72fA1a5xhb2qVkw6Pt0HD7GxU0FV8y5vGp5O9mPz0CXqRSsMNsM+tbXfw== X-Received: by 10.200.42.153 with SMTP id b25mr16036536qta.72.1470990980926; Fri, 12 Aug 2016 01:36:20 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.53.155 with HTTP; Fri, 12 Aug 2016 01:36:20 -0700 (PDT) In-Reply-To: References: <10fbcb03-5de8-4d9a-da1c-7e2bf77937cb@lsces.co.uk> Date: Fri, 12 Aug 2016 10:36:20 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Lester Caine Cc: PHP Internals List Content-Type: multipart/alternative; boundary=001a113ab766e2d52d0539dbc6ab Subject: Re: [PHP-DEV] Simple variable handling. From: michal@brzuchalski.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=) --001a113ab766e2d52d0539dbc6ab Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2016-08-12 9:51 GMT+02:00 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? > How does it differ from userland components/libraries like: Symfony Form https://github.com/symfony/form ZendFramework Form https://github.com/zendframework/zend-form Phalcon Form https://docs.phalconphp.com/en/latest/reference/forms.html and etc. They have additional functionalities to build form but validation looks the same you want to acheive. If most important thing of what you want to achieve is easy to use user input validation there are plenty of lib which does that. There you can put build in and own constraints, validate array and retrieve valid data. What is the reason such feature should be built in PHP language? > > -- > 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 > > --=20 pozdrawiam -- Micha=C5=82 Brzuchalski --001a113ab766e2d52d0539dbc6ab--