Skip to content

Commit ea917fe

Browse files
committed
Add debugInfo to a few classes that cause recursion
These objects often hold complicated cyclic references. This causes something like debug($controller) to go horribly wrong. This removes the most annoying cyclic references.
1 parent a343146 commit ea917fe

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/Event/EventManager.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,19 @@ public function prioritisedListeners($eventKey) {
320320
}
321321
return $this->_listeners[$eventKey];
322322
}
323+
324+
/**
325+
* Debug friendly object properties.
326+
*
327+
* @return array
328+
*/
329+
public function __debugInfo() {
330+
$properties = get_object_vars($this);
331+
$properties['_generalManager'] = '(object) EventManager';
332+
$properties['_listeners'] = [];
333+
foreach ($this->_listeners as $key => $listeners) {
334+
$properties['_listeners'][$key] = count($listeners) . ' listener(s)';
335+
}
336+
return $properties;
337+
}
323338
}

src/Utility/ObjectRegistry.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,16 @@ public function unload($objectName) {
221221
unset($this->_loaded[$objectName]);
222222
}
223223

224+
/**
225+
* Debug friendly object properties.
226+
*
227+
* @return array
228+
*/
229+
public function __debugInfo() {
230+
$properties = get_object_vars($this);
231+
$properties['_loaded'] = array_keys($properties['_loaded']);
232+
return $properties;
233+
}
234+
235+
224236
}

0 commit comments

Comments
 (0)