summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2010-03-02 00:16:40 +0000
committerFelipe Pena <felipe@php.net>2010-03-02 00:16:40 +0000
commit79f618833f3576a54565273d76027b3c0bb1db89 (patch)
tree3a84f10b01ea3e326ca319f1e177027ecc3532dc /Zend
parentfcf1058d6bab4e80466f910ed42ab65ddaa93e2b (diff)
downloadphp-git-79f618833f3576a54565273d76027b3c0bb1db89.tar.gz
- Fixed bug #51176 (Static calling in non-static method behaves like $this->)
Diffstat (limited to 'Zend')
-rw-r--r--Zend/tests/bug45180.phpt6
-rw-r--r--Zend/tests/bug45186.phpt8
-rw-r--r--Zend/tests/bug51176.phpt32
-rw-r--r--Zend/tests/call_static_003.phpt4
-rw-r--r--Zend/tests/call_static_007.phpt2
-rw-r--r--Zend/zend_object_handlers.c6
6 files changed, 45 insertions, 13 deletions
diff --git a/Zend/tests/bug45180.phpt b/Zend/tests/bug45180.phpt
index 285543aaf0..4e1ab9ee08 100644
--- a/Zend/tests/bug45180.phpt
+++ b/Zend/tests/bug45180.phpt
@@ -43,11 +43,11 @@ __call:
string(3) "ABC"
__call:
string(3) "ABC"
-__call:
+__callstatic:
string(3) "XYZ"
-__call:
+__callstatic:
string(3) "WWW"
-__call:
+__callstatic:
string(3) "ABC"
__callstatic:
string(1) "A"
diff --git a/Zend/tests/bug45186.phpt b/Zend/tests/bug45186.phpt
index bcf88a1897..da7ac73f5c 100644
--- a/Zend/tests/bug45186.phpt
+++ b/Zend/tests/bug45186.phpt
@@ -35,17 +35,17 @@ call_user_func('self::y');
?>
--EXPECTF--
-__call:
+__callstatic:
string(3) "ABC"
-__call:
+__callstatic:
string(3) "ABC"
__call:
string(3) "xyz"
-__call:
+__callstatic:
string(3) "www"
__call:
string(1) "y"
-__call:
+__callstatic:
string(1) "y"
ok
__callstatic:
diff --git a/Zend/tests/bug51176.phpt b/Zend/tests/bug51176.phpt
new file mode 100644
index 0000000000..436378eff2
--- /dev/null
+++ b/Zend/tests/bug51176.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Bug #51176 (Static calling in non-static method behaves like $this->)
+--FILE--
+<?php
+class Foo
+{
+ public function start()
+ {
+ self::bar();
+ static::bar();
+ Foo::bar();
+ }
+
+ public function __call($n, $a)
+ {
+ echo "instance\n";
+ }
+
+ public static function __callStatic($n, $a)
+ {
+ echo "static\n";
+ }
+}
+
+$foo = new Foo();
+$foo->start();
+
+?>
+--EXPECT--
+static
+static
+static
diff --git a/Zend/tests/call_static_003.phpt b/Zend/tests/call_static_003.phpt
index 566ff0fdf2..d5e2b75298 100644
--- a/Zend/tests/call_static_003.phpt
+++ b/Zend/tests/call_static_003.phpt
@@ -28,9 +28,9 @@ foo::BAZ();
--EXPECT--
nonstatic
string(6) "fOoBaR"
-nonstatic
+static
string(6) "foOBAr"
-nonstatic
+static
string(6) "fOOBAr"
static
string(3) "bAr"
diff --git a/Zend/tests/call_static_007.phpt b/Zend/tests/call_static_007.phpt
index 419f102310..766802092b 100644
--- a/Zend/tests/call_static_007.phpt
+++ b/Zend/tests/call_static_007.phpt
@@ -30,5 +30,5 @@ a::Foo();
--EXPECT--
__callstatic: Test
__call: Test
-__call: Bar
+__callstatic: Bar
__callstatic: Foo
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index 888831c271..1424a111c4 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -953,13 +953,13 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, char *f
if (!fbc && zend_hash_find(&ce->function_table, lc_function_name, function_name_strlen+1, (void **) &fbc)==FAILURE) {
efree(lc_function_name);
- if (ce->__call &&
+ if (ce->__callstatic) {
+ return zend_get_user_callstatic_function(ce, function_name_strval, function_name_strlen);
+ } else if (ce->__call &&
EG(This) &&
Z_OBJ_HT_P(EG(This))->get_class_entry &&
instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) {
return zend_get_user_call_function(ce, function_name_strval, function_name_strlen);
- } else if (ce->__callstatic) {
- return zend_get_user_callstatic_function(ce, function_name_strval, function_name_strlen);
} else {
return NULL;
}