Bug #80323 [Com]: is_callable() not same to type "callable"
| From: | antonfedonyuk at gmail dot com | Date: | Thu, 05 Nov 2020 19:35:22 +0000 |
| Subject: | Bug #80323 [Com]: is_callable() not same to type "callable" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-230153@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80323&edit=1
ID: 80323
Comment by: antonfedonyuk at gmail dot com
Reported by: antonfedonyuk at gmail dot com
Summary: is_callable() not same to type "callable"
Status: Open
Type: Bug
Package: *General Issues
Operating System: Any
PHP Version: 7.2.34
Block user comment: N
Private report: N
New Comment:
> levim@php.net how you test it?
that code still generate error (tested in php 7.x):
<?php
class Test {
public function callback() {}
}
class Test2 {
public function set(callable $callback) {}
}
$callback = 'Test::callback';
var_dump(is_callable($callback));
$a = new Test2();
$a->set($callback);
?>
Previous Comments:
------------------------------------------------------------------------
[2020-11-05 19:29:18] antonfedonyuk at gmail dot com
> levim@php.net "you are calling
Test::callback without an
> object and it is not marked as statiÑ"
Congratulations, devs find 2 new bugs!
Or you don't see any problem here? (:
------------------------------------------------------------------------
[2020-11-05 19:15:14] levim@php.net
The "new" bug isn't a bug at all; you are calling Test::callback without
an object and it is not marked as static. Can you provide a reproduction case for the first bug?
------------------------------------------------------------------------
[2020-11-05 18:48:48] antonfedonyuk at gmail dot com
nikic@php.net find another bug!!! )))
It's really work fine and not generate errors:
<?php
class Test {
public function callback() {}
public function set(callable $callback) {}
}
$callback = ['Test', 'callback'];
var_dump(is_callable($callback));
$a = new Test();
$a->set($callback);
?>
But if we separate set() then php generate error "Deprecated: Non-static method
Test::callback() should not be called statically in ...":
<?php
class Test {
public function callback() {}
}
class Test2 {
public function set(callable $callback) {}
}
$callback = ['Test', 'callback'];
var_dump(is_callable($callback));
$a = new Test2();
$a->set($callback);
?>
------------------------------------------------------------------------
[2020-11-05 18:20:14] levim@php.net
We had bugs in differences in is_callable and callable in the past,
haven't we? Or maybe it was in is_callable/callable and actually
calling it. I wonder if we could specifically fuzz this.
------------------------------------------------------------------------
[2020-11-05 18:03:49] nikic@php.net
I can't reproduce this: https://3v4l.org/Q10AR
The call does not produce an error.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=80323
--
Edit this bug report at https://bugs.php.net/bug.php?id=80323&edit=1