> > Second, I'd like to throw in the idea of array accessors. I mentioned
> > this before, but did not get any response.
> >
> > public $Addresses {
> >     offsetSet($offset, $value) { ... }
> >     offsetGet() { ... }
> >     offsetUnset($offset) { ... }
> >     offsetExists($offset) { ... }
> > }
> 
> Definitely on the "nice to have" list.

While I agree it would be a "nice to have" it would also be un-necessary.  
There are already ways to do precisely what is desired here by way of 
ArrayAccess.

class Addresses implements ArrayAccess {
        offsetSet($offset, $value) { ... }
        offsetGet() { ... }
        offsetUnset($offset) { ... }
        offsetExists($offset) { ... }
}


// In base class where the proposed additional accessor types were suggested
public $Addresses = new Addresses();

Or if you felt like using an accessor to control access to the Addresses 
object, you could implement that as well, but an accessor wouldn't even be 
necessary.

This would provide for cleaner object-oriented principles, the logic for 
dealing with acceptance of a new address stays within a class designed to hold 
and control access to the collection of addresses.




--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to