PHP PHP.net news server web interface
From: Date: Fri Jun 20 13:17:19 2008
Subject: cvs: ZendEngine2 / zend_compile.c /tests ns_066.phpt ns_067.inc ns_067.phpt
Groups: php.zend-engine.cvs 
dmitry		Fri Jun 20 17:17:19 2008 UTC

  Modified files:              
    /ZendEngine2	zend_compile.c 
    /ZendEngine2/tests	ns_066.phpt ns_067.inc ns_067.phpt 
  Log:
  Allowed to override internal classaes with "use"
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.826&r2=1.827&diff_format=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.826 ZendEngine2/zend_compile.c:1.827
--- ZendEngine2/zend_compile.c:1.826	Tue Jun  3 19:01:25 2008
+++ ZendEngine2/zend_compile.c	Fri Jun 20 17:17:18 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_compile.c,v 1.826 2008/06/03 19:01:25 felipe Exp $ */
+/* $Id: zend_compile.c,v 1.827 2008/06/20 17:17:18 dmitry Exp $ */
 
 #include <zend_language_parser.h>
 #include "zend.h"
@@ -5391,6 +5391,7 @@
 	zstr lcname;
 	zval *name, *ns, tmp;
 	zend_bool warn = 0;
+	zend_class_entry **pce;
 
 	if (!CG(current_import)) {
 		CG(current_import) = emalloc(sizeof(HashTable));
@@ -5462,7 +5463,9 @@
 			efree(tmp.v);
 		}
 		efree(ns_name.v);
-	} else if (zend_u_hash_exists(CG(class_table), Z_TYPE_P(name), lcname, lcname_len+1)) {
+	} else if (zend_u_hash_find(CG(class_table), Z_TYPE_P(name), lcname, lcname_len+1, (void**)&pce) == SUCCESS &&
+	           (*pce)->type == ZEND_USER_CLASS &&
+	           (*pce)->filename == CG(compiled_filename)) {
 		unsigned int tmp_len;		
 		zstr tmp = zend_u_str_case_fold(Z_TYPE_P(ns), Z_UNIVAL_P(ns), Z_UNILEN_P(ns), 0, &tmp_len);
 
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/ns_066.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/ns_066.phpt
diff -u /dev/null ZendEngine2/tests/ns_066.phpt:1.2
--- /dev/null	Fri Jun 20 17:17:19 2008
+++ ZendEngine2/tests/ns_066.phpt	Fri Jun 20 17:17:19 2008
@@ -0,0 +1,10 @@
+--TEST--
+066: Name ambiguity (import name & internal class name)
+--FILE--
+<?php
+include __DIR__ . '/ns_027.inc';
+use Foo::Bar::Foo as stdClass;
+
+new stdClass();
+--EXPECT--
+Foo::Bar::Foo
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/ns_067.inc?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/ns_067.inc
diff -u /dev/null ZendEngine2/tests/ns_067.inc:1.2
--- /dev/null	Fri Jun 20 17:17:19 2008
+++ ZendEngine2/tests/ns_067.inc	Fri Jun 20 17:17:19 2008
@@ -0,0 +1,3 @@
+<?php
+use Foo::Bar::Foo as Test;
+new Test();
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/ns_067.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/ns_067.phpt
diff -u /dev/null ZendEngine2/tests/ns_067.phpt:1.2
--- /dev/null	Fri Jun 20 17:17:19 2008
+++ ZendEngine2/tests/ns_067.phpt	Fri Jun 20 17:17:19 2008
@@ -0,0 +1,9 @@
+--TEST--
+067: Name ambiguity (import name & internal class name)
+--FILE--
+<?php
+include __DIR__ . '/ns_022.inc';
+include __DIR__ . '/ns_027.inc';
+include __DIR__ . '/ns_067.inc';
+--EXPECT--
+Foo::Bar::Foo


   
php.zend-engine.cvs (#6809)

Written by Jim Winstead. no rights reserved. (source code)