Commit:    4a6291508d69fab951562b996ed7223c052a0168
Author:    Dmitry Stogov <dmi...@zend.com>         Tue, 19 Mar 2013 14:56:53 
+0400
Parents:   87c8ea15f29cd89e8a58d2f6dce4348453c6ac59
Branches:  PHP-5.3 PHP-5.4 PHP-5.5 master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=4a6291508d69fab951562b996ed7223c052a0168

Log:
Fixed bug #62343 (Show class_alias In get_declared_classes())

Bugs:
https://bugs.php.net/62343

Changed paths:
  M  NEWS
  A  Zend/tests/bug62343.phpt
  M  Zend/zend_builtin_functions.c


Diff:
diff --git a/NEWS b/NEWS
index adf868f..c8c6f75 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ PHP                                                             
           NEWS
 - Core
   . Fixed bug #64370 (microtime(true) less than 
$_SERVER['REQUEST_TIME_FLOAT']).
     (Anatol)
+  . Fixed bug #62343 (Show class_alias In get_declared_classes()) (Dmitry)
 
 - PCRE:
   . Merged PCRE 8.32). (Anatol)
diff --git a/Zend/tests/bug62343.phpt b/Zend/tests/bug62343.phpt
new file mode 100644
index 0000000..b0208c4
--- /dev/null
+++ b/Zend/tests/bug62343.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #62343 (Show class_alias In get_declared_classes())
+--FILE--
+<?php
+class a { }
+class_alias("a", "b");
+$c = get_declared_classes();
+var_dump(end($c));
+var_dump(prev($c));
+?>
+--EXPECT--
+string(1) "b"
+string(1) "a"
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 06f1462..c60cff5 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -1541,6 +1541,13 @@ ZEND_FUNCTION(restore_exception_handler)
 }
 /* }}} */
 
+static int same_name(const char *key, const char *name, zend_uint name_len)
+{
+       char *lcname = zend_str_tolower_dup(name, name_len);
+       int ret = memcmp(lcname, key, name_len) == 0;
+       efree(lcname);
+       return ret;
+}
 
 static int copy_class_or_interface_name(zend_class_entry **pce TSRMLS_DC, int 
num_args, va_list args, zend_hash_key *hash_key)
 {
@@ -1552,7 +1559,13 @@ static int copy_class_or_interface_name(zend_class_entry 
**pce TSRMLS_DC, int nu
 
        if ((hash_key->nKeyLength==0 || hash_key->arKey[0]!=0)
                && (comply_mask == (ce->ce_flags & mask))) {
-               add_next_index_stringl(array, ce->name, ce->name_length, 1);
+               if (ce->refcount > 1 && 
+                   (ce->name_length != hash_key->nKeyLength - 1 || 
+                    !same_name(hash_key->arKey, ce->name, ce->name_length))) {
+                       add_next_index_stringl(array, hash_key->arKey, 
hash_key->nKeyLength - 1, 1);
+               } else {
+                       add_next_index_stringl(array, ce->name, 
ce->name_length, 1);
+               }
        }
        return ZEND_HASH_APPLY_KEEP;
 }


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

Reply via email to