Earlier this year, Johannes implemented class posing for PHP as follows:

   <?php
   class Foo {}
   class Bar extends Foo {}

   function new_overload($className)
   {
       if ($className == 'Foo') {
           return new Bar;
       }

       // ...
   }

   $o = new Foo;
   // $o is an object of Foo.

   register_new_overload('new_overload');

   $o = new Foo;
   // $o is an object of Bar.
   ?>

This looks like factory pattern. What's wrong with implementing it as factory?

 However, to make this a viable mechanism that can be used in tools such
 as PHPUnit (for which I could really use this functionality), we agreed
 that it actually belongs into the core.

I personally don't see much of the use of it in the core, and it definitely adds very "magic" things - you don't know anymore what class you are instantiating when you run "new Foo". My opinion is it belongs to places like "runkit" which do tricks with the language, but I don't see much use for it in the core. Could you explain more why existing pattern won't work for the same?
--
Stanislav Malyshev, Zend Software Architect
[EMAIL PROTECTED]   http://www.zend.com/
(408)253-8829   MSN: [EMAIL PROTECTED]


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to