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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2022 The PHP Group
All rights reserved.
Last updated: Mon Sep 26 13:05:56 2022 UTC