| Issue 73: | magic get/set methods | |
| 1 person starred this issue and may be notified of changes. | Back to list |
Hi, could you please replace these with just getters/setters or declare appropriate fields as protected? The presence of magic get/set hides the real presence/absence of fields, thus accessing any not existent field from a derived class does not produce any errors. This increase debugging time significantly, while having regular getters/setters would be able to detect such issues during a few seconds Thanks
Sep 18, 2013
#1
m...@mail.ru
Sep 19, 2013
In my opinion, getter and setter functions would decrease readability without offering any real benefit. I can't really think of any situation where someone would spend significantly more time because he's misspelled a variable name. If and when php will implement proper getter/setter syntax (not defining getVariable/setVariable functions) functions, I will use them. Your concern about hiding the real presence of fields is somewhat valid though, but can be solved by implementing __isset. And that's what I'll do (or you can submit a patch/pull request, if you want to).
Sep 19, 2013
at least could you please throw an exception on access to not existent fields? It is really easy fix, just to add one more 'else' thanks |