]> granicus.if.org Git - php/commitdiff
- Fixed bug #54624 (class_alias and type hint)
authorFelipe Pena <felipe@php.net>
Sun, 12 Jun 2011 21:10:31 +0000 (21:10 +0000)
committerFelipe Pena <felipe@php.net>
Sun, 12 Jun 2011 21:10:31 +0000 (21:10 +0000)
NEWS
Zend/tests/bug54624.phpt [new file with mode: 0644]
Zend/zend_compile.c

diff --git a/NEWS b/NEWS
index d86221fc3014f9e08fbfc06ea9e3ffa5c5caa30f..f2173e44795a5a67e0b3a5cab30388aba219c1fe 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ PHP                                                                        NEWS
     name). (Dmitry)
   . Fixed bug #54804 (__halt_compiler and imported namespaces).
     (Pierrick, Felipe)
+  . Fixed bug #54624 (class_alias and type hint). (Felipe)
   . Fixed bug #54585 (track_errors causes segfault). (Dmitry)
   . Fixed bug #54423 (classes from dl()'ed extensions are not destroyed). 
     (Tony, Dmitry)
diff --git a/Zend/tests/bug54624.phpt b/Zend/tests/bug54624.phpt
new file mode 100644 (file)
index 0000000..1d0c1ce
--- /dev/null
@@ -0,0 +1,26 @@
+--TEST--
+Bug #54624 (class_alias and type hint)
+--FILE--
+<?php
+class A
+{
+       function foo(A $param) {
+       }
+
+}
+
+class_alias('A', 'AliasA');
+
+eval(' 
+       class B extends A
+       {
+               function foo(AliasA $param) {
+               }
+
+       }
+');
+
+echo "DONE\n";
+?>
+--EXPECTF--
+DONE
index 9b5166f9aec8ad6ddad80e23521227ff607c0573..85600f29eaa3b179ba691bbf0c4dc980385b95f4 100644 (file)
@@ -2572,11 +2572,23 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
                        && strcasecmp(fe->common.arg_info[i].class_name, proto->common.arg_info[i].class_name)!=0) {
                        char *colon;
 
-                       if (fe->common.type != ZEND_USER_FUNCTION ||
-                                       strchr(proto->common.arg_info[i].class_name, '\\') != NULL ||
-                                       (colon = zend_memrchr(fe->common.arg_info[i].class_name, '\\', fe->common.arg_info[i].class_name_len)) == NULL ||
-                                       strcasecmp(colon+1, proto->common.arg_info[i].class_name) != 0) {
+                       if (fe->common.type != ZEND_USER_FUNCTION) {
                                return 0;
+                       } else if (strchr(proto->common.arg_info[i].class_name, '\\') != NULL ||
+                           (colon = zend_memrchr(fe->common.arg_info[i].class_name, '\\', fe->common.arg_info[i].class_name_len)) == NULL ||
+                           strcasecmp(colon+1, proto->common.arg_info[i].class_name) != 0) {
+                               zend_class_entry **fe_ce, **proto_ce;
+                               TSRMLS_FETCH();
+                               int found = zend_lookup_class(fe->common.arg_info[i].class_name, fe->common.arg_info[i].class_name_len, &fe_ce TSRMLS_CC);
+                               int found2 = zend_lookup_class(proto->common.arg_info[i].class_name, proto->common.arg_info[i].class_name_len, &proto_ce TSRMLS_CC);
+                               
+                               /* Check for class alias */
+                               if (found != SUCCESS || found2 != SUCCESS ||
+                                       (*fe_ce)->type == ZEND_INTERNAL_CLASS ||
+                                       (*proto_ce)->type == ZEND_INTERNAL_CLASS ||
+                                       *fe_ce != *proto_ce) {
+                                       return 0;
+                               }
                        }
                }
                if (fe->common.arg_info[i].array_type_hint != proto->common.arg_info[i].array_type_hint) {