ID: 47872 User updated by: kwutzke at web dot de Reported By: kwutzke at web dot de Status: Open Bug Type: Feature/Change Request Operating System: all PHP Version: 5.3.0RC1 New Comment:
Other examples of use wildcards are: use \namespace2\*; use \otherns\*; use \myown\sub\*; use \myown\sub\subsub\*; Previous Comments: ------------------------------------------------------------------------ [2009-04-02 02:44:11] kwutzke at web dot de 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" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47872&edit=1