Doc #80110 [Opn->Ver]: object with __invoke method is considered callable
| From: | cmb@php.net | Date: | Wed, 16 Sep 2020 08:32:25 +0000 |
| Subject: | Doc #80110 [Opn->Ver]: object with __invoke method is considered callable | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-17893@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: cmb@php.net
Reported by: divinity76+spam at gmail dot com
Summary: object with __invoke method is considered callable
-Status: Open
+Status: Verified
Type: Documentation Problem
Package: Documentation problem
PHP Version: 8.0.0beta3
Block user comment: N
Private report: N
New Comment:
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>
Previous Comments:
------------------------------------------------------------------------
[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