]> granicus.if.org Git - php/commitdiff
- Fixed bug #51176 (Static calling in non-static method behaves like $this->)
authorFelipe Pena <felipe@php.net>
Tue, 2 Mar 2010 00:16:40 +0000 (00:16 +0000)
committerFelipe Pena <felipe@php.net>
Tue, 2 Mar 2010 00:16:40 +0000 (00:16 +0000)
NEWS
Zend/tests/bug45180.phpt
Zend/tests/bug45186.phpt
Zend/tests/bug51176.phpt [new file with mode: 0644]
Zend/tests/call_static_003.phpt
Zend/tests/call_static_007.phpt
Zend/zend_object_handlers.c

diff --git a/NEWS b/NEWS
index 54d6320d1b2f800b860b95236cc8b45cdd0a2513..99fa8b52b6d75de7df16f18160f80524844a826c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -69,7 +69,9 @@ PHP                                                                        NEWS
 - Fixed memory leak in the realpath cache on Windows. (Pierre)
 - Fixed memory leak in zip_close. (Pierre)
 
-- Fixed #51059 (crypt crashes when invalid salt are given). (Pierre)
+- Fixed bug #51176 (Static calling in non-static method behaves like $this->).
+  (Felipe)
+- Fixed bug #51059 (crypt crashes when invalid salt are given). (Pierre)
 - Fixed bug #50952 (allow underscore _ in constants parsed in php.ini files).
   (Jani)
 - Fixed bug #50940 (Custom content-length set incorrectly in Apache SAPIs).
index 285543aaf08d22d35461c502774ba7f17a857aad..4e1ab9ee0829e3c69251e81862a5b62bcc878bb8 100644 (file)
@@ -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"
index bcf88a1897603dc9b3620709d02bd6a96d52d78a..da7ac73f5cefbae7be1e686ac0c2ed780c529be9 100644 (file)
@@ -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 (file)
index 0000000..436378e
--- /dev/null
@@ -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
index 566ff0fdf220b4cd3e52eee7387d83da42617ded..d5e2b75298ca305ac93d379e85a0f51d7af27c08 100644 (file)
@@ -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"
index 419f102310313ec3f51d574fcbe452bcd126ccf2..766802092ba9b7d46abdb09699086e29ea1b7ee2 100644 (file)
@@ -30,5 +30,5 @@ a::Foo();
 --EXPECT--
 __callstatic: Test
 __call: Test
-__call: Bar
+__callstatic: Bar
 __callstatic: Foo
index 888831c27145a76ac537345771e0a56ca6dab2ab..1424a111c41aa04a987fe2700eba018bb7a8dacd 100644 (file)
@@ -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;
                }