|
Posted by Steve on 04/21/07 19:03
"Jim" <jimyt@yahoo.com> wrote in message
news:1177180911.763041.218230@d57g2000hsg.googlegroups.com...
| I've been reading the responses eagerly and can appreciate all the
| opinion. Truth is, I like the idea of being able to set a property
| with:
|
| $obj->prop = "a value";
|
| That seems natural to me and I think it's going to be the option I
| take........depending on the responses to my next question:
yes, it is natural. however you cannot currently control the immediate
validation of the property being accessed. __set and __get do NOT do what
you think it does.
| When properties are set, there'll be validation taking place. For
| example a string might be too long or in the wrong format in which
| case I need to let the user know that. Ideally the failure of
| validation should allow the user to continue assigning values to other
| properties and then once all the values are assigned, they can check
| to see if there were any validation errors.
this is all common stuff that everyone wants/has to do. however, you cannot
do it immediately when a property is set, unless you use a public setter.
| My first thought on this would be to have a "errors( )" method which
| would return a reference to an array of error messages which the user
| could then loop through and output to the browser. This same function
| could again be used by "component" object when assigning the "item"
| object to it to confirm it's valid.
|
| Does this seem sensible?
all of it is very sensible. i just wish __set and __get would work on
DEFINED properties instead of UNDEFINED properties of a class.
Navigation:
[Reply to this message]
|