1 | <?php |
||
25 | trait TimestampTrait |
||
26 | { |
||
27 | |||
28 | /** |
||
29 | * @var string the attribute that will receive datetime value |
||
30 | * Set this property to false if you do not want to record the creation time. |
||
31 | */ |
||
32 | public $createdAtAttribute = 'create_time'; |
||
33 | |||
34 | /** |
||
35 | * @var string the attribute that will receive datetime value. |
||
36 | * Set this property to false if you do not want to record the update time. |
||
37 | */ |
||
38 | public $updatedAtAttribute = 'update_time'; |
||
39 | |||
40 | /** |
||
41 | * @var integer Determine the format of timestamp. |
||
42 | */ |
||
43 | public $timeFormat = 0; |
||
44 | public static $timeFormatDatetime = 0; |
||
45 | public static $timeFormatTimestamp = 1; |
||
46 | public static $initDatetime = '1970-01-01 00:00:00'; |
||
47 | public static $initTimestamp = 0; |
||
48 | |||
49 | /** |
||
50 | * Get the current date & time in format of "Y-m-d H:i:s" or timestamp. |
||
51 | * You can override this method to customize the return value. |
||
52 | * @param \yii\base\ModelEvent $event |
||
53 | * @return string Date & Time. |
||
54 | * @since 1.1 |
||
55 | */ |
||
56 | 41 | public static function getCurrentDatetime($event) |
|
61 | |||
62 | 41 | public function currentDatetime() |
|
71 | |||
72 | /** |
||
73 | * Get init date & time in format of "Y-m-d H:i:s" or timestamp.s |
||
74 | * @param \yii\base\ModelEvent $event |
||
75 | * @return string|int |
||
76 | */ |
||
77 | 3 | public static function getInitDatetime($event) |
|
82 | |||
83 | 3 | public function initDatetime() |
|
93 | |||
94 | 2 | protected function isInitDatetime($attribute) |
|
104 | |||
105 | /** |
||
106 | * Get the current date & time in format of "Y-m-d H:i:s". |
||
107 | * This method is ONLY used for being triggered by event. DO NOT call, |
||
108 | * override or modify it directly, unless you know the consequences. |
||
109 | * @param \yii\base\Event $event |
||
110 | * @return string Date & Time. |
||
111 | * @since 1.1 |
||
112 | */ |
||
113 | 41 | public function onUpdateCurrentDatetime($event) |
|
117 | |||
118 | /** |
||
119 | * Behaviors associated with timestamp. |
||
120 | * @return array behaviors |
||
121 | */ |
||
122 | 11 | public function getTimestampBehaviors() |
|
133 | |||
134 | /** |
||
135 | * Get createdAtAttribute. |
||
136 | * @return string timestamp |
||
137 | */ |
||
138 | public function getCreatedAt() |
||
143 | |||
144 | /** |
||
145 | * Get rules associated with createdAtAttribute. |
||
146 | * @return array rules |
||
147 | */ |
||
148 | 11 | public function getCreatedAtRules() |
|
157 | |||
158 | /** |
||
159 | * Get rules associated with updatedAtAttribute. |
||
160 | * @return array rules |
||
161 | */ |
||
162 | 11 | public function getUpdatedAtRules() |
|
171 | } |
||
172 |
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.