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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 14:01:30 2024 UTC