Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95067 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7420 invoked from network); 12 Aug 2016 09:07:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Aug 2016 09:07:06 -0000 Authentication-Results: pb1.pair.com smtp.mail=cmbecker69@gmx.de; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=cmbecker69@gmx.de; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.de designates 212.227.15.15 as permitted sender) X-PHP-List-Original-Sender: cmbecker69@gmx.de X-Host-Fingerprint: 212.227.15.15 mout.gmx.net Received: from [212.227.15.15] ([212.227.15.15:52011] helo=mout.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 01/97-56950-9B19DA75 for ; Fri, 12 Aug 2016 05:07:06 -0400 Received: from [192.168.2.103] ([79.243.112.54]) by mail.gmx.com (mrgmx001) with ESMTPSA (Nemesis) id 0LvlTo-1b8nVJ2M72-017UFq; Fri, 12 Aug 2016 11:07:01 +0200 To: Lester Caine , internals@lists.php.net References: <10fbcb03-5de8-4d9a-da1c-7e2bf77937cb@lsces.co.uk> <5657afc7-7569-5fc4-4a5a-27ed786c4fa5@gmail.com> <0825c173-5cb4-7f65-cf34-b45ca30919a3@lsces.co.uk> <8646c3ad-b929-cb0b-bad4-52a0a7160d16@gmail.com> <11ce571b-964b-5a3e-9f2f-3f69a8bc20b4@lsces.co.uk> <7d9db8d5-ae7a-4123-14f4-f76fb6d764c5@gmail.com> Message-ID: Date: Fri, 12 Aug 2016 11:07:06 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:jUzRkBvNagVub/v0GU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5 4wQTpsj Subject: Re: [PHP-DEV] Simple variable handling. From: cmbecker69@gmx.de ("Christoph M. Becker") On 12.08.2016 at 10:19, Lester Caine wrote: > On 11/08/16 23:17, Rowan Collins wrote: > >> You've mentioned a lot about flexibility, and that the feature could be >> used in multiple styles, but some concrete examples of how *you* would >> use it might help define what the feature needs to do (and not do). > > Currently my code has lots of checks for constraints and that is hard > coded. Docblock helps to provide documentation and help in the IDE and > there is no fundamental reason to change anything ... except. Small > elements of the constraint process are being introduced into the > process. You can now complain if the variable is not an integer but it > does not remove the need to still check if the integer is valid. There > have been various discussions on how the rules for that extra step could > be added to PHP and in my book that has been there for years in the > docblocks, but other layers are being proposed to add them, and Yasuo is > now hiding them in his validate functions, so why not SIMPLY add a set > of functions to variables to allow those rules to be freely available > and managed on a variable by variable basis. The validate array function > would then simply iterate over a cleanly defined set of variables? Or > each variable can be managed in it's own right. > > I'm thinking > $var->setConstraint() > $var->setEscape() > $var->setReadOnly() > > Rather than having to build 'reflections' classes to pull out data that > a simple $var->is_valid or echo $var will output a correctly escaped > piece of text. Actually, this is already possible; just use objects. E.g. class Container { function __construct() {} function setConstraint() {} function setEscape() {} function setReadOnly() {} function isValid() {} function __toString() {} } $var = new Container($some_value); -- Christoph M. Becker