php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #80110 object with __invoke method is considered callable
Submitted: 2020-09-16 06:58 UTC Modified: 2020-09-16 08:32 UTC
From: divinity76+spam at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 8.0.0beta3 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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: divinity76+spam at gmail dot com
New email:
PHP Version: OS:

 

 [2020-09-16 06:58 UTC] divinity76+spam at gmail dot com
Description:
------------
the Callable documentation at https://www.php.net/manual/en/language.types.callable.php 
says these things can be callable: a string containing a function name or "ClassName::StaticMethod", and an array containing containing an object or classname in index 0 and a string in index 1, and finally, closures.


but every PHP version since 5.3.0 (when __invoke was introduced) consider an object with an __invoke method to be callable as well,

either the documentation is lacking and objects with __invoke are indeed callable, or the php implementation is wrong, i'm guessing it's the former

Test script:
---------------
<?php 
class C{
function __invoke(){}
}
var_dump(is_callable(new C));

Expected result:
----------------
// according to Callable type documentation
bool(false)

Actual result:
--------------
bool(true)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-16 08:32 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2020-09-16 08:32 UTC] cmb@php.net
Yes, indeed a documentation issue, as the __invoke() example[1]
shows.

[1] <https://www.php.net/manual/en/language.oop5.magic.php#language.oop5.traits.visibility.ex1>
 [2020-09-17 10:12 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=468e71623d4c2269ef237ce7ab5a2792dbd0e7b7
Log: Fix #80110: object with __invoke method is considered callable
 [2020-09-17 10:12 UTC] phpdocbot@php.net
-Status: Verified +Status: Closed
 [2020-09-18 10:45 UTC] phpdocbot@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=8a768647660657cc64eaf85cfd12b2d145f16c00
Log: Fix #80110: object with __invoke method is considered callable
 [2020-12-30 11:59 UTC] nikic@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=cf9bfbcac65a511aaa4f44306ea7ce8222b43b82
Log: Fix #80110: object with __invoke method is considered callable
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 02:01:32 2025 UTC