From:             
Operating system: Ubuntu 10.04
PHP version:      5.3.3
Package:          Class/Object related
Bug Type:         Bug
Bug description:Weird behavior of method_exists with anonymous functions

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 bug report at http://bugs.php.net/bug.php?id=53009&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=53009&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=53009&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=53009&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=53009&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=53009&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=53009&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=53009&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=53009&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=53009&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=53009&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=53009&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=53009&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=53009&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=53009&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=53009&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=53009&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=53009&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=53009&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=53009&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=53009&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=53009&r=mysqlcfg

Reply via email to