|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-09-22 17:16 UTC] cmb@php.net
-Status: Open
+Status: Suspended
[2018-09-22 17:16 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 02:00:01 2025 UTC |
Description: ------------ It would be nice to important an entire namespace into global space, but only for a controlled section of code Test script: --------------- /* desktop.php */ <?php namespace desktop; class Window{...} class Icon{...} class Button{...} ?> /* index.php */ <?php require 'desktop.php'; global_function(); { use desktop; $window1=new Window(); $window2=new Window(); $button1=new Button(); } more_global_functions(); ?> Expected result: ---------------- Whilst in the codeblock the namespace is available as if it were global, but once outside it is no longer globally available. The global namespace should be unaffected afterwards Actual result: -------------- currently namespaces cannot be imported entirely under the justification that it will pollute the global namespace. I believe that if only done for controlled regions of code this can be avoided & code can be more cleanly written