note 102656 deleted from functions.anonymous by danbrown
| From: | danbrown@php.net | Date: | Sun, 27 Feb 2011 16:23:43 +0000 |
| Subject: | note 102656 deleted from functions.anonymous by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-177375@lists.php.net to get a copy of this message | ||
Note Submitter: floydian at phphorizons dot com
----
In regards to: Anonymous 03-Aug-2009 09:50
That test can fail. See code below:
<?php
class anon_test {
public function __invoke($args) {
}
}
$anon_test = new anon_test();
var_dump(is_callable($anon_test) && is_object($anon_test)); // bool(true)
var_dump($anon_test instanceof Closure); // bool(false)
?>
It seems that the only way to truly know if a variable contains an anonymous function is to use the
"implementation detail" that we are warned not to rely on.
Cheers