Changed usage of self to static to allow extendibility

code style section has been added here:
https://github.com/yiisoft/yii2/wiki/Core-framework-code-style#self-vs-static

verification code for properties:
https://gist.github.com/cebe/7566916
This commit is contained in:
Carsten Brandt 2013-11-20 18:36:05 +01:00
parent 3b0ffb51ca
commit 6aa0755eeb

View File

@ -26,14 +26,14 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface
public static function findIdentity($id) public static function findIdentity($id)
{ {
return isset(self::$users[$id]) ? new self(self::$users[$id]) : null; return isset(self::$users[$id]) ? new static(self::$users[$id]) : null;
} }
public static function findByUsername($username) public static function findByUsername($username)
{ {
foreach (self::$users as $user) { foreach (self::$users as $user) {
if (strcasecmp($user['username'], $username) === 0) { if (strcasecmp($user['username'], $username) === 0) {
return new self($user); return new static($user);
} }
} }
return null; return null;