Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Function to check whether or not a callable can be bound to a PHP object.
namespace PhpHooligans;
* @param \Closure $callable
* @return bool
function isBindable(\Closure $callable)
$bindable = false;
$reflectionFunction = new \ReflectionFunction($callable);
if (
$reflectionFunction->getClosureScopeClass() === null
|| $reflectionFunction->getClosureThis() !== null
) {
$bindable = true;
return $bindable;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.