2016-08-12 10:19 GMT+02:00 Lester Caine <les...@lsces.co.uk>:

> 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=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
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
pozdrawiam
--
Michał Brzuchalski

Reply via email to