Bug #50289 [Nab]: method_exists doesn't work on "self"

From: Date: Fri, 15 Jan 2016 13:53:54 +0000
Subject: Bug #50289 [Nab]: method_exists doesn't work on "self"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198681@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=50289&edit=1 ID: 50289 Updated by: danack@php.net Reported by: soapergem at gmail dot com Summary: method_exists doesn't work on "self" Status: Not a bug Type: Bug Package: Class/Object related Operating System: Windows XP PHP Version: 5.3.1 Block user comment: N Private report: N New Comment: Hi, Using this: method_exists(self::class, "method") gives the result you appear to want. Changing the behaviour of callable with respect to the string 'self' will require an RFC, which I plan to do for PHP 8. https://wiki.php.net/rfc/consistent_callables Previous Comments: ------------------------------------------------------------------------ [2009-11-25 07:52:38] jani@php.net callback != object or class name There is no bug here. ------------------------------------------------------------------------ [2009-11-24 21:37:28] soapergem at gmail dot com Description: ------------ method_exists doesn't work if you pass in a callback with a reference to "self". Yet call_user_func *does* work if you pass in a callback with a reference to "self". This is inconsistent and probably not intentional. Reproduce code: --------------- <?php class Test { public static function check_method() { var_dump(method_exists('self', 'output')); } public static function run_method() { call_user_func(array('self', 'output')); } public static function output() { echo 'this works'; } } Test::check_method(); Test::run_method(); ?> Expected result: ---------------- bool(true) this works Actual result: -------------- bool(false) this works ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=50289&edit=1

« previous php.bugs (#198681) next »