stas                                     Sun, 04 Apr 2010 23:28:20 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=297482

Log:
change namespaced ctors - only __construct would work

Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/Zend/tests/ns_063.phpt
    U   php/php-src/branches/PHP_5_3/Zend/zend_compile.c
    U   php/php-src/trunk/Zend/tests/ns_063.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   2010-04-04 22:10:06 UTC (rev 297481)
+++ php/php-src/branches/PHP_5_3/NEWS   2010-04-04 23:28:20 UTC (rev 297482)
@@ -8,6 +8,9 @@
   mcrypt_filter). (Stas)
 - Added full_special_chars filter to ext/filter (Rasmus)

+- Changed namespaced classes so that the ctor can only be named
+  __construct now. (Stas)
+
 - Fixed a NULL pointer dereference when processing invalid XML-RPC
   requests (Fixes CVE-2010-0397, bug #51288). (Raphael Geissert)


Modified: php/php-src/branches/PHP_5_3/Zend/tests/ns_063.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/tests/ns_063.phpt 2010-04-04 22:10:06 UTC 
(rev 297481)
+++ php/php-src/branches/PHP_5_3/Zend/tests/ns_063.phpt 2010-04-04 23:28:20 UTC 
(rev 297482)
@@ -1,5 +1,5 @@
 --TEST--
-063: Support for old-style constructors in namesapces
+063: Old-style constructors in namesapces (not supported!)
 --FILE--
 <?php
 namespace Foo;
@@ -9,5 +9,6 @@
        }
 }
 new Bar();
+echo "ok\n";
 --EXPECT--
 ok

Modified: php/php-src/branches/PHP_5_3/Zend/zend_compile.c
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/zend_compile.c    2010-04-04 22:10:06 UTC 
(rev 297481)
+++ php/php-src/branches/PHP_5_3/Zend/zend_compile.c    2010-04-04 23:28:20 UTC 
(rev 297482)
@@ -1270,22 +1270,13 @@
                                }
                        }
                } else {
-                       char *short_class_name;
-                       int short_class_name_length;
-                       char *short_class_lcname;
-
-                       if ((short_class_name = 
zend_memrchr(CG(active_class_entry)->name, '\\', 
CG(active_class_entry)->name_length))) {
-                               short_class_name_length = 
CG(active_class_entry)->name_length - (short_class_name - 
CG(active_class_entry)->name) - 1;
-                               ++short_class_name;
-                       } else {
-                               short_class_name = CG(active_class_entry)->name;
-                               short_class_name_length = 
CG(active_class_entry)->name_length;
-                       }
-                       short_class_lcname = do_alloca(short_class_name_length 
+ 1, use_heap);
-                       zend_str_tolower_copy(short_class_lcname, 
short_class_name, short_class_name_length);
+                       char *class_lcname;
+
+                       class_lcname = 
do_alloca(CG(active_class_entry)->name_length + 1, use_heap);
+                       zend_str_tolower_copy(class_lcname, 
CG(active_class_entry)->name, CG(active_class_entry)->name_length);
                        /* Improve after RC: cache the lowercase class name */

-                       if ((short_class_name_length == name_len) && 
(!memcmp(short_class_lcname, lcname, name_len))) {
+                       if ((CG(active_class_entry)->name_length == name_len) 
&& (!memcmp(class_lcname, lcname, name_len))) {
                                if (CG(active_class_entry)->constructor) {
                                        zend_error(E_STRICT, "Redefining 
already defined constructor for class %s", CG(active_class_entry)->name);
                                } else {
@@ -1338,7 +1329,7 @@
                        } else if (!(fn_flags & ZEND_ACC_STATIC)) {
                                CG(active_op_array)->fn_flags |= 
ZEND_ACC_ALLOW_STATIC;
                        }
-                       free_alloca(short_class_lcname, use_heap);
+                       free_alloca(class_lcname, use_heap);
                }

                efree(lcname);

Modified: php/php-src/trunk/Zend/tests/ns_063.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/ns_063.phpt    2010-04-04 22:10:06 UTC (rev 
297481)
+++ php/php-src/trunk/Zend/tests/ns_063.phpt    2010-04-04 23:28:20 UTC (rev 
297482)
@@ -1,5 +1,5 @@
 --TEST--
-063: Support for old-style constructors in namesapces
+063: Old-style constructors in namesapces (not supported!)
 --FILE--
 <?php
 namespace Foo;
@@ -9,5 +9,6 @@
        }
 }
 new Bar();
+echo "ok\n";
 --EXPECT--
 ok

Modified: php/php-src/trunk/Zend/zend_compile.c
===================================================================
--- php/php-src/trunk/Zend/zend_compile.c       2010-04-04 22:10:06 UTC (rev 
297481)
+++ php/php-src/trunk/Zend/zend_compile.c       2010-04-04 23:28:20 UTC (rev 
297482)
@@ -1270,22 +1270,13 @@
                                }
                        }
                } else {
-                       char *short_class_name;
-                       int short_class_name_length;
-                       char *short_class_lcname;
-
-                       if ((short_class_name = 
zend_memrchr(CG(active_class_entry)->name, '\\', 
CG(active_class_entry)->name_length))) {
-                               short_class_name_length = 
CG(active_class_entry)->name_length - (short_class_name - 
CG(active_class_entry)->name) - 1;
-                               ++short_class_name;
-                       } else {
-                               short_class_name = CG(active_class_entry)->name;
-                               short_class_name_length = 
CG(active_class_entry)->name_length;
-                       }
-                       short_class_lcname = do_alloca(short_class_name_length 
+ 1, use_heap);
-                       zend_str_tolower_copy(short_class_lcname, 
short_class_name, short_class_name_length);
+                       char *class_lcname;
+
+                       class_lcname = 
do_alloca(CG(active_class_entry)->name_length + 1, use_heap);
+                       zend_str_tolower_copy(class_lcname, 
CG(active_class_entry)->name, CG(active_class_entry)->name_length);
                        /* Improve after RC: cache the lowercase class name */

-                       if ((short_class_name_length == name_len) && 
(!memcmp(short_class_lcname, lcname, name_len))) {
+                       if ((CG(active_class_entry)->name_length == name_len) 
&& (!memcmp(class_lcname, lcname, name_len))) {
                                if (CG(active_class_entry)->constructor) {
                                        zend_error(E_STRICT, "Redefining 
already defined constructor for class %s", CG(active_class_entry)->name);
                                } else {
@@ -1338,7 +1329,7 @@
                        } else if (!(fn_flags & ZEND_ACC_STATIC)) {
                                CG(active_op_array)->fn_flags |= 
ZEND_ACC_ALLOW_STATIC;
                        }
-                       free_alloca(short_class_lcname, use_heap);
+                       free_alloca(class_lcname, use_heap);
                }

                efree(lcname);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to