[TYPO3-dev] Hooks and protected class members

Helmut Hummel helmut at typo3.org
Fri Sep 24 10:47:34 CEST 2010


Hi,

On 23.09.10 15:07, Jigal van Hemert wrote:
> 
> On 23-9-2010 13:28, Xavier Perseguers wrote:
>>>> Generally I don't think that a hook subscriber should have access to
>>>> all protected members by default.
>> Me neither.
> 
> I can't see the harm here. There is already an XCLASS mechanism which 
> enables extensions to change and access everything that is not private. 

There's no security problem allowing hooks to access protected member
variables. It's a matter of a clean and defined set of interfaces what a
hook subscriber should be able to do.

Protected member variables (and methods) are (should be) implementation
details thus subject to change. If you add magic getters, you sneak in
some kind of public API for them, so you can never change them.

> Hooks are better because their subscribers are more likely to survive 
> several versions and multiple subscribers can use the same hook.

Hooks are better and more compatible to future versions _because_ they
are limited (they only have a defined set of possibilities). If we
enable them to access arbitrary protected methods or meber variables,
this would change.

Just my 2 cents.

Regards Helmut




More information about the TYPO3-dev mailing list