php.net |  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 (profile)
Status: Closed Package: Class/Object related
PHP Version: 5.4.4 OS: XP
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: valentiny510 at yahoo dot es
New email:
PHP Version: OS:

 

 [2012-06-17 16:22 UTC] valentiny510 at yahoo dot es
Description:
------------
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:
----------------
Array
(
    [0] => a
    [1] => b
)


Actual result:
--------------
Array
(
    [0] => a
    [1] => a
)


Patches

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

Pull Requests

History

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 )
etc...
 and show ONLY the "user declared" classes not the full list ..
 [2012-06-22 09:28 UTC] laruence@php.net
The following patch has been added/updated:

Patch Name: bug62343.patch
Revision:   1340357325
URL:        https://bugs.php.net/patch-display.php?bug=62343&patch=bug62343.patch&revision=1340357325
 [2012-06-22 09:29 UTC] laruence@php.net
The following patch has been added/updated:

Patch Name: bug62343.phpt
Revision:   1340357369
URL:        https://bugs.php.net/patch-display.php?bug=62343&patch=bug62343.phpt&revision=1340357369
 [2012-06-22 09:31 UTC] laruence@php.net
-Assigned To: +Assigned To: dmitry
 [2012-06-22 09:31 UTC] laruence@php.net
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?


thanks
 [2012-06-22 09:33 UTC] pajoye@php.net
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:

Array
(
    ['a'] => NULL
    ['b'] => 'a'
)

for example.
 [2012-06-22 09:33 UTC] pajoye@php.net
-Status: Assigned +Status: Open
 [2012-06-22 09:37 UTC] pajoye@php.net
Also bring that on internals please. There are room for discussions here.
 [2012-06-22 16:25 UTC] laruence@php.net
okey, thanks :)
 [2012-06-25 08:00 UTC] dmitry@php.net
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] dmitry@php.net
-Status: Assigned +Status: Closed
 [2013-03-19 11:01 UTC] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=4a6291508d69fab951562b996ed7223c052a0168
Log: Fixed bug #62343 (Show class_alias In get_declared_classes())
 [2013-03-19 11:01 UTC] dmitry@php.net
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
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2014-10-07 23:19 UTC] stas@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=4a6291508d69fab951562b996ed7223c052a0168
Log: Fixed bug #62343 (Show class_alias In get_declared_classes())
 [2014-10-07 23:30 UTC] stas@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=4a6291508d69fab951562b996ed7223c052a0168
Log: Fixed bug #62343 (Show class_alias In get_declared_classes())
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC