@@ -12,60 +12,60 @@ |
||
12 | 12 | */ |
13 | 13 | class FindFromTimezoneIdentifier implements TimezoneFinder |
14 | 14 | { |
15 | - public function find(string $tzid, bool $failIfUncertain = false): ?DateTimeZone |
|
16 | - { |
|
17 | - // First we will just see if the tzid is a support timezone identifier. |
|
18 | - // |
|
19 | - // The only exception is if the timezone starts with (. This is to |
|
20 | - // handle cases where certain microsoft products generate timezone |
|
21 | - // identifiers that for instance look like: |
|
22 | - // |
|
23 | - // (GMT+01.00) Sarajevo/Warsaw/Zagreb |
|
24 | - // |
|
25 | - // Since PHP 5.5.10, the first bit will be used as the timezone and |
|
26 | - // this method will return just GMT+01:00. This is wrong, because it |
|
27 | - // doesn't take DST into account |
|
28 | - if (!isset($tzid[0])) { |
|
29 | - return null; |
|
30 | - } |
|
31 | - if ('(' === $tzid[0]) { |
|
32 | - return null; |
|
33 | - } |
|
34 | - // PHP has a bug that logs PHP warnings even it shouldn't: |
|
35 | - // https://bugs.php.net/bug.php?id=67881 |
|
36 | - // |
|
37 | - // That's why we're checking if we'll be able to successfully instantiate |
|
38 | - // \DateTimeZone() before doing so. Otherwise we could simply instantiate |
|
39 | - // and catch the exception. |
|
40 | - $tzIdentifiers = DateTimeZone::listIdentifiers(); |
|
15 | + public function find(string $tzid, bool $failIfUncertain = false): ?DateTimeZone |
|
16 | + { |
|
17 | + // First we will just see if the tzid is a support timezone identifier. |
|
18 | + // |
|
19 | + // The only exception is if the timezone starts with (. This is to |
|
20 | + // handle cases where certain microsoft products generate timezone |
|
21 | + // identifiers that for instance look like: |
|
22 | + // |
|
23 | + // (GMT+01.00) Sarajevo/Warsaw/Zagreb |
|
24 | + // |
|
25 | + // Since PHP 5.5.10, the first bit will be used as the timezone and |
|
26 | + // this method will return just GMT+01:00. This is wrong, because it |
|
27 | + // doesn't take DST into account |
|
28 | + if (!isset($tzid[0])) { |
|
29 | + return null; |
|
30 | + } |
|
31 | + if ('(' === $tzid[0]) { |
|
32 | + return null; |
|
33 | + } |
|
34 | + // PHP has a bug that logs PHP warnings even it shouldn't: |
|
35 | + // https://bugs.php.net/bug.php?id=67881 |
|
36 | + // |
|
37 | + // That's why we're checking if we'll be able to successfully instantiate |
|
38 | + // \DateTimeZone() before doing so. Otherwise we could simply instantiate |
|
39 | + // and catch the exception. |
|
40 | + $tzIdentifiers = DateTimeZone::listIdentifiers(); |
|
41 | 41 | |
42 | - try { |
|
43 | - if ( |
|
44 | - (in_array($tzid, $tzIdentifiers)) || |
|
45 | - (preg_match('/^GMT(\+|-)([0-9]{4})$/', $tzid, $matches)) || |
|
46 | - (in_array($tzid, $this->getIdentifiersBC())) |
|
47 | - ) { |
|
48 | - return new DateTimeZone($tzid); |
|
49 | - } |
|
50 | - } catch (Exception $e) { |
|
51 | - } |
|
42 | + try { |
|
43 | + if ( |
|
44 | + (in_array($tzid, $tzIdentifiers)) || |
|
45 | + (preg_match('/^GMT(\+|-)([0-9]{4})$/', $tzid, $matches)) || |
|
46 | + (in_array($tzid, $this->getIdentifiersBC())) |
|
47 | + ) { |
|
48 | + return new DateTimeZone($tzid); |
|
49 | + } |
|
50 | + } catch (Exception $e) { |
|
51 | + } |
|
52 | 52 | |
53 | - return null; |
|
54 | - } |
|
53 | + return null; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * This method returns an array of timezone identifiers, that are supported |
|
58 | - * by DateTimeZone(), but not returned by DateTimeZone::listIdentifiers(). |
|
59 | - * |
|
60 | - * We're not using DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC) because: |
|
61 | - * - It's not supported by some PHP versions as well as HHVM. |
|
62 | - * - It also returns identifiers, that are invalid values for new DateTimeZone() on some PHP versions. |
|
63 | - * (See timezonedata/php-bc.php and timezonedata php-workaround.php) |
|
64 | - * |
|
65 | - * @return array |
|
66 | - */ |
|
67 | - private function getIdentifiersBC() |
|
68 | - { |
|
69 | - return include __DIR__.'/../timezonedata/php-bc.php'; |
|
70 | - } |
|
56 | + /** |
|
57 | + * This method returns an array of timezone identifiers, that are supported |
|
58 | + * by DateTimeZone(), but not returned by DateTimeZone::listIdentifiers(). |
|
59 | + * |
|
60 | + * We're not using DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC) because: |
|
61 | + * - It's not supported by some PHP versions as well as HHVM. |
|
62 | + * - It also returns identifiers, that are invalid values for new DateTimeZone() on some PHP versions. |
|
63 | + * (See timezonedata/php-bc.php and timezonedata php-workaround.php) |
|
64 | + * |
|
65 | + * @return array |
|
66 | + */ |
|
67 | + private function getIdentifiersBC() |
|
68 | + { |
|
69 | + return include __DIR__.'/../timezonedata/php-bc.php'; |
|
70 | + } |
|
71 | 71 | } |
@@ -9,111 +9,111 @@ |
||
9 | 9 | |
10 | 10 | class GuessFromMsTzId implements TimezoneGuesser |
11 | 11 | { |
12 | - /** |
|
13 | - * List of microsoft exchange timezone ids. |
|
14 | - * |
|
15 | - * Source: http://msdn.microsoft.com/en-us/library/aa563018(loband).aspx |
|
16 | - */ |
|
17 | - public static $microsoftExchangeMap = [ |
|
18 | - 0 => 'UTC', |
|
19 | - 31 => 'Africa/Casablanca', |
|
12 | + /** |
|
13 | + * List of microsoft exchange timezone ids. |
|
14 | + * |
|
15 | + * Source: http://msdn.microsoft.com/en-us/library/aa563018(loband).aspx |
|
16 | + */ |
|
17 | + public static $microsoftExchangeMap = [ |
|
18 | + 0 => 'UTC', |
|
19 | + 31 => 'Africa/Casablanca', |
|
20 | 20 | |
21 | - // Insanely, id #2 is used for both Europe/Lisbon, and Europe/Sarajevo. |
|
22 | - // I'm not even kidding.. We handle this special case in the |
|
23 | - // getTimeZone method. |
|
24 | - 2 => 'Europe/Lisbon', |
|
25 | - 1 => 'Europe/London', |
|
26 | - 4 => 'Europe/Berlin', |
|
27 | - 6 => 'Europe/Prague', |
|
28 | - 3 => 'Europe/Paris', |
|
29 | - 69 => 'Africa/Luanda', // This was a best guess |
|
30 | - 7 => 'Europe/Athens', |
|
31 | - 5 => 'Europe/Bucharest', |
|
32 | - 49 => 'Africa/Cairo', |
|
33 | - 50 => 'Africa/Harare', |
|
34 | - 59 => 'Europe/Helsinki', |
|
35 | - 27 => 'Asia/Jerusalem', |
|
36 | - 26 => 'Asia/Baghdad', |
|
37 | - 74 => 'Asia/Kuwait', |
|
38 | - 51 => 'Europe/Moscow', |
|
39 | - 56 => 'Africa/Nairobi', |
|
40 | - 25 => 'Asia/Tehran', |
|
41 | - 24 => 'Asia/Muscat', // Best guess |
|
42 | - 54 => 'Asia/Baku', |
|
43 | - 48 => 'Asia/Kabul', |
|
44 | - 58 => 'Asia/Yekaterinburg', |
|
45 | - 47 => 'Asia/Karachi', |
|
46 | - 23 => 'Asia/Calcutta', |
|
47 | - 62 => 'Asia/Kathmandu', |
|
48 | - 46 => 'Asia/Almaty', |
|
49 | - 71 => 'Asia/Dhaka', |
|
50 | - 66 => 'Asia/Colombo', |
|
51 | - 61 => 'Asia/Rangoon', |
|
52 | - 22 => 'Asia/Bangkok', |
|
53 | - 64 => 'Asia/Krasnoyarsk', |
|
54 | - 45 => 'Asia/Shanghai', |
|
55 | - 63 => 'Asia/Irkutsk', |
|
56 | - 21 => 'Asia/Singapore', |
|
57 | - 73 => 'Australia/Perth', |
|
58 | - 75 => 'Asia/Taipei', |
|
59 | - 20 => 'Asia/Tokyo', |
|
60 | - 72 => 'Asia/Seoul', |
|
61 | - 70 => 'Asia/Yakutsk', |
|
62 | - 19 => 'Australia/Adelaide', |
|
63 | - 44 => 'Australia/Darwin', |
|
64 | - 18 => 'Australia/Brisbane', |
|
65 | - 76 => 'Australia/Sydney', |
|
66 | - 43 => 'Pacific/Guam', |
|
67 | - 42 => 'Australia/Hobart', |
|
68 | - 68 => 'Asia/Vladivostok', |
|
69 | - 41 => 'Asia/Magadan', |
|
70 | - 17 => 'Pacific/Auckland', |
|
71 | - 40 => 'Pacific/Fiji', |
|
72 | - 67 => 'Pacific/Tongatapu', |
|
73 | - 29 => 'Atlantic/Azores', |
|
74 | - 53 => 'Atlantic/Cape_Verde', |
|
75 | - 30 => 'America/Noronha', |
|
76 | - 8 => 'America/Sao_Paulo', // Best guess |
|
77 | - 32 => 'America/Argentina/Buenos_Aires', |
|
78 | - 60 => 'America/Godthab', |
|
79 | - 28 => 'America/St_Johns', |
|
80 | - 9 => 'America/Halifax', |
|
81 | - 33 => 'America/Caracas', |
|
82 | - 65 => 'America/Santiago', |
|
83 | - 35 => 'America/Bogota', |
|
84 | - 10 => 'America/New_York', |
|
85 | - 34 => 'America/Indiana/Indianapolis', |
|
86 | - 55 => 'America/Guatemala', |
|
87 | - 11 => 'America/Chicago', |
|
88 | - 37 => 'America/Mexico_City', |
|
89 | - 36 => 'America/Edmonton', |
|
90 | - 38 => 'America/Phoenix', |
|
91 | - 12 => 'America/Denver', // Best guess |
|
92 | - 13 => 'America/Los_Angeles', // Best guess |
|
93 | - 14 => 'America/Anchorage', |
|
94 | - 15 => 'Pacific/Honolulu', |
|
95 | - 16 => 'Pacific/Midway', |
|
96 | - 39 => 'Pacific/Kwajalein', |
|
97 | - ]; |
|
21 | + // Insanely, id #2 is used for both Europe/Lisbon, and Europe/Sarajevo. |
|
22 | + // I'm not even kidding.. We handle this special case in the |
|
23 | + // getTimeZone method. |
|
24 | + 2 => 'Europe/Lisbon', |
|
25 | + 1 => 'Europe/London', |
|
26 | + 4 => 'Europe/Berlin', |
|
27 | + 6 => 'Europe/Prague', |
|
28 | + 3 => 'Europe/Paris', |
|
29 | + 69 => 'Africa/Luanda', // This was a best guess |
|
30 | + 7 => 'Europe/Athens', |
|
31 | + 5 => 'Europe/Bucharest', |
|
32 | + 49 => 'Africa/Cairo', |
|
33 | + 50 => 'Africa/Harare', |
|
34 | + 59 => 'Europe/Helsinki', |
|
35 | + 27 => 'Asia/Jerusalem', |
|
36 | + 26 => 'Asia/Baghdad', |
|
37 | + 74 => 'Asia/Kuwait', |
|
38 | + 51 => 'Europe/Moscow', |
|
39 | + 56 => 'Africa/Nairobi', |
|
40 | + 25 => 'Asia/Tehran', |
|
41 | + 24 => 'Asia/Muscat', // Best guess |
|
42 | + 54 => 'Asia/Baku', |
|
43 | + 48 => 'Asia/Kabul', |
|
44 | + 58 => 'Asia/Yekaterinburg', |
|
45 | + 47 => 'Asia/Karachi', |
|
46 | + 23 => 'Asia/Calcutta', |
|
47 | + 62 => 'Asia/Kathmandu', |
|
48 | + 46 => 'Asia/Almaty', |
|
49 | + 71 => 'Asia/Dhaka', |
|
50 | + 66 => 'Asia/Colombo', |
|
51 | + 61 => 'Asia/Rangoon', |
|
52 | + 22 => 'Asia/Bangkok', |
|
53 | + 64 => 'Asia/Krasnoyarsk', |
|
54 | + 45 => 'Asia/Shanghai', |
|
55 | + 63 => 'Asia/Irkutsk', |
|
56 | + 21 => 'Asia/Singapore', |
|
57 | + 73 => 'Australia/Perth', |
|
58 | + 75 => 'Asia/Taipei', |
|
59 | + 20 => 'Asia/Tokyo', |
|
60 | + 72 => 'Asia/Seoul', |
|
61 | + 70 => 'Asia/Yakutsk', |
|
62 | + 19 => 'Australia/Adelaide', |
|
63 | + 44 => 'Australia/Darwin', |
|
64 | + 18 => 'Australia/Brisbane', |
|
65 | + 76 => 'Australia/Sydney', |
|
66 | + 43 => 'Pacific/Guam', |
|
67 | + 42 => 'Australia/Hobart', |
|
68 | + 68 => 'Asia/Vladivostok', |
|
69 | + 41 => 'Asia/Magadan', |
|
70 | + 17 => 'Pacific/Auckland', |
|
71 | + 40 => 'Pacific/Fiji', |
|
72 | + 67 => 'Pacific/Tongatapu', |
|
73 | + 29 => 'Atlantic/Azores', |
|
74 | + 53 => 'Atlantic/Cape_Verde', |
|
75 | + 30 => 'America/Noronha', |
|
76 | + 8 => 'America/Sao_Paulo', // Best guess |
|
77 | + 32 => 'America/Argentina/Buenos_Aires', |
|
78 | + 60 => 'America/Godthab', |
|
79 | + 28 => 'America/St_Johns', |
|
80 | + 9 => 'America/Halifax', |
|
81 | + 33 => 'America/Caracas', |
|
82 | + 65 => 'America/Santiago', |
|
83 | + 35 => 'America/Bogota', |
|
84 | + 10 => 'America/New_York', |
|
85 | + 34 => 'America/Indiana/Indianapolis', |
|
86 | + 55 => 'America/Guatemala', |
|
87 | + 11 => 'America/Chicago', |
|
88 | + 37 => 'America/Mexico_City', |
|
89 | + 36 => 'America/Edmonton', |
|
90 | + 38 => 'America/Phoenix', |
|
91 | + 12 => 'America/Denver', // Best guess |
|
92 | + 13 => 'America/Los_Angeles', // Best guess |
|
93 | + 14 => 'America/Anchorage', |
|
94 | + 15 => 'Pacific/Honolulu', |
|
95 | + 16 => 'Pacific/Midway', |
|
96 | + 39 => 'Pacific/Kwajalein', |
|
97 | + ]; |
|
98 | 98 | |
99 | - public function guess(VTimeZone $vtimezone, bool $throwIfUnsure = false): ?DateTimeZone |
|
100 | - { |
|
101 | - // Microsoft may add a magic number, which we also have an |
|
102 | - // answer for. |
|
103 | - if (!isset($vtimezone->{'X-MICROSOFT-CDO-TZID'})) { |
|
104 | - return null; |
|
105 | - } |
|
106 | - $cdoId = (int) $vtimezone->{'X-MICROSOFT-CDO-TZID'}->getValue(); |
|
99 | + public function guess(VTimeZone $vtimezone, bool $throwIfUnsure = false): ?DateTimeZone |
|
100 | + { |
|
101 | + // Microsoft may add a magic number, which we also have an |
|
102 | + // answer for. |
|
103 | + if (!isset($vtimezone->{'X-MICROSOFT-CDO-TZID'})) { |
|
104 | + return null; |
|
105 | + } |
|
106 | + $cdoId = (int) $vtimezone->{'X-MICROSOFT-CDO-TZID'}->getValue(); |
|
107 | 107 | |
108 | - // 2 can mean both Europe/Lisbon and Europe/Sarajevo. |
|
109 | - if (2 === $cdoId && false !== strpos((string) $vtimezone->TZID, 'Sarajevo')) { |
|
110 | - return new DateTimeZone('Europe/Sarajevo'); |
|
111 | - } |
|
108 | + // 2 can mean both Europe/Lisbon and Europe/Sarajevo. |
|
109 | + if (2 === $cdoId && false !== strpos((string) $vtimezone->TZID, 'Sarajevo')) { |
|
110 | + return new DateTimeZone('Europe/Sarajevo'); |
|
111 | + } |
|
112 | 112 | |
113 | - if (isset(self::$microsoftExchangeMap[$cdoId])) { |
|
114 | - return new DateTimeZone(self::$microsoftExchangeMap[$cdoId]); |
|
115 | - } |
|
113 | + if (isset(self::$microsoftExchangeMap[$cdoId])) { |
|
114 | + return new DateTimeZone(self::$microsoftExchangeMap[$cdoId]); |
|
115 | + } |
|
116 | 116 | |
117 | - return null; |
|
118 | - } |
|
117 | + return null; |
|
118 | + } |
|
119 | 119 | } |
@@ -11,68 +11,68 @@ |
||
11 | 11 | */ |
12 | 12 | class FindFromTimezoneMap implements TimezoneFinder |
13 | 13 | { |
14 | - private $map = []; |
|
14 | + private $map = []; |
|
15 | 15 | |
16 | - private $patterns = [ |
|
17 | - '/^\((UTC|GMT)(\+|\-)[\d]{2}\:[\d]{2}\) (.*)/', |
|
18 | - '/^\((UTC|GMT)(\+|\-)[\d]{2}\.[\d]{2}\) (.*)/', |
|
19 | - ]; |
|
16 | + private $patterns = [ |
|
17 | + '/^\((UTC|GMT)(\+|\-)[\d]{2}\:[\d]{2}\) (.*)/', |
|
18 | + '/^\((UTC|GMT)(\+|\-)[\d]{2}\.[\d]{2}\) (.*)/', |
|
19 | + ]; |
|
20 | 20 | |
21 | - public function find(string $tzid, bool $failIfUncertain = false): ?DateTimeZone |
|
22 | - { |
|
23 | - // Next, we check if the tzid is somewhere in our tzid map. |
|
24 | - if ($this->hasTzInMap($tzid)) { |
|
25 | - return new DateTimeZone($this->getTzFromMap($tzid)); |
|
26 | - } |
|
21 | + public function find(string $tzid, bool $failIfUncertain = false): ?DateTimeZone |
|
22 | + { |
|
23 | + // Next, we check if the tzid is somewhere in our tzid map. |
|
24 | + if ($this->hasTzInMap($tzid)) { |
|
25 | + return new DateTimeZone($this->getTzFromMap($tzid)); |
|
26 | + } |
|
27 | 27 | |
28 | - // Some Microsoft products prefix the offset first, so let's strip that off |
|
29 | - // and see if it is our tzid map. We don't want to check for this first just |
|
30 | - // in case there are overrides in our tzid map. |
|
31 | - foreach ($this->patterns as $pattern) { |
|
32 | - if (!preg_match($pattern, $tzid, $matches)) { |
|
33 | - continue; |
|
34 | - } |
|
35 | - $tzidAlternate = $matches[3]; |
|
36 | - if ($this->hasTzInMap($tzidAlternate)) { |
|
37 | - return new DateTimeZone($this->getTzFromMap($tzidAlternate)); |
|
38 | - } |
|
39 | - } |
|
28 | + // Some Microsoft products prefix the offset first, so let's strip that off |
|
29 | + // and see if it is our tzid map. We don't want to check for this first just |
|
30 | + // in case there are overrides in our tzid map. |
|
31 | + foreach ($this->patterns as $pattern) { |
|
32 | + if (!preg_match($pattern, $tzid, $matches)) { |
|
33 | + continue; |
|
34 | + } |
|
35 | + $tzidAlternate = $matches[3]; |
|
36 | + if ($this->hasTzInMap($tzidAlternate)) { |
|
37 | + return new DateTimeZone($this->getTzFromMap($tzidAlternate)); |
|
38 | + } |
|
39 | + } |
|
40 | 40 | |
41 | - return null; |
|
42 | - } |
|
41 | + return null; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * This method returns an array of timezone identifiers, that are supported |
|
46 | - * by DateTimeZone(), but not returned by DateTimeZone::listIdentifiers(). |
|
47 | - * |
|
48 | - * We're not using DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC) because: |
|
49 | - * - It's not supported by some PHP versions as well as HHVM. |
|
50 | - * - It also returns identifiers, that are invalid values for new DateTimeZone() on some PHP versions. |
|
51 | - * (See timezonedata/php-bc.php and timezonedata php-workaround.php) |
|
52 | - * |
|
53 | - * @return array |
|
54 | - */ |
|
55 | - private function getTzMaps() |
|
56 | - { |
|
57 | - if ([] === $this->map) { |
|
58 | - $this->map = array_merge( |
|
59 | - include __DIR__.'/../timezonedata/windowszones.php', |
|
60 | - include __DIR__.'/../timezonedata/lotuszones.php', |
|
61 | - include __DIR__.'/../timezonedata/exchangezones.php', |
|
62 | - include __DIR__.'/../timezonedata/php-workaround.php' |
|
63 | - ); |
|
64 | - } |
|
44 | + /** |
|
45 | + * This method returns an array of timezone identifiers, that are supported |
|
46 | + * by DateTimeZone(), but not returned by DateTimeZone::listIdentifiers(). |
|
47 | + * |
|
48 | + * We're not using DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC) because: |
|
49 | + * - It's not supported by some PHP versions as well as HHVM. |
|
50 | + * - It also returns identifiers, that are invalid values for new DateTimeZone() on some PHP versions. |
|
51 | + * (See timezonedata/php-bc.php and timezonedata php-workaround.php) |
|
52 | + * |
|
53 | + * @return array |
|
54 | + */ |
|
55 | + private function getTzMaps() |
|
56 | + { |
|
57 | + if ([] === $this->map) { |
|
58 | + $this->map = array_merge( |
|
59 | + include __DIR__.'/../timezonedata/windowszones.php', |
|
60 | + include __DIR__.'/../timezonedata/lotuszones.php', |
|
61 | + include __DIR__.'/../timezonedata/exchangezones.php', |
|
62 | + include __DIR__.'/../timezonedata/php-workaround.php' |
|
63 | + ); |
|
64 | + } |
|
65 | 65 | |
66 | - return $this->map; |
|
67 | - } |
|
66 | + return $this->map; |
|
67 | + } |
|
68 | 68 | |
69 | - private function getTzFromMap(string $tzid): string |
|
70 | - { |
|
71 | - return $this->getTzMaps()[$tzid]; |
|
72 | - } |
|
69 | + private function getTzFromMap(string $tzid): string |
|
70 | + { |
|
71 | + return $this->getTzMaps()[$tzid]; |
|
72 | + } |
|
73 | 73 | |
74 | - private function hasTzInMap(string $tzid): bool |
|
75 | - { |
|
76 | - return isset($this->getTzMaps()[$tzid]); |
|
77 | - } |
|
74 | + private function hasTzInMap(string $tzid): bool |
|
75 | + { |
|
76 | + return isset($this->getTzMaps()[$tzid]); |
|
77 | + } |
|
78 | 78 | } |
@@ -11,21 +11,21 @@ |
||
11 | 11 | */ |
12 | 12 | class FindFromOffset implements TimezoneFinder |
13 | 13 | { |
14 | - public function find(string $tzid, bool $failIfUncertain = false): ?DateTimeZone |
|
15 | - { |
|
16 | - // Maybe the author was hyper-lazy and just included an offset. We |
|
17 | - // support it, but we aren't happy about it. |
|
18 | - if (preg_match('/^GMT(\+|-)([0-9]{4})$/', $tzid, $matches)) { |
|
19 | - // Note that the path in the source will never be taken from PHP 5.5.10 |
|
20 | - // onwards. PHP 5.5.10 supports the "GMT+0100" style of format, so it |
|
21 | - // already gets returned early in this function. Once we drop support |
|
22 | - // for versions under PHP 5.5.10, this bit can be taken out of the |
|
23 | - // source. |
|
24 | - // @codeCoverageIgnoreStart |
|
25 | - return new DateTimeZone('Etc/GMT'.$matches[1].ltrim(substr($matches[2], 0, 2), '0')); |
|
26 | - // @codeCoverageIgnoreEnd |
|
27 | - } |
|
14 | + public function find(string $tzid, bool $failIfUncertain = false): ?DateTimeZone |
|
15 | + { |
|
16 | + // Maybe the author was hyper-lazy and just included an offset. We |
|
17 | + // support it, but we aren't happy about it. |
|
18 | + if (preg_match('/^GMT(\+|-)([0-9]{4})$/', $tzid, $matches)) { |
|
19 | + // Note that the path in the source will never be taken from PHP 5.5.10 |
|
20 | + // onwards. PHP 5.5.10 supports the "GMT+0100" style of format, so it |
|
21 | + // already gets returned early in this function. Once we drop support |
|
22 | + // for versions under PHP 5.5.10, this bit can be taken out of the |
|
23 | + // source. |
|
24 | + // @codeCoverageIgnoreStart |
|
25 | + return new DateTimeZone('Etc/GMT'.$matches[1].ltrim(substr($matches[2], 0, 2), '0')); |
|
26 | + // @codeCoverageIgnoreEnd |
|
27 | + } |
|
28 | 28 | |
29 | - return null; |
|
30 | - } |
|
29 | + return null; |
|
30 | + } |
|
31 | 31 | } |
@@ -7,5 +7,5 @@ |
||
7 | 7 | |
8 | 8 | interface TimezoneGuesser |
9 | 9 | { |
10 | - public function guess(VTimeZone $vtimezone, bool $failIfUncertain = false): ?DateTimeZone; |
|
10 | + public function guess(VTimeZone $vtimezone, bool $failIfUncertain = false): ?DateTimeZone; |
|
11 | 11 | } |
@@ -13,21 +13,21 @@ |
||
13 | 13 | */ |
14 | 14 | class GuessFromLicEntry implements TimezoneGuesser |
15 | 15 | { |
16 | - public function guess(VTimeZone $vtimezone, bool $failIfUncertain = false): ?DateTimeZone |
|
17 | - { |
|
18 | - if (!isset($vtimezone->{'X-LIC-LOCATION'})) { |
|
19 | - return null; |
|
20 | - } |
|
16 | + public function guess(VTimeZone $vtimezone, bool $failIfUncertain = false): ?DateTimeZone |
|
17 | + { |
|
18 | + if (!isset($vtimezone->{'X-LIC-LOCATION'})) { |
|
19 | + return null; |
|
20 | + } |
|
21 | 21 | |
22 | - $lic = (string) $vtimezone->{'X-LIC-LOCATION'}; |
|
22 | + $lic = (string) $vtimezone->{'X-LIC-LOCATION'}; |
|
23 | 23 | |
24 | - // Libical generators may specify strings like |
|
25 | - // "SystemV/EST5EDT". For those we must remove the |
|
26 | - // SystemV part. |
|
27 | - if ('SystemV/' === substr($lic, 0, 8)) { |
|
28 | - $lic = substr($lic, 8); |
|
29 | - } |
|
24 | + // Libical generators may specify strings like |
|
25 | + // "SystemV/EST5EDT". For those we must remove the |
|
26 | + // SystemV part. |
|
27 | + if ('SystemV/' === substr($lic, 0, 8)) { |
|
28 | + $lic = substr($lic, 8); |
|
29 | + } |
|
30 | 30 | |
31 | - return TimeZoneUtil::getTimeZone($lic, null, $failIfUncertain); |
|
32 | - } |
|
31 | + return TimeZoneUtil::getTimeZone($lic, null, $failIfUncertain); |
|
32 | + } |
|
33 | 33 | } |
@@ -16,121 +16,121 @@ |
||
16 | 16 | */ |
17 | 17 | class Message |
18 | 18 | { |
19 | - /** |
|
20 | - * The object's UID. |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - public $uid; |
|
19 | + /** |
|
20 | + * The object's UID. |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + public $uid; |
|
25 | 25 | |
26 | - /** |
|
27 | - * The component type, such as VEVENT. |
|
28 | - * |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - public $component; |
|
26 | + /** |
|
27 | + * The component type, such as VEVENT. |
|
28 | + * |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + public $component; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Contains the ITip method, which is something like REQUEST, REPLY or |
|
35 | - * CANCEL. |
|
36 | - * |
|
37 | - * @var string |
|
38 | - */ |
|
39 | - public $method; |
|
33 | + /** |
|
34 | + * Contains the ITip method, which is something like REQUEST, REPLY or |
|
35 | + * CANCEL. |
|
36 | + * |
|
37 | + * @var string |
|
38 | + */ |
|
39 | + public $method; |
|
40 | 40 | |
41 | - /** |
|
42 | - * The current sequence number for the event. |
|
43 | - * |
|
44 | - * @var int |
|
45 | - */ |
|
46 | - public $sequence; |
|
41 | + /** |
|
42 | + * The current sequence number for the event. |
|
43 | + * |
|
44 | + * @var int |
|
45 | + */ |
|
46 | + public $sequence; |
|
47 | 47 | |
48 | - /** |
|
49 | - * The senders' email address. |
|
50 | - * |
|
51 | - * Note that this does not imply that this has to be used in a From: field |
|
52 | - * if the message is sent by email. It may also be populated in Reply-To: |
|
53 | - * or not at all. |
|
54 | - * |
|
55 | - * @var string |
|
56 | - */ |
|
57 | - public $sender; |
|
48 | + /** |
|
49 | + * The senders' email address. |
|
50 | + * |
|
51 | + * Note that this does not imply that this has to be used in a From: field |
|
52 | + * if the message is sent by email. It may also be populated in Reply-To: |
|
53 | + * or not at all. |
|
54 | + * |
|
55 | + * @var string |
|
56 | + */ |
|
57 | + public $sender; |
|
58 | 58 | |
59 | - /** |
|
60 | - * The name of the sender. This is often populated from a CN parameter from |
|
61 | - * either the ORGANIZER or ATTENDEE, depending on the message. |
|
62 | - * |
|
63 | - * @var string|null |
|
64 | - */ |
|
65 | - public $senderName; |
|
59 | + /** |
|
60 | + * The name of the sender. This is often populated from a CN parameter from |
|
61 | + * either the ORGANIZER or ATTENDEE, depending on the message. |
|
62 | + * |
|
63 | + * @var string|null |
|
64 | + */ |
|
65 | + public $senderName; |
|
66 | 66 | |
67 | - /** |
|
68 | - * The recipient's email address. |
|
69 | - * |
|
70 | - * @var string |
|
71 | - */ |
|
72 | - public $recipient; |
|
67 | + /** |
|
68 | + * The recipient's email address. |
|
69 | + * |
|
70 | + * @var string |
|
71 | + */ |
|
72 | + public $recipient; |
|
73 | 73 | |
74 | - /** |
|
75 | - * The name of the recipient. This is usually populated with the CN |
|
76 | - * parameter from the ATTENDEE or ORGANIZER property, if it's available. |
|
77 | - * |
|
78 | - * @var string|null |
|
79 | - */ |
|
80 | - public $recipientName; |
|
74 | + /** |
|
75 | + * The name of the recipient. This is usually populated with the CN |
|
76 | + * parameter from the ATTENDEE or ORGANIZER property, if it's available. |
|
77 | + * |
|
78 | + * @var string|null |
|
79 | + */ |
|
80 | + public $recipientName; |
|
81 | 81 | |
82 | - /** |
|
83 | - * After the message has been delivered, this should contain a string such |
|
84 | - * as : 1.1;Sent or 1.2;Delivered. |
|
85 | - * |
|
86 | - * In case of a failure, this will hold the error status code. |
|
87 | - * |
|
88 | - * See: |
|
89 | - * http://tools.ietf.org/html/rfc6638#section-7.3 |
|
90 | - * |
|
91 | - * @var string |
|
92 | - */ |
|
93 | - public $scheduleStatus; |
|
82 | + /** |
|
83 | + * After the message has been delivered, this should contain a string such |
|
84 | + * as : 1.1;Sent or 1.2;Delivered. |
|
85 | + * |
|
86 | + * In case of a failure, this will hold the error status code. |
|
87 | + * |
|
88 | + * See: |
|
89 | + * http://tools.ietf.org/html/rfc6638#section-7.3 |
|
90 | + * |
|
91 | + * @var string |
|
92 | + */ |
|
93 | + public $scheduleStatus; |
|
94 | 94 | |
95 | - /** |
|
96 | - * The iCalendar / iTip body. |
|
97 | - * |
|
98 | - * @var \Sabre\VObject\Component\VCalendar |
|
99 | - */ |
|
100 | - public $message; |
|
95 | + /** |
|
96 | + * The iCalendar / iTip body. |
|
97 | + * |
|
98 | + * @var \Sabre\VObject\Component\VCalendar |
|
99 | + */ |
|
100 | + public $message; |
|
101 | 101 | |
102 | - /** |
|
103 | - * This will be set to true, if the iTip broker considers the change |
|
104 | - * 'significant'. |
|
105 | - * |
|
106 | - * In practice, this means that we'll only mark it true, if for instance |
|
107 | - * DTSTART changed. This allows systems to only send iTip messages when |
|
108 | - * significant changes happened. This is especially useful for iMip, as |
|
109 | - * normally a ton of messages may be generated for normal calendar use. |
|
110 | - * |
|
111 | - * To see the list of properties that are considered 'significant', check |
|
112 | - * out Sabre\VObject\ITip\Broker::$significantChangeProperties. |
|
113 | - * |
|
114 | - * @var bool |
|
115 | - */ |
|
116 | - public $significantChange = true; |
|
102 | + /** |
|
103 | + * This will be set to true, if the iTip broker considers the change |
|
104 | + * 'significant'. |
|
105 | + * |
|
106 | + * In practice, this means that we'll only mark it true, if for instance |
|
107 | + * DTSTART changed. This allows systems to only send iTip messages when |
|
108 | + * significant changes happened. This is especially useful for iMip, as |
|
109 | + * normally a ton of messages may be generated for normal calendar use. |
|
110 | + * |
|
111 | + * To see the list of properties that are considered 'significant', check |
|
112 | + * out Sabre\VObject\ITip\Broker::$significantChangeProperties. |
|
113 | + * |
|
114 | + * @var bool |
|
115 | + */ |
|
116 | + public $significantChange = true; |
|
117 | 117 | |
118 | - /** |
|
119 | - * Returns the schedule status as a string. |
|
120 | - * |
|
121 | - * For example: |
|
122 | - * 1.2 |
|
123 | - * |
|
124 | - * @return mixed bool|string |
|
125 | - */ |
|
126 | - public function getScheduleStatus() |
|
127 | - { |
|
128 | - if (!$this->scheduleStatus) { |
|
129 | - return false; |
|
130 | - } else { |
|
131 | - list($scheduleStatus) = explode(';', $this->scheduleStatus); |
|
118 | + /** |
|
119 | + * Returns the schedule status as a string. |
|
120 | + * |
|
121 | + * For example: |
|
122 | + * 1.2 |
|
123 | + * |
|
124 | + * @return mixed bool|string |
|
125 | + */ |
|
126 | + public function getScheduleStatus() |
|
127 | + { |
|
128 | + if (!$this->scheduleStatus) { |
|
129 | + return false; |
|
130 | + } else { |
|
131 | + list($scheduleStatus) = explode(';', $this->scheduleStatus); |
|
132 | 132 | |
133 | - return $scheduleStatus; |
|
134 | - } |
|
135 | - } |
|
133 | + return $scheduleStatus; |
|
134 | + } |
|
135 | + } |
|
136 | 136 | } |
@@ -16,53 +16,53 @@ |
||
16 | 16 | */ |
17 | 17 | class Writer |
18 | 18 | { |
19 | - /** |
|
20 | - * Serializes a vCard or iCalendar object. |
|
21 | - * |
|
22 | - * @return string |
|
23 | - */ |
|
24 | - public static function write(Component $component) |
|
25 | - { |
|
26 | - return $component->serialize(); |
|
27 | - } |
|
19 | + /** |
|
20 | + * Serializes a vCard or iCalendar object. |
|
21 | + * |
|
22 | + * @return string |
|
23 | + */ |
|
24 | + public static function write(Component $component) |
|
25 | + { |
|
26 | + return $component->serialize(); |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Serializes a jCal or jCard object. |
|
31 | - * |
|
32 | - * @param int $options |
|
33 | - * |
|
34 | - * @return string |
|
35 | - */ |
|
36 | - public static function writeJson(Component $component, $options = 0) |
|
37 | - { |
|
38 | - return json_encode($component, $options); |
|
39 | - } |
|
29 | + /** |
|
30 | + * Serializes a jCal or jCard object. |
|
31 | + * |
|
32 | + * @param int $options |
|
33 | + * |
|
34 | + * @return string |
|
35 | + */ |
|
36 | + public static function writeJson(Component $component, $options = 0) |
|
37 | + { |
|
38 | + return json_encode($component, $options); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Serializes a xCal or xCard object. |
|
43 | - * |
|
44 | - * @return string |
|
45 | - */ |
|
46 | - public static function writeXml(Component $component) |
|
47 | - { |
|
48 | - $writer = new Xml\Writer(); |
|
49 | - $writer->openMemory(); |
|
50 | - $writer->setIndent(true); |
|
41 | + /** |
|
42 | + * Serializes a xCal or xCard object. |
|
43 | + * |
|
44 | + * @return string |
|
45 | + */ |
|
46 | + public static function writeXml(Component $component) |
|
47 | + { |
|
48 | + $writer = new Xml\Writer(); |
|
49 | + $writer->openMemory(); |
|
50 | + $writer->setIndent(true); |
|
51 | 51 | |
52 | - $writer->startDocument('1.0', 'utf-8'); |
|
52 | + $writer->startDocument('1.0', 'utf-8'); |
|
53 | 53 | |
54 | - if ($component instanceof Component\VCalendar) { |
|
55 | - $writer->startElement('icalendar'); |
|
56 | - $writer->writeAttribute('xmlns', Parser\XML::XCAL_NAMESPACE); |
|
57 | - } else { |
|
58 | - $writer->startElement('vcards'); |
|
59 | - $writer->writeAttribute('xmlns', Parser\XML::XCARD_NAMESPACE); |
|
60 | - } |
|
54 | + if ($component instanceof Component\VCalendar) { |
|
55 | + $writer->startElement('icalendar'); |
|
56 | + $writer->writeAttribute('xmlns', Parser\XML::XCAL_NAMESPACE); |
|
57 | + } else { |
|
58 | + $writer->startElement('vcards'); |
|
59 | + $writer->writeAttribute('xmlns', Parser\XML::XCARD_NAMESPACE); |
|
60 | + } |
|
61 | 61 | |
62 | - $component->xmlSerialize($writer); |
|
62 | + $component->xmlSerialize($writer); |
|
63 | 63 | |
64 | - $writer->endElement(); |
|
64 | + $writer->endElement(); |
|
65 | 65 | |
66 | - return $writer->outputMemory(); |
|
67 | - } |
|
66 | + return $writer->outputMemory(); |
|
67 | + } |
|
68 | 68 | } |
@@ -17,32 +17,32 @@ |
||
17 | 17 | */ |
18 | 18 | class ElementList extends ArrayIterator |
19 | 19 | { |
20 | - /* {{{ ArrayAccess Interface */ |
|
20 | + /* {{{ ArrayAccess Interface */ |
|
21 | 21 | |
22 | - /** |
|
23 | - * Sets an item through ArrayAccess. |
|
24 | - * |
|
25 | - * @param int $offset |
|
26 | - * @param mixed $value |
|
27 | - */ |
|
28 | - #[\ReturnTypeWillChange] |
|
29 | - public function offsetSet($offset, $value) |
|
30 | - { |
|
31 | - throw new LogicException('You can not add new objects to an ElementList'); |
|
32 | - } |
|
22 | + /** |
|
23 | + * Sets an item through ArrayAccess. |
|
24 | + * |
|
25 | + * @param int $offset |
|
26 | + * @param mixed $value |
|
27 | + */ |
|
28 | + #[\ReturnTypeWillChange] |
|
29 | + public function offsetSet($offset, $value) |
|
30 | + { |
|
31 | + throw new LogicException('You can not add new objects to an ElementList'); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Sets an item through ArrayAccess. |
|
36 | - * |
|
37 | - * This method just forwards the request to the inner iterator |
|
38 | - * |
|
39 | - * @param int $offset |
|
40 | - */ |
|
41 | - #[\ReturnTypeWillChange] |
|
42 | - public function offsetUnset($offset) |
|
43 | - { |
|
44 | - throw new LogicException('You can not remove objects from an ElementList'); |
|
45 | - } |
|
34 | + /** |
|
35 | + * Sets an item through ArrayAccess. |
|
36 | + * |
|
37 | + * This method just forwards the request to the inner iterator |
|
38 | + * |
|
39 | + * @param int $offset |
|
40 | + */ |
|
41 | + #[\ReturnTypeWillChange] |
|
42 | + public function offsetUnset($offset) |
|
43 | + { |
|
44 | + throw new LogicException('You can not remove objects from an ElementList'); |
|
45 | + } |
|
46 | 46 | |
47 | - /* }}} */ |
|
47 | + /* }}} */ |
|
48 | 48 | } |