These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace SRF\iCalendar; |
||
4 | |||
5 | use SMWDataValueFactory as DataValueFactory; |
||
6 | use SMWTimeValue as TimeValue; |
||
7 | |||
8 | /** |
||
9 | * @license GNU GPL v2+ |
||
10 | * @since 3.2 |
||
11 | */ |
||
12 | class DateParser { |
||
13 | |||
14 | /** |
||
15 | * Extract a date string formatted for iCalendar from a SMWTimeValue object. |
||
16 | * |
||
17 | * @since 3.2 |
||
18 | * |
||
19 | * @param TimeValue $dataValue |
||
20 | * @param boolean $isEnd |
||
21 | * |
||
22 | * @return string |
||
23 | */ |
||
24 | 4 | public function parseDate( TimeValue $dataValue, $isEnd = false ) { |
|
25 | 4 | $year = $dataValue->getYear(); |
|
26 | |||
27 | // ISO range is limited to four digits |
||
28 | 4 | if ( ( $year > 9999 ) || ( $year < -9998 ) ) { |
|
29 | return ''; |
||
30 | } |
||
31 | |||
32 | 4 | $year = number_format( $year, 0, '.', '' ); |
|
33 | 4 | $time = str_replace( ':', '', $dataValue->getTimeString( false ) ); |
|
0 ignored issues
–
show
|
|||
34 | |||
35 | // increment by one day, compute date to cover leap years etc. |
||
36 | 4 | if ( ( $time == false ) && ( $isEnd ) ) { |
|
37 | 1 | $dataValue = DataValueFactory::getInstance()->newDataValueByType( |
|
38 | 1 | '_dat', |
|
39 | 1 | $dataValue->getWikiValue() . 'T00:00:00-24:00' |
|
40 | ); |
||
41 | } |
||
42 | |||
43 | 4 | $month = $dataValue->getMonth(); |
|
44 | |||
45 | 4 | if ( strlen( $month ) == 1 ) { |
|
46 | 3 | $month = '0' . $month; |
|
47 | } |
||
48 | |||
49 | 4 | $day = $dataValue->getDay(); |
|
50 | |||
51 | 4 | if ( strlen( $day ) == 1 ) { |
|
52 | 3 | $day = '0' . $day; |
|
53 | } |
||
54 | |||
55 | 4 | $result = $year . $month . $day; |
|
56 | |||
57 | 4 | if ( $time != false ) { |
|
58 | 3 | $result .= "T$time"; |
|
59 | } |
||
60 | |||
61 | 4 | return $result; |
|
62 | } |
||
63 | |||
64 | } |
||
65 |
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: