In WordPress we have several objects defined through classes that are enough documented.
These are the WP_Query
, WPDB
, WP_Post
and other.
There are other objects however that are actually created at runtime, usually converting an array to a standard object, or reading from the DB.
For instance, the taxonomy object you get from get_taxonomy()
function.
Even though there isn’t an actual class that defines these objects, I wonder if there is any detailed documentation of all properties we can find in these objects that doesn’t require me to alway dig in the code to remember which are the properties names.
There is no such documentation, and I donât expect one anytime soon. WordPress could implement specialized property objects for these cases, for
get_taxonomies()
it could look like this:Your IDE would provide the methods per auto-complete then. No need for manual look-ups anymore.
But there are at least two reasons why this will not happen in the near future.
There is little interest in implementing OOP in core code. If you find an object at all, it does too much (look at
WP_Screen
for an example), or it is a third-party library (SimplePie).It would require a large clean-up, because many objects are de facto hidden. An example from the class
Walker_Nav_Menu
; look very carefully at$args
:$args
is not an array, it is one of those sloppy objects, created with type casting in the functionwp_nav_menu()
:$args = (object) $args;
.Now what? You cannot change the signatures in
Walker_Nav_Menu
, because that is a child class ofWalker
(one of the many reasons why inheritance is bad concept). Changing the child class signatures would raiseE_STRICT
notices. You cannot just pass an array, because that would break many third-party walkers. When you introduce new objects, you have to fix the classes that are using them at first. And there are probably many cases like this one.