Edit report at http://bugs.php.net/bug.php?id=53009&edit=1
ID: 53009
User updated by: acid24 at gmail dot com
Reported by: acid24 at gmail dot com
Summary: Weird behavior of method_exists with anonymous
functions
Status: Open
Type: Bug
Package: Class/Object related
Operating System: Ubuntu 10.04
PHP Version: 5.3.3
Block user comment: N
New Comment:
provided wrong email address
Previous Comments:
------------------------------------------------------------------------
[2010-10-07 10:27:32] acid24 at gmail dot com
Description:
------------
method_exists() has a weird behavior when used on anonymous functions.
One would expect that testing the variable that holds the anonymous
function and the class of the anonymous function (Closure) to either
have or not the __invoke method. Instead method_exists() reports that
the variable that holds the anonymous function HAS an __invoke method
and the class of the anonymous function HAS NOT an __invoke method. Is
this behavior correct? If yes, maybe somebody can explain why. Thank you
in advance.
Test script:
---------------
<?php
$lambda = function() {};
var_dump( method_exists( $lambda, '__invoke' ) );
var_dump( method_exists( get_class( $lambda ), '__invoke' ) );
Expected result:
----------------
boolean(false)
boolean(false)
or
boolean(true)
boolean(true)
Actual result:
--------------
boolean(true)
boolean(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53009&edit=1