calmPress / calmpress

A modern CMS based on WordPress
https://calmpress.org/
22 stars 1 forks source link

Deprecate magic class functions __get, __set and __isset #93

Open markkap opened 6 years ago

markkap commented 6 years ago

If a property needs to be accessed than it either should be defined as public, or provide a relevant public functions. Use of magic functions is a major code smell.

As this might break plugins and themes we should do it in several phases

  1. Notice when WP_DEBUG is on. Target is version 2.0
  2. Error when WP_DEBUG is on, notice otherwise. Target is version 3.0
  3. Error. Target is version 4.0
  4. Code removal. Target is version 5.0
markkap commented 6 years ago

seems like same needs to be done with call and unset

mikeschinkel commented 6 years ago

Where are you planning to deprecate these, on what classes?

FYI, our WPLib library when we use for client projects would not be possible without __call(), and I can image useful architectures where there other magic methods are critical, and not code smells.

I will say that sometimes developers use them when they don't need to, but other times these methods are essential, such as when using containment vs. inheritance and delegating method calls and property gets/sets from the containing object to the contained object.