Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Function to check whether or not a callable can be bound to a PHP object.
<?php
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;
}
/*EOF*/
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.