ZF-3745: If Zend_Mail_Part is extended it should return an instance of the new class

Description

Zend_Mail_Part currently creates instances wit 'new self(...)', which means even if it's extended it still uses Zend_Mail_Part, because of early binding. '$classname = get_class($this); new $classname(..)' can be used in PHP < 5.3 to avoid the problem.

Comments

One concern: The above suggestion will change the way {{Zend_Mail_Message}} works. It extends {{Zend_Mail_Part}}, and so with the above modification all parts accessed via a {{Zend_Mail_Message}} object will be returned as instances of {{Zend_Mail_Message}} and not {{Zend_Mail_Part}}. Probably not a big deal, but worth noting.

Might it be better to give {{Zend_Mail_Part}} something analogous to {{Zend_Db_Table}}'s {{get/setRowClass}} methods? ie: Allow specifying the part class through the constructor and/or setter method, with the default value being equivalent to 'self'?

For consistency a method as Adam suggested would indeed be appreciated. This will be fixed in ZF2 however, so unless a patch is supplied this won't be given priority.

Tnx.

Updated affected versions and switched to an improvement issue

Attached patch contains a prototype implementation of the agreed-upon solution. Comments?

Fixed in trunk (1.12.0): r24759 Fixed in release-1.11 (1.11.12): r24760