However, during some testing in preparation to trying your suggestion,
I discovered my
problem analysis was wrong:
I _can_ add instance variables, and they will not be caught by the
magic methods.
The only requirement is that they are declared in the class, and
accessed in scope.
My previous misunderstanding was probably a due to trying to access
a protected variable from the outside, but misdiagnosed as the magic setter
intervening in a valid reference.
It would still be nice to have a subclass like yours in the library to
derive from,
so you can add fields dynamically like normal in PHP.
But for this project, I am happy just declaring my extra fields as instance
variables in the class def.
-Joachim
没有评论:
发表评论