1 | <?php |
||
28 | abstract class BaseMongoBlameableModel extends BaseMongoEntityModel |
||
29 | { |
||
30 | use BlameableTrait; |
||
31 | |||
32 | /** |
||
33 | * Initialize the blameable model. |
||
34 | * If query class is not specified, [[BaseMongoBlameableQuery]] will be taken. |
||
35 | */ |
||
36 | 12 | public function init() |
|
47 | |||
48 | /** |
||
49 | * Get the query class with specified identity. |
||
50 | * @param BaseUserModel $identity |
||
51 | * @return BaseMongoBlameableQuery |
||
52 | */ |
||
53 | 3 | public static function findByIdentity($identity = null) |
|
57 | |||
58 | /** |
||
59 | * Because every document has a `MongoId" class, this class no longer needs GUID feature. |
||
60 | * @var boolean determines whether enable the GUID features. |
||
61 | */ |
||
62 | public $guidAttribute = false; |
||
63 | public $idAttribute = '_id'; |
||
64 | |||
65 | /** |
||
66 | * @inheritdoc |
||
67 | * You can override this method if enabled fields cannot meet your requirements. |
||
68 | * @return array |
||
69 | */ |
||
70 | 12 | public function attributes() |
|
74 | |||
75 | /** |
||
76 | * Get blame who owned this blameable model. |
||
77 | * NOTICE! This method will not check whether `$userClass` exists. You should |
||
78 | * specify it in `init()` method. |
||
79 | * @return BaseUserQuery user. |
||
80 | */ |
||
81 | public function getHost() |
||
88 | |||
89 | public function getCreatedByAttribute() |
||
94 | |||
95 | /** |
||
96 | * |
||
97 | * @param IdentityInterface $host |
||
98 | * @return boolean |
||
99 | */ |
||
100 | 12 | public function setHost($host) |
|
113 | |||
114 | /** |
||
115 | * Get updater who updated this blameable model recently. |
||
116 | * NOTICE! This method will not check whether `$userClass` exists. You should |
||
117 | * specify it in `init()` method. |
||
118 | * @return BaseUserQuery user. |
||
119 | */ |
||
120 | public function getUpdater() |
||
130 | |||
131 | public function getUpdatedByAttribute() |
||
136 | |||
137 | /** |
||
138 | * |
||
139 | * @param IdentityInterface $user |
||
140 | * @return boolean |
||
141 | */ |
||
142 | public function setUpdater($updater) |
||
158 | |||
159 | /** |
||
160 | * Return the current user's GUID if current model doesn't specify the owner |
||
161 | * yet, or return the owner's GUID if current model has been specified. |
||
162 | * This method is ONLY used for being triggered by event. DO NOT call, |
||
163 | * override or modify it directly, unless you know the consequences. |
||
164 | * @param ModelEvent $event |
||
165 | * @return string the GUID of current user or the owner. |
||
166 | */ |
||
167 | 12 | public function onGetCurrentUserGuid($event) |
|
180 | } |
||
181 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.