It's good that this thread transformed from a theoretical war into a practical discussion 
I just want to add a theoratical point that IMHO has been missed:
To model a class with get* and set* accessors (like the initial question was) matches the concept of a Java Bean.
AFAIK Beans were invented to give the programmer the ability to deal with classes of which the implementation is not initially known.
Everything that needs to be accessible as an "attribute" of the object has to have a getter method.
Remember: a class could have member variables that shouldn't be accessible (you won't have to care about that with PHP5) or "attributes" that consist of the state of more than one member variable. That's why direct access to members doesn't give you enough possibilities.
Using Reflection, you can do a lot of things generally with unknown "Beans" and therefore you won't need to write code for each class taking part in a certain activity. I've been told that this was the main cause for the invention of Beans.
For example I use bean-like classes and a Reflection in a lot of ways, some simple examples:
You can auto-generate forms from beanlike classes
PHP Code:
...
$methods = get_class_methods(get_class($myBean));
foreach($methods as $method) {
if (substr(0,3, $method) == 'get') {
$attribute = substr(4, strlen($method), $method);
$myFormObject->addField($attribute);
$myFormObject->setFieldVal($attribute, $myBean->$method());
}
}
...
You can easily populate beanlike objects from database query results given as arrays in a similar way and I think O/R Mapping uses similar Reflection methods to persist objects.
Bookmarks