Skip to content

Commit

Permalink
Add debugInfo to a few classes that cause recursion
Browse files Browse the repository at this point in the history
These objects often hold complicated cyclic references. This causes
something like debug($controller) to go horribly wrong. This removes the
most annoying cyclic references.
  • Loading branch information
markstory committed Jun 8, 2014
1 parent a343146 commit ea917fe
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Event/EventManager.php
Expand Up @@ -320,4 +320,19 @@ public function prioritisedListeners($eventKey) {
}
return $this->_listeners[$eventKey];
}

/**
* Debug friendly object properties.
*
* @return array
*/
public function __debugInfo() {
$properties = get_object_vars($this);
$properties['_generalManager'] = '(object) EventManager';
$properties['_listeners'] = [];
foreach ($this->_listeners as $key => $listeners) {
$properties['_listeners'][$key] = count($listeners) . ' listener(s)';
}
return $properties;
}
}
12 changes: 12 additions & 0 deletions src/Utility/ObjectRegistry.php
Expand Up @@ -221,4 +221,16 @@ public function unload($objectName) {
unset($this->_loaded[$objectName]);
}

/**
* Debug friendly object properties.
*
* @return array
*/
public function __debugInfo() {
$properties = get_object_vars($this);
$properties['_loaded'] = array_keys($properties['_loaded']);
return $properties;
}


}

0 comments on commit ea917fe

Please sign in to comment.