Skip to content

Commit ed3a2ee

Browse files
committed
Merge branch 'PHP-5.3' into PHP-5.4
* PHP-5.3: Fixed bug #63111 (is_callable() lies for abstract static method) Conflicts: NEWS
2 parents f037ddc + 4db74b7 commit ed3a2ee

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ PHP NEWS
1212
. Added optional second argument for assert() to specify custom message. Patch
1313
by Lonny Kapelushnik ([email protected]). (Lars)
1414
. Support building PHP with the native client toolchain. (Stuart Langley)
15+
. Fixed bug #63111 (is_callable() lies for abstract static method). (Dmitry)
1516
. Fixed bug #63093 (Segfault while load extension failed in zts-build).
1617
(Laruence)
1718
. Fixed bug #62976 (Notice: could not be converted to int when comparing

Zend/tests/bug63111.phpt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
Bug #63111 (is_callable() lies for abstract static method)
3+
--FILE--
4+
<?php
5+
abstract class Foo {
6+
abstract static function bar();
7+
}
8+
interface MyInterface {
9+
static function bar();
10+
}
11+
abstract class Bar {
12+
static function foo() {
13+
echo "ok\n";
14+
}
15+
}
16+
var_dump(is_callable(array("Foo", "bar")));
17+
var_dump(is_callable("Foo::bar"));
18+
var_dump(is_callable(array("MyInterface", "bar")));
19+
var_dump(is_callable("MyInterface::bar"));
20+
var_dump(is_callable(array("Bar", "foo")));
21+
var_dump(is_callable("Bar::foo"));
22+
Bar::foo();
23+
Foo::bar();
24+
?>
25+
--EXPECTF--
26+
Strict Standards: Static function Foo::bar() should not be abstract in %sbug63111.php on line 3
27+
bool(false)
28+
bool(false)
29+
bool(false)
30+
bool(false)
31+
bool(true)
32+
bool(true)
33+
ok
34+
35+
Fatal error: Cannot call abstract method Foo::bar() in %sbug63111.php on line 20
36+

Zend/zend_API.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2813,7 +2813,14 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
28132813

28142814
if (retval) {
28152815
if (fcc->calling_scope && !call_via_handler) {
2816-
if (!fcc->object_ptr && !(fcc->function_handler->common.fn_flags & ZEND_ACC_STATIC)) {
2816+
if (!fcc->object_ptr && (fcc->function_handler->common.fn_flags & ZEND_ACC_ABSTRACT)) {
2817+
if (error) {
2818+
zend_spprintf(error, 0, "cannot call abstract method %s::%s()", fcc->calling_scope->name, fcc->function_handler->common.function_name);
2819+
retval = 0;
2820+
} else {
2821+
zend_error(E_ERROR, "Cannot call abstract method %s::%s()", fcc->calling_scope->name, fcc->function_handler->common.function_name);
2822+
}
2823+
} else if (!fcc->object_ptr && !(fcc->function_handler->common.fn_flags & ZEND_ACC_STATIC)) {
28172824
int severity;
28182825
char *verb;
28192826
if (fcc->function_handler->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {

0 commit comments

Comments
 (0)