Hi,
Thanks for all the work on Feeds. I think there might be an issue in the code, but I'm not sure if the comment's off, or the code (or me!).
FeedsConfigurable::__get() is documented with Override magic method __get(). Make sure that $this->config goes through getConfig(). The implementation does a bit more than that though:
it publicly exposes any private members that FeedsConfigurable itself may have (none at the mo), and also any protected members declared anywhere in the inheritance hierarchy. Also it doesn't generate a warning for non-existent members.
If you're happy with the implementation as it is, I think it would be nice to expand the comment to explain its effect.
Thanks again
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | feeds-feedsconfigurable-__get-comment-2636342-8.patch | 1.2 KB | megachriz |
| #4 | feeds-feedsconfigurable___get_comment-2636342-4-D7.patch | 1.11 KB | andyf |
Comments
Comment #2
andyf commentedComment #3
megachrizIt seemed to be added on purpose to "fix warnings". See commit.
Anyway, I'm fine with the implementation as it is. Code in the module and probably also contrib code already tries to access private/protected members. As long as these properties can't be set outside of the class, I don't see any concerns.
It's a good idea to expand the documentation of this method. Any suggestion for the additional documentation?
Comment #4
andyf commentedOK so I think maybe there's another difference I hadn't noticed. IIUC the magic function won't be used for
$this->configas written in the comment. (__get() is utilized for reading data from inaccessible properties.) I don't know if other code is relying on that anywhere?Anyways, I've attached a patch with a suggestion for updating the comment.
Thanks
Comment #5
andyf commentedComment #6
megachrizYou are right about
$this->config. Within the class itself and in child classes the method__get()isn't called when accessing$this->config. I looked at the code of child classes, but could not see anything that might cause something bad so far. Note that in the construct method of FeedsConfigurable the result ofFeedsConfigurable::configDefaults()is assigned to$this->config. This method is also called inFeedsConfigurable::getConfig().I think I would change "publicly accessible" to "publicly readable".
Maybe it is enough to document that own private and protected properties are exposed and remove the note about descendents properties. Classes that extend FeedsConfigurable could in theory override __get(). And FeedsConfigurable doesn't know by itself that it is extended (we know though). What do you think?
Comment #7
andyf commentedThanks, I'll do that.
Personally, I'd argue that the comment is only describing the behavior of the method, which is that it exposes descendent protected properties. If we later derive from that class and override
__get()and change the behaviour, it should then be documented in the derived class__get().Just my 2 cents, thanks!
Comment #8
megachrizWhat do you think of the documentation in the attached patch?
Comment #9
andyf commented+1 seems easier to understand to me, thanks!
Comment #10
megachrizThanks for your feedback, AndyF! Committed #8.