Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Ensure we return a callback
Browse files Browse the repository at this point in the history
- Check to see if we have a WeakRef; if so, get the object it composes
  before returning the callback
  • Loading branch information
weierophinney committed Sep 23, 2011
1 parent e42dfab commit 5ac55ee
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/CallbackHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,25 @@ public function getCallback()
throw new Exception\InvalidCallbackException('Invalid callback provided; not callable');
}

return $this->callback;
$callback = $this->callback;
if (is_string($callback)) {
return $callback;
}

if ($callback instanceof WeakRef) {
return $callback->get();
}

if (is_object($callback)) {
return $callback;
}

list($target, $method) = $callback;
if ($target instanceof WeakRef) {
return array($target->get(), $method);
}

return $callback;
}

/**
Expand Down

0 comments on commit 5ac55ee

Please sign in to comment.