Conditions | 4 |
Paths | 3 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
20 | protected function asDateTime($value) |
||
21 | { |
||
22 | $datetime = parent::asDateTime($value); |
||
23 | $timezone = optional(request()->user())->timezone; |
||
24 | |||
25 | if (! $timezone || $timezone === config('app.timezone')) { |
||
26 | return $datetime; |
||
27 | } |
||
28 | |||
29 | $thisIsUpdateRequest = Arr::first(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 30), function ($trace) { |
||
|
|||
30 | return $trace['function'] === 'setAttribute'; |
||
31 | }); |
||
32 | |||
33 | if ($thisIsUpdateRequest) { |
||
34 | // When updating attributes, we need to reset user timezone to system timezone before saving! |
||
35 | return Date::parse($datetime->toDateTimeString(), $timezone)->setTimezone(config('app.timezone')); |
||
36 | } |
||
37 | |||
38 | return $datetime->setTimezone(new DateTimeZone($timezone)); |
||
39 | } |
||
40 | |||
55 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: