# Fwd:  __call for the namespaces

- Thread: https://externals.io/message/112
- Original archive: https://news-web.php.net/php.internals/112
- Started by Brad LaFountain on 2003-03-19T20:34:12+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #112 — Brad LaFountain — 2003-03-19T20:34:12+00:00

URL: https://externals.io/message/112#112

--- Brad LaFountain <rodif_bl@yahoo.com> wrote:
> Date: Mon, 17 Mar 2003 05:42:37 -0800 (PST)
> From: Brad LaFountain <rodif_bl@yahoo.com>
> To: php-dev@lists.php.net
> Subject: [PHP-DEV] __call for the namespaces
> 
> 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
> 
> -- 
> PHP Development Mailing List <http://www.php.net/>
> 
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com
