__call for the namespaces
| From: | Brad LaFountain | Date: | Mon, 17 Mar 2003 13:42:37 +0000 |
| Subject: | __call for the namespaces | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-95192@lists.php.net to get a copy of this message | ||
This idea spawned from playing with ext/rpc and the ability to declare
class types on the fly....
Since zend_namespaces is really _zend_class_entry I think it would
be cool to implement __call at the namespace level.
namespace java {
function __call($classname) {
// this will be called every time a new java::$classname() is called
// and $classname isn't defined
eval("
class $classname {
}
");
// and it can return the new class
return new $classname();
}
}
This doesn't seem like it would be too hard to implement and it will allow me
to do stuff like...
<?
$j = new java::java.util.Stack();
// $j could be of ns java:util and class Stack
$s = new soap::myObject("http://server/some.wsdl");
// $s could be the namespace defined in the wsdl and of class myObject
?>
ps:
<?
namespace test {
class test1 {
function doSomething() {
eval("
class test2 { }
");
}
}
}
$test1 = new test::test1();
$test1->doSomething();
?>
results in...
<b>Fatal error</b>: Internal Zend error - Missing class information for in
<b>
c:\php\php5\Release_TSDbg\name.php(7) : eval()'d code</b> on line
<b>2</b><br
/>
- Brad
__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
http://webhosting.yahoo.com