php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #50552 Add function to get all used namespaces
Submitted: 2009-12-22 02:53 UTC Modified: 2021-12-05 04:22 UTC
Votes:7
Avg. Score:3.6 ± 1.8
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:2 (40.0%)
From: kristopherwilson at gmail dot com Assigned: cmb (profile)
Status: No Feedback Package: Scripting Engine problem
PHP Version: * OS: *
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: kristopherwilson at gmail dot com
New email:
PHP Version: OS:

 

 [2009-12-22 02:53 UTC] kristopherwilson at gmail dot com
Description:
------------
Provide a function for returning all namespaces used in the current request to aid in autoloading. 

Reproduce code:
---------------
<?php
    use My\Namespace;
    use Other\Namespace;

    print_r(get_used_namespaces());
?>

Expected result:
----------------
Array(
    [0] = My\Namespace,
    [1] = Other\Namespace
)

Actual result:
--------------
No such function exists.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-24 09:50 UTC] jani@php.net
-Package: Feature/Change Request +Package: Scripting Engine problem -Operating System: Any +Operating System: * -PHP Version: 5.3.1 +PHP Version: *
 [2021-11-23 11:24 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-11-23 11:24 UTC] cmb@php.net
Namespace imports are a compile time concept only; during runtime
PHP has no general notion of these, only of the fully qualified
names of individual classes, functions, etc.  As such,
implementing this feature would require quite some changes,
possibly having detrimental effects on the engine, and the details
are sufficiently unclear, so this would require the RFC
process[1].

However, I wonder what would be the use-case at all.  How could
that be useful "to aid in autoloading"?

[1] <https://wiki.php.net/rfc/howto>
 [2021-12-05 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC