Re: [PHP-DEV] Simple variable handling.

2016-08-15 Thread Lester Caine
On 15/08/16 11:25, Tony Marston wrote: > The Data Dictionary is one that I wrote, and is available in my open > source Radicore framework. > > I don't use PDO as it was not created until years AFTER I had built my > own solution. Besides, PDO does not do data validation. > > I have no intention

Re: [PHP-DEV] Simple variable handling.

2016-08-15 Thread Tony Marston
"Marco Pivetta" wrote in message news:CADyq6s+LjfL5g2mLNz=XSk7BWT=p3vftgsicgjgck-tz0ce...@mail.gmail.com... Hey Tony, On Sun, Aug 14, 2016 at 10:50 AM, Tony Marston wrote: "Marco Pivetta" wrote in message news:CADyq6sKZRBvYFtqyKYVYM4iU

Re: [PHP-DEV] Simple variable handling.

2016-08-15 Thread Tony Marston
"Lester Caine" wrote in message news:4b381281-204d-5e57-0bba-127ab8d2e...@lsces.co.uk... On 15/08/16 10:11, Tony Marston wrote: The origins of $fieldarray should be obvious. The $fieldspecs array is constructed from data which is originally extracted from the database schema, imported into my

Re: [PHP-DEV] Simple variable handling.

2016-08-15 Thread Lester Caine
On 15/08/16 10:11, Tony Marston wrote: > The origins of $fieldarray should be obvious. The $fieldspecs array is > constructed from data which is originally extracted from the database > schema, imported into my Data Dictionary, then exported into a PHP > script which is then included when the

Re: [PHP-DEV] Simple variable handling.

2016-08-15 Thread Tony Marston
"Lester Caine" wrote in message news:fe222876-6875-3f07-e25b-aea2cbbed...@lsces.co.uk... On 14/08/16 09:50, Tony Marston wrote: If you are still writing code to perform primary validation on each field then your coding style is way behind the times. At some point you need to know the rules

Re: [PHP-DEV] Simple variable handling.

2016-08-14 Thread Marco Pivetta
Hey Tony, On Sun, Aug 14, 2016 at 10:50 AM, Tony Marston wrote: > "Marco Pivetta" wrote in message news:CADyq6sKZRBvYFtqyKYVYM4iU > ex+2ouujvhep1jznm56k3+h...@mail.gmail.com... > >> >> So much confusion... >> >> There are 3 (or more) types of validation in pretty much

Re: [PHP-DEV] Simple variable handling.

2016-08-14 Thread Lester Caine
On 14/08/16 09:50, Tony Marston wrote: > If you are still writing code to perform primary validation on each > field then your coding style is way behind the times. At some point you need to know the rules that wrap each field you are working with. The sort of forms I work with have individual

Re: [PHP-DEV] Simple variable handling.

2016-08-14 Thread Tony Marston
"Marco Pivetta" wrote in message news:cadyq6skzrbvyftqykyvym4iuex+2ouujvhep1jznm56k3+h...@mail.gmail.com... So much confusion... There are 3 (or more) types of validation in pretty much every web-app, so let's please stop calling it simply "validation". 1. frontend validation

Re: [PHP-DEV] Simple variable handling.

2016-08-13 Thread Lester Caine
On 13/08/16 18:28, Marco Pivetta wrote: > A "NI" or "Email address" concept is only a string at low level. Yes ... but where do you store the flag such as "NI" ... > It is well known/accepted that such concepts should be turned into > simple objects instead, so that you can actually use

Re: [PHP-DEV] Simple variable handling.

2016-08-13 Thread Marco Pivetta
A "NI" or "Email address" concept is only a string at low level. It is well known/accepted that such concepts should be turned into simple objects instead, so that you can actually use type-signatures to type-hint against NI/Email. This avoids having to re-validat e for data-integrity and

Re: [PHP-DEV] Simple variable handling.

2016-08-13 Thread Lester Caine
On 13/08/16 14:43, Marco Pivetta wrote: > It receives a value (nested, if necessary) and tells us if it is valid or > not, plus why (as a set of strings, usually). > > This is validation. Please do use separate terminology if you mean: > * "frontend (client-side) validation" > * "frontend

Re: [PHP-DEV] Simple variable handling.

2016-08-13 Thread Marco Pivetta
So much confusion... There are 3 (or more) types of validation in pretty much every web-app, so let's please stop calling it simply "validation". 1. frontend validation (unsafe/unreliable), prevents invalid data submission, makes things friendlier for the user 2. form validation, in the

Re: [PHP-DEV] Simple variable handling.

2016-08-13 Thread Lester Caine
On 13/08/16 10:14, Tony Marston wrote: > I do not see that complicating the language by making it do what SHOULD > be done in userland code is a good idea. Helping 1% of users while > hindering the remaining 99% is not an idea which should EVER be > contemplated. I'm currently looking to

Re: [PHP-DEV] Simple variable handling.

2016-08-13 Thread Tony Marston
"Peter Lind" wrote in message news:caeu6nadvbkmqhju0assr5f+ubo9vvryjyvjmr0ihxb8bdmg...@mail.gmail.com... On 12 August 2016 at 12:13, Lester Caine wrote: On 12/08/16 10:42, Peter Lind wrote: > On 12 August 2016 at 11:25, Lester Caine wrote: > > Thanks

Re: [PHP-DEV] Simple variable handling.

2016-08-13 Thread Tony Marston
"Niklas Keller" wrote in message news:canuqdcjaxejscajye+q-uhxcfjexwrywlkzmfwrqvdaewvb...@mail.gmail.com... 2016-08-11 14:42 GMT+02:00 Lester Caine : On 11/08/16 04:56, Michal Brzuchalski wrote: > You want to stick such validation at runtime at any time with variable and

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Lester Caine
On 12/08/16 12:13, Yasuo Ohgaki wrote: >> I may be missing something, but I thought the original code had rules >> > for each element of the array? I would certainly expect to see the >> > capability of setting different validating rules for each element, and >> > the rules you are defining are

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Lester Caine
On 12/08/16 12:18, Peter Lind wrote: > On 12 August 2016 at 13:15, Lester Caine wrote: > >> On 12/08/16 12:09, Peter Lind wrote: >>> And if all typos were switching 'e' and 'n', what a wonderful world it >>> would be. That is not the case though - it's possible to

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Peter Lind
On 12 August 2016 at 13:15, Lester Caine wrote: > On 12/08/16 12:09, Peter Lind wrote: > > And if all typos were switching 'e' and 'n', what a wonderful world it > > would be. That is not the case though - it's possible to accidentally > enter > > " and > too. > And the

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Yasuo Ohgaki
Hi Lester, On Fri, Aug 12, 2016 at 8:13 PM, Yasuo Ohgaki wrote: > On Fri, Aug 12, 2016 at 8:06 PM, Lester Caine wrote: >> On 12/08/16 11:51, Yasuo Ohgaki wrote: >>> What makes you feel missing some or designed badly? >> >> I may be missing something, but

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Lester Caine
On 12/08/16 12:09, Peter Lind wrote: > And if all typos were switching 'e' and 'n', what a wonderful world it > would be. That is not the case though - it's possible to accidentally enter > " and > too. And the browser validation strips them and handles the ' when used in text fields. -- Lester

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Yasuo Ohgaki
Hi Lester, On Fri, Aug 12, 2016 at 8:06 PM, Lester Caine wrote: > On 12/08/16 11:51, Yasuo Ohgaki wrote: >> What makes you feel missing some or designed badly? > > I may be missing something, but I thought the original code had rules > for each element of the array? I would

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Peter Lind
On 12 August 2016 at 13:01, Lester Caine wrote: > On 12/08/16 11:01, Peter Lind wrote: > > On 12 August 2016 at 11:54, Rowan Collins > wrote: > > > >> On 12/08/2016 10:21, Lester Caine wrote: > >> > >>> Many of my systems run on secure intra-nets and

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Peter Lind
On 12 August 2016 at 12:52, Lester Caine wrote: > On 12/08/16 11:23, Peter Lind wrote: > > On 12 August 2016 at 12:13, Lester Caine wrote: > > > >> On 12/08/16 10:42, Peter Lind wrote: > >>> On 12 August 2016 at 11:25, Lester Caine

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Lester Caine
On 12/08/16 11:51, Yasuo Ohgaki wrote: > What makes you feel missing some or designed badly? I may be missing something, but I thought the original code had rules for each element of the array? I would certainly expect to see the capability of setting different validating rules for each element,

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Lester Caine
On 12/08/16 11:01, Peter Lind wrote: > On 12 August 2016 at 11:54, Rowan Collins wrote: > >> On 12/08/2016 10:21, Lester Caine wrote: >> >>> Many of my systems run on secure intra-nets and much of the 'safety >>> concerns' that have been brought up recently as

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Lester Caine
On 12/08/16 11:23, Peter Lind wrote: > On 12 August 2016 at 12:13, Lester Caine wrote: > >> On 12/08/16 10:42, Peter Lind wrote: >>> On 12 August 2016 at 11:25, Lester Caine wrote: >>> >>> Thanks for the ideas on this feature. >>> >>> A few thoughts. >>>

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Yasuo Ohgaki
Hi Lester, On Fri, Aug 12, 2016 at 7:13 PM, Lester Caine wrote: >> That said, I generally think that built-in methods that accept Callables >> are a great way to go. It encourages reuse through modular composition - >> and could likely be a neater way around the throw

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Lester Caine
On 12/08/16 11:11, Yasuo Ohgaki wrote: > Hi Lester, > > On Fri, Aug 12, 2016 at 5:19 PM, Lester Caine wrote: >> > I'm thinking >> > $var->setConstraint() >> > $var->setEscape() >> > $var->setReadOnly() > DbC cannot cover all, but some of them can be covered during

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Peter Lind
On 12 August 2016 at 12:13, Lester Caine wrote: > On 12/08/16 10:42, Peter Lind wrote: > > On 12 August 2016 at 11:25, Lester Caine wrote: > > > > Thanks for the ideas on this feature. > > > > A few thoughts. > > 1. The RFC for this isn't a change - it's

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Rowan Collins
On 12/08/2016 10:52, Lester Caine wrote: I think the idea *I* am throwing out for discussion is a switch from global_library($var, ... ) to $var->global_library( ... ) where $var is now always an object without having every framework creating it's own version of the wrapper? So kind of an

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Lester Caine
On 12/08/16 10:42, Peter Lind wrote: > On 12 August 2016 at 11:25, Lester Caine wrote: > >> On 12/08/16 10:07, Christoph M. Becker wrote: > I'm thinking > $var->setConstraint() > $var->setEscape() > $var->setReadOnly() > > Rather than having to build

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Yasuo Ohgaki
Hi Lester, On Fri, Aug 12, 2016 at 5:19 PM, Lester Caine wrote: > I'm thinking > $var->setConstraint() > $var->setEscape() > $var->setReadOnly() DbC cannot cover all, but some of them can be covered during development. https://wiki.php.net/rfc/introduce_design_by_contract

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Peter Lind
On 12 August 2016 at 11:54, Rowan Collins wrote: > On 12/08/2016 10:21, Lester Caine wrote: > >> Many of my systems run on secure intra-nets and much of the 'safety >> concerns' that have been brought up recently as 'essential' simply don't >> apply. >> > > There's

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Rowan Collins
On 12/08/2016 10:21, Lester Caine wrote: Many of my systems run on secure intra-nets and much of the 'safety concerns' that have been brought up recently as 'essential' simply don't apply. There's always rogue employees / students / visitors with temporary access... But yes, IF you trust your

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Lester Caine
On 12/08/16 09:54, Rowan Collins wrote: > On 12/08/2016 09:19, Lester Caine wrote: >> 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

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Peter Lind
On 12 August 2016 at 11:25, Lester Caine wrote: > On 12/08/16 10:07, Christoph M. Becker wrote: > >> > I'm thinking > >> > $var->setConstraint() > >> > $var->setEscape() > >> > $var->setReadOnly() > >> > > >> > Rather than having to build 'reflections' classes to pull out

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Lester Caine
On 12/08/16 09:43, Michał Brzuchalski wrote: > 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 >

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Lester Caine
On 12/08/16 10:07, Christoph M. Becker wrote: >> > 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 >>

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Lester Caine
On 12/08/16 09:58, Rowan Collins wrote: >> 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

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread 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

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Rowan Collins
On 12/08/2016 08:51, Lester Caine wrote: 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? Just

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Rowan Collins
On 12/08/2016 09:19, Lester Caine wrote: 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. Note that as discussed

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Michał Brzuchalski
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

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread Michał Brzuchalski
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

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread 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

Re: [PHP-DEV] Simple variable handling.

2016-08-12 Thread 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

Re: [PHP-DEV] Simple variable handling.

2016-08-11 Thread 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 >

Re: [PHP-DEV] Simple variable handling.

2016-08-11 Thread Rowan Collins
On 11/08/2016 21:19, Lester Caine wrote: No ... add more than just validation rules. Include facilities such as escape rules, display rules and variable specific material such as error messages. Just how the rules are enforced needs to be flexible and such things as 'required' will vary how the

Re: [PHP-DEV] Simple variable handling.

2016-08-11 Thread Lester Caine
On 11/08/16 21:22, Fleshgrinder wrote: > What you are describing are classes. You can achieve all of that with them. > > You are completely right btw. that exceptions should not be used during > validation and for flow control. We have said all along that all of this can be done in classes, and

Re: [PHP-DEV] Simple variable handling.

2016-08-11 Thread Fleshgrinder
On 8/11/2016 10:19 PM, Lester Caine wrote: > No ... add more than just validation rules. Include facilities such as > escape rules, display rules and variable specific material such as error > messages. > > Just how the rules are enforced needs to be flexible and such things as > 'required' will

Re: [PHP-DEV] Simple variable handling.

2016-08-11 Thread Lester Caine
On 11/08/16 16:14, Rowan Collins wrote: > On 11/08/2016 15:49, Lester Caine wrote: >> The question is not how >> you flag an error, but rather when do you check for one. If the 'load' >> function from a database record or the populate from a web form results >> in $age not being valid one handles

Re: [PHP-DEV] Simple variable handling.

2016-08-11 Thread Rowan Collins
On 11/08/2016 16:22, Michał Brzuchalski wrote: Wgat about static analysis and IDE support? They probably can handle all those sugarcandies because tgey are sticjed to variable but not with any dynamic rules procedural style. Am I right? Yep, that's a good point, add "machine-friendly"

Re: [PHP-DEV] Simple variable handling.

2016-08-11 Thread Michał Brzuchalski
Wgat about static analysis and IDE support? They probably can handle all those sugarcandies because tgey are sticjed to variable but not with any dynamic rules procedural style. Am I right? 11.08.2016 17:17 "Rowan Collins" napisał(a): > On 11/08/2016 15:49, Lester Caine

Re: [PHP-DEV] Simple variable handling.

2016-08-11 Thread Rowan Collins
On 11/08/2016 15:49, Lester Caine wrote: The question is not how you flag an error, but rather when do you check for one. If the 'load' function from a database record or the populate from a web form results in $age not being valid one handles that situation based on the data model. If you are

Re: [PHP-DEV] Simple variable handling.

2016-08-11 Thread Lester Caine
On 11/08/16 14:51, Rowan Collins wrote: > On 11/08/16 13:50, Niklas Keller wrote: >>> > If not by using exceptions, how would you handle them if you assign >>> such >>> > checks to variables and assign a wrong value? > > On 11/08/2016 14:29, Lester Caine wrote: >> if ( !$age->set(

Re: [PHP-DEV] Simple variable handling.

2016-08-11 Thread Rowan Collins
On 11/08/16 13:50, Niklas Keller wrote: > If not by using exceptions, how would you handle them if you assign such > checks to variables and assign a wrong value? On 11/08/2016 14:29, Lester Caine wrote: if ( !$age->set( $result_set['age'] ) ) { // handle error } else { // next step } So,

Re: [PHP-DEV] Simple variable handling.

2016-08-11 Thread Lester Caine
On 11/08/16 13:50, Niklas Keller wrote: >> Now this is where the fundamental difference in styles comes in. >> > PERSONALLY I would not be looking to throw exceptions at all. The whole >> > point of validation is to handle any validation error ... and it is an >> > error not an exception. >> > >

Re: [PHP-DEV] Simple variable handling.

2016-08-11 Thread Niklas Keller
2016-08-11 14:42 GMT+02:00 Lester Caine : > On 11/08/16 04:56, Michał Brzuchalski wrote: > > You want to stick such validation at runtime at any time with variable > and > > throwing \TypeError at any time constraint is broken - wouldn't it cause > of > > throwing much more

Re: [PHP-DEV] Simple variable handling.

2016-08-11 Thread Lester Caine
On 11/08/16 04:56, Michał Brzuchalski wrote: > You want to stick such validation at runtime at any time with variable and > throwing \TypeError at any time constraint is broken - wouldn't it cause of > throwing much more unexpected exceptions during runtime? > Imagine you'll be passing such

Re: [PHP-DEV] Simple variable handling.

2016-08-10 Thread Michał Brzuchalski
You want to stick such validation at runtime at any time with variable and throwing \TypeError at any time constraint is broken - wouldn't it cause of throwing much more unexpected exceptions during runtime? Imagine you'll be passing such variable with constraint into some object who operates on

Re: [PHP-DEV] Simple variable handling.

2016-08-10 Thread Bishop Bettini
On Wed, Aug 10, 2016 at 4:07 PM, 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

[PHP-DEV] Simple variable handling.

2016-08-10 Thread Lester Caine
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