Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95056 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77081 invoked from network); 12 Aug 2016 02:28:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Aug 2016 02:28:40 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@ohgaki.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@ohgaki.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ohgaki.net designates 180.42.98.130 as permitted sender) X-PHP-List-Original-Sender: yohgaki@ohgaki.net X-Host-Fingerprint: 180.42.98.130 ns1.es-i.jp Received: from [180.42.98.130] ([180.42.98.130:53583] helo=es-i.jp) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7A/C2-56950-6543DA75 for ; Thu, 11 Aug 2016 22:28:40 -0400 Received: (qmail 70541 invoked by uid 89); 12 Aug 2016 02:28:35 -0000 Received: from unknown (HELO mail-qt0-f177.google.com) (yohgaki@ohgaki.net@209.85.216.177) by 0 with ESMTPA; 12 Aug 2016 02:28:35 -0000 Received: by mail-qt0-f177.google.com with SMTP id w38so6973903qtb.0 for ; Thu, 11 Aug 2016 19:28:34 -0700 (PDT) X-Gm-Message-State: AEkooustBIS3li14ysvRpDOUOr/6dIrA1rzEv3NUpCi75wQHGKfHU/jSqv1VmVmRs93ik3eAndkDneUDUxKkXg== X-Received: by 10.237.53.157 with SMTP id c29mr14904335qte.75.1470968907816; Thu, 11 Aug 2016 19:28:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.85.242 with HTTP; Thu, 11 Aug 2016 19:27:47 -0700 (PDT) In-Reply-To: <10fbcb03-5de8-4d9a-da1c-7e2bf77937cb@lsces.co.uk> References: <10fbcb03-5de8-4d9a-da1c-7e2bf77937cb@lsces.co.uk> Date: Fri, 12 Aug 2016 11:27:47 +0900 X-Gmail-Original-Message-ID: Message-ID: To: Lester Caine Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Simple variable handling. From: yohgaki@ohgaki.net (Yasuo Ohgaki) Hi Lester, On Thu, Aug 11, 2016 at 5:07 AM, Lester Caine wrote: > 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. It sounds you are looking for autoboxing (or at least something similar) https://wiki.php.net/rfc/autoboxing I like this proposal, BTW. I'm not sure performance impact, though. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net