#46226 [NEW]: Create new namespace __autoload-type function
| From: | phpbugs at sevenlight dot com | Date: | Fri, 03 Oct 2008 15:35:01 +0000 |
| Subject: | #46226 [NEW]: Create new namespace __autoload-type function | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-129443@lists.php.net to get a copy of this message | ||
From: phpbugs at sevenlight dot com
Operating system: OSX 10.5.5
PHP version: 5.3.0alpha2
PHP Bug Type: Feature/Change Request
Bug description: Create new namespace __autoload-type function
Description:
------------
I suggest adding a new function called __import() or __use() or something
similar to autoload namespaces when they are used() but undefined.
Reproduce code:
---------------
core.php
<?php
function __import($sNamespace)
{
// sample code to load namespace dynamically
echo "Auto-Importing $sNamespace\n";
require_once '/path/to/folder/' . join('/', explode('::',
$sNamespace)
. '.php';
}
?>
some_other_file.php
<?php
namespace MyNamespace;
use Library::DB::Connector;
use Library::Other::Stuff;
?>
Expected result:
----------------
Auto-Importing Library::DB::Connector
Auto-Importing Library::Other::Stuff
--
Edit bug report at http://bugs.php.net/?id=46226&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46226&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46226&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46226&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=46226&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=46226&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=46226&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=46226&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=46226&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=46226&r=support
Expected behavior: http://bugs.php.net/fix.php?id=46226&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=46226&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=46226&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=46226&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46226&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46226&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=46226&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=46226&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=46226&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=46226&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=46226&r=mysqlcfg