>> So we have one set of properties where get and isset use different >> methods >> and another set of properties where get and isset use same method but >> with >> parameter. I think it's not the best way to go. It's better to ignore >> isset >> altogether than this. > > No. The prototype of all setters would be the same. As would the > prototype of all getters. > > The prototype would be ... > > [public|protected|private] property $property { > [public|protected|private] mixed|bool get([bool $isset = false]) { > // mixed result for get, bool result for isset > }, > [public|protected|private] mixed|void set(mixed $value [, bool > $unset = false]) { // mixed result for set, void result for unset > }, > }; > > > From a user's perspective ... > > echo isset($instance->property) ? 'isset to ' . $instance->property : > 'not isset'; > > This would result in 2 calls ... > > property->get(true) // Let the getter that an attempt is being made to > see if the property has been set. > and > property->get(false) // Let the getter know that the getter is > expected to return the properties value. > > Similarly for the setter. > > $instance->property = 'foo'; > unset($instance->property); > > would result in 2 calls ... > > property->set('foo', false) // Let the setter know that it should be > setting the value of the property to 'foo'. > and > property->set(null, true) // Let the setter know that an attempt to > unset the property has taken place. > > > > Maybe the proposal should be changed to ... > > > [public|protected|private] property $property { > [public|protected|private] mixed get() { > }, > [public|protected|private] mixed set(mixed $value) { > }, > [public|protected|private] bool isset() { > }, > [public|protected|private] void unset() { > }, > }; > > (NOTE: Add in abstract and final as appropriate).
This last syntax makes far more sense than adding parameters to the get/set methods. The problem however, is what does isset and unset do/return if they are not defined? What if I only want to define the get/set and I do not define the isset/unset? If they are required, properties are far too complex to be useful. But if they are optional, we are back to the same problem of what isset() and unset() are supposed to do... - Dennis -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php