Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95063 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1153 invoked from network); 12 Aug 2016 08:44:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Aug 2016 08:44:03 -0000 Authentication-Results: pb1.pair.com smtp.mail=michal@brzuchalski.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=michal@brzuchalski.com; 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:44726] helo=poczta.brzuchalski.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 79/36-56950-15C8DA75 for ; Fri, 12 Aug 2016 04:44:01 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by poczta.brzuchalski.com (Postfix) with ESMTP id ED9F3298423C for ; Fri, 12 Aug 2016 10:43:57 +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 szvyKEd0zUY7 for ; Fri, 12 Aug 2016 10:43:54 +0200 (CEST) Received: from mail-qk0-f178.google.com (unknown [209.85.220.178]) by poczta.brzuchalski.com (Postfix) with ESMTPSA id 06B3B298423B for ; Fri, 12 Aug 2016 10:43:54 +0200 (CEST) Received: by mail-qk0-f178.google.com with SMTP id l2so19041610qkf.3 for ; Fri, 12 Aug 2016 01:43:53 -0700 (PDT) X-Gm-Message-State: AEkoous+RLGaGEth85LEeCBrfwRK+6R/4+a/VgKrE9avvbRhABADMeUtWwPDsNlGxpaSabinQlPT8dm0nQqHgQ== X-Received: by 10.55.9.147 with SMTP id 141mr15429844qkj.7.1470991433274; Fri, 12 Aug 2016 01:43:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.53.155 with HTTP; Fri, 12 Aug 2016 01:43:52 -0700 (PDT) In-Reply-To: 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> Date: Fri, 12 Aug 2016 10:43:52 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Lester Caine Cc: PHP Internals List Content-Type: multipart/alternative; boundary=001a114c4a6cd91c740539dbe173 Subject: Re: [PHP-DEV] Simple variable handling. From: michal@brzuchalski.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=) --001a114c4a6cd91c740539dbe173 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2016-08-12 10:19 GMT+02:00 Lester Caine : > 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. > Because escaping can differ in context of usage? (html, css, js, xml, json. etc.) IMHO escaping pinned to variable is just bad idea. In case of $var->setReadOnly() you will change variable behavior at runtime= , so it's behavior differs from one before that method run and after, it's about consistency! About ReadOnly I'm currently working on `immutable` feature proposal where could be possible to mark class and properties as immutable (ReadOnly after initialisation) so it could solve problem with ReadOnly ValueObjects and immutable properties which are simple primitives. > > -- > 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 --001a114c4a6cd91c740539dbe173--