php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63422 incorrect work is_callable
Submitted: 2012-11-02 18:04 UTC Modified: 2012-11-03 14:46 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: iblacksmoke at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.4.8 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: iblacksmoke at gmail dot com
New email:
PHP Version: OS:

 

 [2012-11-02 18:04 UTC] iblacksmoke at gmail dot com
Description:
------------
Is_callable function doesnt determine ability to call private method in class, even if this call made in context of class, from which you can call private function.

Test script:
---------------
class A {
	public function test($method){
		return (is_callable($this, $method)) ? 'yes' : 'no';
	}
	private function qwerty(){}
}

echo (new A)->test('qwerty');

Expected result:
----------------
yes

Actual result:
--------------
no

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-03 03:18 UTC] pierrick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

There is a bug in your code

it should be is_callable(array($this, $method))
 [2012-11-03 03:18 UTC] pierrick@php.net
-Status: Open +Status: Not a bug
 [2012-11-03 09:43 UTC] iblacksmoke at gmail dot com
But its illogical behavior of function. From place, where check, I can call my function, but is_callable says its impossible.
 [2012-11-03 14:46 UTC] pierrick@php.net
Please read my previous comment. Your code is wrong. Try this :

class A {
    public function test($method){
        return (is_callable(array($this, $method))) ? 'yes' : 'no';
    }                   
    private function qwerty(){}
}

echo (new A)->test('qwerty');
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 03:01:29 2024 UTC