|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-04-02 02:50 UTC] kwutzke at web dot de
[2009-04-02 02:55 UTC] kwutzke at web dot de
[2009-04-03 19:40 UTC] johannes@php.net
[2011-01-28 16:10 UTC] iffzy at atomar dot de
[2013-08-17 10:14 UTC] worldoffame at hotmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 20 20:00:01 2025 UTC |
Description: ------------ When using namespaces you always have to put the exact 'use \ClassName' statement into the code. This list of dependencies can become quite large in some classes. To relieve programmers from having to manually put use statements to the top (or elsewhere) a namespace wildcard should be added to the language. Much like in Java, where in stead of writing import java.awt.Image; import javax.swing.JTextField; import javax.swing.JComboBox; import javax.swing.JSpinner; import javax.swing.JCheckBox; import javax.swing.JRadioButton; import javax.swing.JMenuItem; import javax.swing.JMenu; import javax.swing.JMenuBar; one could write import java.awt.*; import javax.swing.*; This saves a lot of time while writing the code. An IDE (plugin) might replace the wildcards with the actually used classes. Wrting use \*; seems natural to me. Don't know how much this RFE is possible language-wise. It would however make lots of sense for PHP 5.3. I'm not sure if this is the right place to ask for a language enhancement of this caliber. Reproduce code: --------------- <?php namespace whatever; //in dir whatever //use \*; <- why not??? //PHP standard classes use \Exception; //ZF classes use \Zend_Version; class ZfTools { public static function checkVersion($strRequiredVersion = '1.5.1') { switch ( Zend_Version::compareVersion($strRequiredVersion) ) { case -1: //required is older return true; case 0: //equal case 1: //newer return false; default: //should never be executed throw new Exception('Error comparing Zend Framework version!'); } } } ?> Expected result: ---------------- use \*; would compile so that Zend_Version and Exception can be used without leading backslashes. Actual result: -------------- use \*; Generates a parse error "Parse error: parse error, expecting `T_STRING' in C:\dev\apache\htdocs\whatever\ZfTools.php on line 5"