Skip to content

Instantly share code, notes, and snippets.

@Potherca
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Potherca/d4244af703c98aef58c4 to your computer and use it in GitHub Desktop.
Save Potherca/d4244af703c98aef58c4 to your computer and use it in GitHub Desktop.
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