Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.11.5

Bug #6841 factory() shuld by static
Submitted: 2006-02-20 09:13 UTC
From: skr at condero dot com Assigned:
Status: Suspended Package: DB_DataObject (version 1.8.2)
PHP Version: 5.0.4 OS: Linux (Suse 9.3)
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 43 - 17 = ?

 
 [2006-02-20 09:13 UTC] skr at condero dot com (Sven Krzyzak)
Description: ------------ The method factory should by static. A Framework with professional ambitions should by follow good patterns of design. And returning of the instance as a reference instead of value is another idea. Test script: --------------- interface CompanyComponent { public static function factory(); public function __destruct(); } interface UserExtension extends CompanyComponent { ... } class AuthUserExtension extends DB_DataObject implements UserExtension { ... public static function factory($param) { $inst = parent :: factory($param); ... return $inst; } ... } AuthUserExtension :: factory("somthing"); Expected result: ---------------- an instance of UserExtension Actual result: -------------- Fatal error: Cannot make non static method DB_DataObject::factory() static in class AuthUserExtension in /home/skr/svn_work_copy/groups/trunk/classes/AuthUserExtension.php on line 5

Comments

 [2006-02-20 13:15 UTC] alan_k
It's not really feasible to fix this, as it would break all the existing PHP4 code that depends on it. I'm not sure you are going to loose much by leaving it not defined as static for PHP5 code, it's syntatic suger anyway... It's definatly one for DataObjects2
 [2007-04-27 13:12 UTC] skr at condero dot com
Welcome to PHP6 In PHP6 however, calling an instance method (not defined using `static`) as a class method (using `class::method()` ) will display an EWarning. Also note that in PHP6, calling a class method (defined using `static`) as an instance method (using `$instance->method()`) will ALSO display an EWarning