From:             kenaniah at gmail dot com
Operating system: 
PHP version:      5.2.4
PHP Bug Type:     Feature/Change Request
Bug description:  Dynamic and multiple object inheritance (and no, this isn't 
heresy)

Description:
------------
To implement this would require a definite change in the way PHP handles
objects, but it would be an excellent addition to the language if we were
able to modify the inheritances of an object after its initialization.

For example:

In an MVC framework, an object named 'User' is manipulated in the Model,
and needs to be saved to the database. Instead of extending 'User' from an
Active Record Database Object class, one could extend the instantiated
'User' object to include the Active Record Class, perform the database
queries, and then "disinherit" the class before passing control on to the
View, eliminating the ability to make use of the Active Record class'
features from within the View. 

Proposed functions:
extend ( object $object, string $class ) -- dynamically extends $object
from $class  
unextend ( object $object, string $class ) -- removes $class from object
(no longer a parent to $object)
adopt ( object $object, string $class ) -- $class is added to $object as
an extension
unadopt ( object $object, string $class ) -- removes $class from $object
(no longer a child within $object)


Reproduce code:
---------------
class User{
...
}
class ActiveRecord{
...
}

$user = new User;
$user->name = "New Name";
extend($user, "ActiveRecord"); //$user is now extended from ActiveRecord
$user->save(); //a function from ActiveRecord class
unextend($user, "ActiveRecord"); //ActiveRecord is completely removed from
$user


-- 
Edit bug report at http://bugs.php.net/?id=42536&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42536&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42536&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42536&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42536&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42536&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42536&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42536&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42536&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42536&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42536&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42536&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42536&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42536&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42536&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42536&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42536&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42536&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42536&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42536&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42536&r=mysqlcfg

Reply via email to