Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

aren't you just managing them in a new syntax now?


The difference with property hooks and userland getter/setters is that you're now just doing

    echo $obj->prop
    $obj->prop = 'bar';
not

    echo $obj->getProp();
    $obj->setProp('bar');


A big part of this is about code that's consumed by third parties: i.e. library code.

Previously, it was very common to not expose a public property directly, even if it required no setter logic, because any future change to add setter logic would mean it has to become a setter method.

This results in potentially dozens of boilerplate getter/setter methods, that provide no actual benefit, but are necessary to avoid potential BC breaks in a future version of the library.

With property hooks, the property doesn't need to define any getter/setter logic initially - and adding a hook later to the `set` action doesn't change the way other code calls it.

So no, it isn't just "new syntax" now - it's a case of largely not needing to write/generate any of that boilerplate any more - it's just not needed, regardless of how that property's behaviour changes in future.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: