svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/Zend/tests/bug54624.phpt branches/PHP_5_3/Zend/zend_compile.c
branches/PHP_5_4/Zend/tests/bug54624.phpt branches/PHP_5_4/Zend/zend_compile.c trunk/Zend/tests/bug54624.phpt trunk/Zend/zend_compile.c
| From: | Felipe Pena | Date: | Sun, 12 Jun 2011 21:10:31 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/Zend/tests/bug54624.phpt branches/PHP_5_3/Zend/zend_compile.c branches/PHP_5_4/Zend/tests/bug54624.phpt branches/PHP_5_4/Zend/zend_compile.c trunk/Zend/tests/bug54624.phpt trunk/Zend/zend_compile.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-65214@lists.php.net to get a copy of this message | ||
felipe Sun, 12 Jun 2011 21:10:31 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=312112
Log:
- Fixed bug #54624 (class_alias and type hint)
Bug: http://bugs.php.net/54624 (Open) class_alias and type
hint (II.)
Changed paths:
U php/php-src/branches/PHP_5_3/NEWS
A php/php-src/branches/PHP_5_3/Zend/tests/bug54624.phpt
U php/php-src/branches/PHP_5_3/Zend/zend_compile.c
A php/php-src/branches/PHP_5_4/Zend/tests/bug54624.phpt
U php/php-src/branches/PHP_5_4/Zend/zend_compile.c
A php/php-src/trunk/Zend/tests/bug54624.phpt
U php/php-src/trunk/Zend/zend_compile.c
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2011-06-12 21:05:16 UTC (rev 312111)
+++ php/php-src/branches/PHP_5_3/NEWS 2011-06-12 21:10:31 UTC (rev 312112)
@@ -11,6 +11,7 @@
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)
Added: php/php-src/branches/PHP_5_3/Zend/tests/bug54624.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/tests/bug54624.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/Zend/tests/bug54624.phpt 2011-06-12 21:10:31 UTC (rev 312112)
@@ -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
Modified: php/php-src/branches/PHP_5_3/Zend/zend_compile.c
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/zend_compile.c 2011-06-12 21:05:16 UTC (rev 312111)
+++ php/php-src/branches/PHP_5_3/Zend/zend_compile.c 2011-06-12 21:10:31 UTC (rev 312112)
@@ -2572,11 +2572,23 @@
&& 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) {
Added: php/php-src/branches/PHP_5_4/Zend/tests/bug54624.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/tests/bug54624.phpt (rev 0)
+++ php/php-src/branches/PHP_5_4/Zend/tests/bug54624.phpt 2011-06-12 21:10:31 UTC (rev 312112)
@@ -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
Modified: php/php-src/branches/PHP_5_4/Zend/zend_compile.c
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/zend_compile.c 2011-06-12 21:05:16 UTC (rev 312111)
+++ php/php-src/branches/PHP_5_4/Zend/zend_compile.c 2011-06-12 21:10:31 UTC (rev 312112)
@@ -2918,11 +2918,23 @@
&& 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 ||
+ 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) {
- return 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].type_hint != proto->common.arg_info[i].type_hint) {
Added: php/php-src/trunk/Zend/tests/bug54624.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/bug54624.phpt (rev 0)
+++ php/php-src/trunk/Zend/tests/bug54624.phpt 2011-06-12 21:10:31 UTC (rev 312112)
@@ -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
Modified: php/php-src/trunk/Zend/zend_compile.c
===================================================================
--- php/php-src/trunk/Zend/zend_compile.c 2011-06-12 21:05:16 UTC (rev 312111)
+++ php/php-src/trunk/Zend/zend_compile.c 2011-06-12 21:10:31 UTC (rev 312112)
@@ -2918,11 +2918,23 @@
&& 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 ||
+ 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) {
- return 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].type_hint != proto->common.arg_info[i].type_hint) {