3 ms·
aren't you just managing them in a new syntax now?
by mgkimsal 2y ago
aren't you just managing them in a new syntax now?
- joshmanders 2y agoThe 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');
- stephenr 2y agoA 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.