Permalink
Browse files

Fixed bug #63111 (is_callable() lies for abstract static method)

  • Loading branch information...
1 parent fd0b3ea commit 4db74b7f1981bf19805e815f983c50d93df2c26a @dstogov dstogov committed Sep 21, 2012
Showing with 45 additions and 1 deletion.
  1. +1 −0 NEWS
  2. +36 −0 Zend/tests/bug63111.phpt
  3. +8 −1 Zend/zend_API.c
View
@@ -3,6 +3,7 @@ PHP NEWS
?? ??? 2012, PHP 5.3.18
- Core:
+ . Fixed bug #63111 (is_callable() lies for abstract static method). (Dmitry)
. Fixed bug #63093 (Segfault while load extension failed in zts-build).
(Laruence)
. Fixed bug #62976 (Notice: could not be converted to int when comparing
@@ -0,0 +1,36 @@
+--TEST--
+Bug #63111 (is_callable() lies for abstract static method)
+--FILE--
+<?php
+abstract class Foo {
+ abstract static function bar();
+}
+interface MyInterface {
+ static function bar();
+}
+abstract class Bar {
+ static function foo() {
+ echo "ok\n";
+ }
+}
+var_dump(is_callable(array("Foo", "bar")));
+var_dump(is_callable("Foo::bar"));
+var_dump(is_callable(array("MyInterface", "bar")));
+var_dump(is_callable("MyInterface::bar"));
+var_dump(is_callable(array("Bar", "foo")));
+var_dump(is_callable("Bar::foo"));
+Bar::foo();
+Foo::bar();
+?>
+--EXPECTF--
+Strict Standards: Static function Foo::bar() should not be abstract in %sbug63111.php on line 3
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+bool(true)
+ok
+
+Fatal error: Cannot call abstract method Foo::bar() in %sbug63111.php on line 20
+
View
@@ -2603,7 +2603,14 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca
if (retval) {
if (fcc->calling_scope && !call_via_handler) {
- if (!fcc->object_ptr && !(fcc->function_handler->common.fn_flags & ZEND_ACC_STATIC)) {
+ if (!fcc->object_ptr && (fcc->function_handler->common.fn_flags & ZEND_ACC_ABSTRACT)) {
+ if (error) {
+ zend_spprintf(error, 0, "cannot call abstract method %s::%s()", fcc->calling_scope->name, fcc->function_handler->common.function_name);
+ retval = 0;
+ } else {
+ zend_error(E_ERROR, "Cannot call abstract method %s::%s()", fcc->calling_scope->name, fcc->function_handler->common.function_name);
+ }
+ } else if (!fcc->object_ptr && !(fcc->function_handler->common.fn_flags & ZEND_ACC_STATIC)) {
int severity;
char *verb;
if (fcc->function_handler->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {

0 comments on commit 4db74b7

Please sign in to comment.