1 | <?php |
||
27 | trait TimestampTrait |
||
28 | { |
||
29 | |||
30 | /** |
||
31 | * @var string the attribute that will receive datetime value |
||
32 | * Set this property to false if you do not want to record the creation time. |
||
33 | */ |
||
34 | public $createdAtAttribute = 'create_time'; |
||
35 | |||
36 | /** |
||
37 | * @var string the attribute that will receive datetime value. |
||
38 | * Set this property to false if you do not want to record the update time. |
||
39 | */ |
||
40 | public $updatedAtAttribute = 'update_time'; |
||
41 | |||
42 | /** |
||
43 | * @var integer Determine the format of timestamp. |
||
44 | */ |
||
45 | public $timeFormat = 0; |
||
46 | public static $timeFormatDatetime = 0; |
||
47 | public static $timeFormatTimestamp = 1; |
||
48 | public static $initDatetime = '1970-01-01 00:00:00'; |
||
49 | public static $initTimestamp = 0; |
||
50 | |||
51 | /** |
||
52 | * Get the current date & time in format of "Y-m-d H:i:s" or timestamp. |
||
53 | * You can override this method to customize the return value. |
||
54 | * @param \yii\base\ModelEvent $event |
||
55 | * @return string Date & Time. |
||
56 | * @since 1.1 |
||
57 | */ |
||
58 | 44 | public static function getCurrentDatetime($event) |
|
63 | |||
64 | 44 | public function currentDatetime() |
|
73 | |||
74 | public function offsetDatetime($time = null, $offset = 0) |
||
83 | |||
84 | /** |
||
85 | * Get init date & time in format of "Y-m-d H:i:s" or timestamp.s |
||
86 | * @param \yii\base\ModelEvent $event |
||
87 | * @return string|int |
||
88 | */ |
||
89 | 6 | public static function getInitDatetime($event) |
|
94 | |||
95 | 6 | public function initDatetime() |
|
105 | |||
106 | /** |
||
107 | * Check whether the attribute is init datetime. |
||
108 | * @param mixed $attribute |
||
109 | * @return boolean |
||
110 | */ |
||
111 | 4 | protected function isInitDatetime($attribute) |
|
121 | |||
122 | /** |
||
123 | * Get the current date & time in format of "Y-m-d H:i:s". |
||
124 | * This method is ONLY used for being triggered by event. DO NOT call, |
||
125 | * override or modify it directly, unless you know the consequences. |
||
126 | * @param \yii\base\Event $event |
||
127 | * @return string Date & Time. |
||
128 | * @since 1.1 |
||
129 | */ |
||
130 | 44 | public function onUpdateCurrentDatetime($event) |
|
134 | |||
135 | /** |
||
136 | * Behaviors associated with timestamp. |
||
137 | * @return array behaviors |
||
138 | */ |
||
139 | 12 | public function getTimestampBehaviors() |
|
150 | |||
151 | /** |
||
152 | * Get createdAt. |
||
153 | * @return string timestamp |
||
154 | */ |
||
155 | public function getCreatedAt() |
||
160 | |||
161 | /** |
||
162 | * Get rules associated with createdAtAttribute. |
||
163 | * @return array rules |
||
164 | */ |
||
165 | 12 | public function getCreatedAtRules() |
|
174 | |||
175 | /** |
||
176 | * Get updatedAt. |
||
177 | * @return string timestamp |
||
178 | */ |
||
179 | public function getUpdatedAt() |
||
184 | |||
185 | /** |
||
186 | * Get rules associated with updatedAtAttribute. |
||
187 | * @return array rules |
||
188 | */ |
||
189 | 12 | public function getUpdatedAtRules() |
|
198 | } |
||
199 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.