Doc #80110 [Ver->Csd]: object with __invoke method is considered callable
| From: | phpdocbot@php.net | Date: | Thu, 17 Sep 2020 10:12:15 +0000 |
| Subject: | Doc #80110 [Ver->Csd]: object with __invoke method is considered callable | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-17894@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80110&edit=1
ID: 80110
Updated by: phpdocbot@php.net
Reported by: divinity76+spam at gmail dot com
Summary: object with __invoke method is considered callable
-Status: Verified
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
PHP Version: 8.0.0beta3
Block user comment: N
Private report: N
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2020-09-16 08:32:25] 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-16 06:58:18] 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)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80110&edit=1