Ideally think I'd prefer it finer grained... interface A { }
class AImpl implements A { } register('A', function() { return new AImpl(); }); register('Foo', function() { return new Bar(); }); $foo = new Foo(); $a = new A(); Would also require functions being values... Which would also be nice. J > -----Original Message----- > From: news [mailto:[EMAIL PROTECTED] On Behalf Of Sebastian Bergmann > Sent: 02 October 2007 10:33 > To: internals@lists.php.net > Subject: [PHP-DEV] Class Posing > > From [1]: > > Objective-C permits a class to wholly replace another > class within a > program. The replacing class is said to "pose as" the target class. > All messages sent to the target class are then instead received by > the posing class. > > There are several restrictions on which classes can pose: > > * A class may only pose as one of its direct or indirect > superclasses. > > [The other restrictions do not apply to PHP] > > 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. > ?> > > We (Johannes, Marcus, Sara, and myself) then discussed where > to put this functionality. Outside of core, there were two > places that both make > sense: pecl/operator and pecl/runkit. > > 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. > > Opinions? Needless to say that I would love to see this in > PHP 5.3 ;-) > > -- > [1] http://en.wikipedia.org/wiki/Objective_C#Posing > > -- > Sebastian Bergmann > http://sebastian-bergmann.de/ > GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 > C514 B85B 5D69 > > -- > PHP Internals - PHP Runtime Development Mailing List To > unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php