Are Magic Methods Best practice in PHP?

OM The Eternity picture OM The Eternity · Apr 23, 2010 · Viewed 11.1k times · Source

Are Magic Methods Best practice in PHP?

Answer

Heikki Naski picture Heikki Naski · Apr 23, 2010

cons

  1. Text searches don't find the functions

  2. System is harder to understand, especially for newcomers

  3. Refactoring tools might fail more often

Generally, the magic methods do things behind the scenes and the programmer might not realize it's happening which makes debugging harder.

When searching for the functions (or other symbols) can't find all the matches it becomes a nightmare to remove old code and this fear can cause dead code to pile up in the codebase. If the dead code is removed, it can cause breakage in unknown places.