|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62343 Show class_alias In get_declared_classes( )
Submitted: 2012-06-17 16:22 UTC Modified: 2013-03-19 11:01 UTC
From: valentiny510 at yahoo dot es Assigned: dmitry
Status: Closed Package: Class/Object related
PHP Version: 5.4.4 OS: XP
Private report: No CVE-ID:
 [2012-06-17 16:22 UTC] valentiny510 at yahoo dot es
Maybe the name of the function get_"declared"_classes is to obvious..
to show only the "declared" classes and not the referenced one but if it true
do not duplicate them, or show the name of the alias

Test script:
class a { }
class_alias(a, b);

print_r(get_declared_classes( ));

Expected result:
    [0] => a
    [1] => b

Actual result:
    [0] => a
    [1] => a


bug62343.phpt (last revision 2012-06-22 09:29 UTC) by
bug62343.patch (last revision 2012-06-22 09:28 UTC) by

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-18 01:01 UTC] valentiny510 at yahoo dot es
P.S. Also will be nice to add an argument to various functions like get_declared_classes( $user_classes = true/false )
get_declared_interfaces( $user_interfaces = true/false )
 and show ONLY the "user declared" classes not the full list ..
 [2012-06-22 09:28 UTC]
The following patch has been added/updated:

Patch Name: bug62343.patch
Revision:   1340357325
 [2012-06-22 09:29 UTC]
The following patch has been added/updated:

Patch Name: bug62343.phpt
Revision:   1340357369
 [2012-06-22 09:31 UTC]
-Assigned To: +Assigned To: dmitry
 [2012-06-22 09:31 UTC]
Dmitry, could you please review this patch? there is one thing I am not sure is, 
there was a :

if ((hash_key->nKeyLength==0 || hash_key->arKey[0]!=0)

I am not sure about the first condition, IMO the key should not be a number in 
CG/EG(class_table),  so I remove that condition,  did I miss something?

 [2012-06-22 09:33 UTC]
Aliases are not declared classes but ... aliases :) 

I don't think it should be shown through that.

However, using an optional argument, it could then return:

    ['a'] => NULL
    ['b'] => 'a'

for example.
 [2012-06-22 09:33 UTC]
-Status: Assigned +Status: Open
 [2012-06-22 09:37 UTC]
Also bring that on internals please. There are room for discussions here.
 [2012-06-22 16:25 UTC]
okey, thanks :)
 [2012-06-25 08:00 UTC]
I would say the patch is bad, because all the returned class names will be lowercased. However, it's possible to improve the patch by comparison of lowercasesd ce->name and hash_key->arKey. In case they are equal we can return ce->name and hash_key->arKey otherwise.

I would also prefer not to extend functionality of internal functions without a big reason (user_only argument).
 [2012-08-25 13:07 UTC] valentiny510 at yahoo dot es
pajoye said: "Aliases are not declared classes but ... aliases :)"

With this comment I must understand that if the aliases are not declared classes, that aliases must NOT be included in the get_declared_classes( ) also ..
right ? .. see u smiling :D
 [2012-08-25 13:24 UTC] valentiny510 at yahoo dot es
P.S. I think the "easyest" solucion can be to create a new function like "get_aliases( )" and assign all the aliases references to that function
and this way we can know for sure what names from the array are aliases
 [2013-03-19 11:01 UTC]
-Status: Assigned +Status: Closed
 [2013-03-19 11:01 UTC]
Automatic comment on behalf of
Log: Fixed bug #62343 (Show class_alias In get_declared_classes())
 [2013-03-19 11:01 UTC]
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 23 07:02:14 2014 UTC