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
Posted by Adam Lundrigan (adamlundrigan) on 2011-06-29T15:04:42.000+0000
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'?
Posted by Dolf Schimmel (Freeaqingme) (freak) on 2011-07-03T13:08:15.000+0000
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.
Posted by Pádraic Brady (padraic) on 2011-08-13T19:57:02.000+0000
Updated affected versions and switched to an improvement issue
Posted by Adam Lundrigan (adamlundrigan) on 2011-10-04T22:27:40.000+0000
Attached patch contains a prototype implementation of the agreed-upon solution. Comments?
Posted by Adam Lundrigan (adamlundrigan) on 2012-05-05T02:59:15.000+0000
Fixed in trunk (1.12.0): r24759 Fixed in release-1.11 (1.11.12): r24760