]> 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)
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

index 887a1598818a421e6c2b08adfc0cbb0c14db4ddd..aab9b2a73c64c3331d69bb49c3e9682ae904a17d 100644 (file)
@@ -43,11 +43,11 @@ __call:
 unicode(3) "ABC"
 __call:
 unicode(3) "ABC"
-__call:
+__callstatic:
 unicode(3) "XYZ"
-__call:
+__callstatic:
 unicode(3) "WWW"
-__call:
+__callstatic:
 unicode(3) "ABC"
 __callstatic:
 unicode(1) "A"
index 2da7cf3260ff12cb427192f210c3881672c4f1de..e36738301124c9a2a336e999a34793ad195dd848 100644 (file)
@@ -35,17 +35,17 @@ call_user_func('self::y');
 
 ?>
 --EXPECTF--
-__call:
+__callstatic:
 unicode(3) "ABC"
-__call:
+__callstatic:
 unicode(3) "ABC"
 __call:
 unicode(3) "xyz"
-__call:
+__callstatic:
 unicode(3) "www"
 __call:
 unicode(1) "y"
-__call:
+__callstatic:
 unicode(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 174366773eb8b3a46fe6e0e384e95b8b0bb8bd8a..f13a0f540df44ef25e3d05fa74130ba2807f02d9 100644 (file)
@@ -28,9 +28,9 @@ foo::BAZ();
 --EXPECT--
 nonstatic
 unicode(6) "fOoBaR"
-nonstatic
+static
 unicode(6) "foOBAr"
-nonstatic
+static
 unicode(6) "fOOBAr"
 static
 unicode(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 9d49c8407e6d41bd004b42ffa0cbaba035894958..c97ec4f183025d9f62da0ee32a4462c424b48397 100644 (file)
@@ -962,13 +962,13 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_uc
        if (!fbc && zend_u_hash_find(&ce->function_table, type, lc_function_name, function_name_strlen + 1, (void **) &fbc)==FAILURE) {
                efree(lc_function_name.v);
 
-               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;
                }