dmitry Thu Jul 26 08:32:52 2007 UTC
Added files:
/ZendEngine2/tests ns_022.inc ns_025.phpt ns_026.phpt ns_027.inc
ns_027.phpt ns_028.inc ns_028.phpt ns_029.phpt
ns_030.phpt
Modified files:
/ZendEngine2 zend_compile.c
/ZendEngine2/tests ns_022.phpt
Log:
Disabling declaration of class which name conflicts with import.
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.756&r2=1.757&diff_format=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.756 ZendEngine2/zend_compile.c:1.757
--- ZendEngine2/zend_compile.c:1.756 Sat Jul 21 05:27:06 2007
+++ ZendEngine2/zend_compile.c Thu Jul 26 08:32:51 2007
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.756 2007/07/21 05:27:06 pollita Exp $ */
+/* $Id: zend_compile.c,v 1.757 2007/07/26 08:32:51 dmitry Exp $ */
#include <zend_language_parser.h>
#include "zend.h"
@@ -3110,6 +3110,11 @@
zend_error(E_COMPILE_ERROR, "Cannot use '%R' as class name as
it is reserved", Z_TYPE(class_name->u.constant),
Z_UNIVAL(class_name->u.constant));
}
+ if (CG(current_import) &&
+ zend_u_hash_exists(CG(current_import),
Z_TYPE(class_name->u.constant), lcname, lcname_len+1)) {
+ zend_error(E_COMPILE_ERROR, "Class name '%R' coflicts with
import name", Z_TYPE(class_name->u.constant), Z_UNIVAL(class_name->u.constant));
+ }
+
if (CG(current_namespace)) {
znode tmp;
@@ -4945,6 +4950,10 @@
zend_error(E_COMPILE_ERROR, "Cannot use '%R' as import name",
Z_TYPE_P(name), Z_UNIVAL_P(name));
}
+ if (zend_u_hash_exists(CG(class_table), Z_TYPE_P(name), lcname,
lcname_len+1)) {
+ zend_error(E_COMPILE_ERROR, "Import name '%R' coflicts with
defined class", Z_TYPE_P(name), Z_UNIVAL_P(name));
+ }
+
if (zend_u_hash_add(CG(current_import), Z_TYPE_P(name), lcname,
lcname_len+1, &ns, sizeof(zval*), NULL) != SUCCESS) {
zend_error(E_COMPILE_ERROR, "Cannot reuse import name");
}
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/ns_022.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/ns_022.phpt
diff -u ZendEngine2/tests/ns_022.phpt:1.1 ZendEngine2/tests/ns_022.phpt:1.2
--- ZendEngine2/tests/ns_022.phpt:1.1 Thu Jul 12 09:23:48 2007
+++ ZendEngine2/tests/ns_022.phpt Thu Jul 26 08:32:52 2007
@@ -6,18 +6,14 @@
import a::b::c as test;
-class Test {
- static function foo() {
- echo __CLASS__,"::",__FUNCTION__,"\n";
- }
-}
+require "ns_022.inc";
function foo() {
echo __FUNCTION__,"\n";
}
test::foo();
-test::test::foo();
+::test::foo();
--EXPECT--
a::b::c::foo
-a::b::c::Test::foo
+Test::foo
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/ns_022.inc?view=markup&rev=1.1
Index: ZendEngine2/tests/ns_022.inc
+++ ZendEngine2/tests/ns_022.inc
<?php
class Test {
static function foo() {
echo __CLASS__,"::",__FUNCTION__,"\n";
}
}
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/ns_025.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/ns_025.phpt
+++ ZendEngine2/tests/ns_025.phpt
--TEST--
025: Name ambiguity (class name & part of namespace name)
--FILE--
<?php
namespace Foo::Bar;
class Foo {
function __construct() {
echo __CLASS__,"\n";
}
static function Bar() {
echo __CLASS__,"\n";
}
}
$x = new Foo;
Foo::Bar();
$x = new Foo::Bar::Foo;
Foo::Bar::Foo::Bar();
--EXPECT--
Foo::Bar::Foo
Foo::Bar::Foo
Foo::Bar::Foo
Foo::Bar::Foo
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/ns_026.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/ns_026.phpt
+++ ZendEngine2/tests/ns_026.phpt
--TEST--
026: Name ambiguity (class name & namespace name)
--FILE--
<?php
namespace Foo;
class Foo {
function __construct() {
echo "Method - ".__CLASS__."::".__FUNCTION__."\n";
}
static function Bar() {
echo "Method - ".__CLASS__."::".__FUNCTION__."\n";
}
}
function Bar() {
echo "Func - ".__FUNCTION__."\n";
}
$x = new Foo;
Foo::Bar();
$x = new Foo::Foo;
Foo::Foo::Bar();
::Foo::Bar();
--EXPECT--
Method - Foo::Foo::__construct
Method - Foo::Foo::Bar
Method - Foo::Foo::__construct
Method - Foo::Foo::Bar
Func - Foo::Bar
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/ns_027.inc?view=markup&rev=1.1
Index: ZendEngine2/tests/ns_027.inc
+++ ZendEngine2/tests/ns_027.inc
<?php
namespace Foo::Bar;
class Foo {
function __construct() {
echo __CLASS__,"\n";
}
static function Bar() {
echo __CLASS__,"\n";
}
}
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/ns_027.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/ns_027.phpt
+++ ZendEngine2/tests/ns_027.phpt
--TEST--
027: Name ambiguity (class name & part of extertnal namespace name)
--FILE--
<?php
require "ns_027.inc";
class Foo {
function __construct() {
echo __CLASS__,"\n";
}
static function Bar() {
echo __CLASS__,"\n";
}
}
$x = new Foo;
Foo::Bar();
$x = new Foo::Bar::Foo;
Foo::Bar::Foo::Bar();
--EXPECT--
Foo
Foo
Foo::Bar::Foo
Foo::Bar::Foo
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/ns_028.inc?view=markup&rev=1.1
Index: ZendEngine2/tests/ns_028.inc
+++ ZendEngine2/tests/ns_028.inc
<?php
namespace Foo;
class Foo {
function __construct() {
echo "Method - ".__CLASS__."::".__FUNCTION__."\n";
}
static function Bar() {
echo "Method - ".__CLASS__."::".__FUNCTION__."\n";
}
}
function Bar() {
echo "Func - ".__FUNCTION__."\n";
}
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/ns_028.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/ns_028.phpt
+++ ZendEngine2/tests/ns_028.phpt
--TEST--
028: Name ambiguity (class name & external namespace name)
--FILE--
<?php
require "ns_028.inc";
class Foo {
function __construct() {
echo "Method - ".__CLASS__."::".__FUNCTION__."\n";
}
static function Bar() {
echo "Method - ".__CLASS__."::".__FUNCTION__."\n";
}
}
$x = new Foo;
Foo::Bar();
$x = new Foo::Foo;
Foo::Foo::Bar();
::Foo::Bar();
--EXPECT--
Method - Foo::__construct
Func - Foo::Bar
Method - Foo::Foo::__construct
Method - Foo::Foo::Bar
Func - Foo::Bar
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/ns_029.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/ns_029.phpt
+++ ZendEngine2/tests/ns_029.phpt
--TEST--
029: Name ambiguity (class name & import name)
--FILE--
<?php
import A::B as Foo;
class Foo {
}
new Foo();
--EXPECTF--
Fatal error: Class name 'Foo' coflicts with import name in %sns_029.php on line
4
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/ns_030.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/ns_030.phpt
+++ ZendEngine2/tests/ns_030.phpt
--TEST--
030: Name ambiguity (import name & class name)
--FILE--
<?php
class Foo {
}
import A::B as Foo;
new Foo();
--EXPECTF--
Fatal error: Import name 'Foo' coflicts with defined class in %sns_030.php on
line 5
--
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
|