PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB_DataObject » Bug #6841

factory() shuld by static

Details

Submitted2006-02-20 09:13 UTC
Fromskr at condero dot com
StatusSuspended
PackageDB_DataObject
PHP Version5.0.4
OSLinux (Suse 9.3)
Roadmaps(Not assigned)

Comments

[2006-02-20 09:13 UTC] skr at condero dot com

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

[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