From:             kwutzke at web dot de
Operating system: all
PHP version:      5.3.0RC1
PHP Bug Type:     Feature/Change Request
Bug description:  PHP 5.3+ support for namespace wildcards (use statement)

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 bug report at http://bugs.php.net/?id=47872&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=47872&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=47872&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=47872&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=47872&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=47872&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=47872&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=47872&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=47872&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=47872&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=47872&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=47872&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=47872&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=47872&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=47872&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=47872&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=47872&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=47872&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=47872&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=47872&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=47872&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=47872&r=mysqlcfg

Reply via email to