You know that anonymous function is just an instance of class `Closure` so this would be equivalent to check whether a variable is an anonymous function or not:
<?php
$test = function () {};
if (is_callable($test) && is_object($test) && $test instanceof Closure) { /* ... */ }
?>