1 | <?php |
||
10 | class TimeZone implements ValueObjectInterface |
||
11 | { |
||
12 | /** @var StringLiteral */ |
||
13 | protected $name; |
||
14 | |||
15 | /** |
||
16 | * Returns a new Time object from native timezone name |
||
17 | * |
||
18 | * @param string $name |
||
|
|||
19 | * @return self |
||
20 | */ |
||
21 | 4 | public static function fromNative() |
|
22 | { |
||
23 | 4 | $args = func_get_args(); |
|
24 | |||
25 | 4 | $name = new StringLiteral($args[0]); |
|
26 | |||
27 | 4 | return new static($name); |
|
28 | } |
||
29 | |||
30 | /** |
||
31 | * Returns a new Time from a native PHP \DateTime |
||
32 | * |
||
33 | * @param \DateTimeZone $timezone |
||
34 | * @return self |
||
35 | */ |
||
36 | 2 | public static function fromNativeDateTimeZone(\DateTimeZone $timezone) |
|
40 | |||
41 | /** |
||
42 | * Returns default TimeZone |
||
43 | * |
||
44 | * @return self |
||
45 | */ |
||
46 | 2 | public static function fromDefault() |
|
50 | |||
51 | /** |
||
52 | * Returns a new TimeZone object |
||
53 | * |
||
54 | * @param StringLiteral $name |
||
55 | * @throws InvalidTimeZoneException |
||
56 | */ |
||
57 | 17 | public function __construct(StringLiteral $name) |
|
58 | { |
||
59 | 17 | if (!in_array($name->toNative(), timezone_identifiers_list())) { |
|
60 | 1 | throw new InvalidTimeZoneException($name); |
|
61 | } |
||
62 | |||
63 | 16 | $this->name = $name; |
|
64 | 16 | } |
|
65 | |||
66 | /** |
||
67 | * Returns a native PHP \DateTimeZone version of the current TimeZone. |
||
68 | * |
||
69 | * @return \DateTimeZone |
||
70 | */ |
||
71 | 3 | public function toNativeDateTimeZone() |
|
75 | |||
76 | /** |
||
77 | * Tells whether two DateTimeZone are equal by comparing their names |
||
78 | * |
||
79 | * @param ValueObjectInterface $timezone |
||
80 | * @return bool |
||
81 | */ |
||
82 | 7 | public function sameValueAs(ValueObjectInterface $timezone) |
|
83 | { |
||
84 | 7 | if (false === Util::classEquals($this, $timezone)) { |
|
85 | 1 | return false; |
|
86 | } |
||
87 | |||
88 | 7 | return $this->getName()->sameValueAs($timezone->getName()); |
|
89 | } |
||
90 | |||
91 | /** |
||
92 | * Returns timezone name |
||
93 | * |
||
94 | * @return String |
||
95 | */ |
||
96 | 15 | public function getName() |
|
100 | |||
101 | /** |
||
102 | * Returns timezone name as string |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | 4 | public function __toString() |
|
110 | |||
111 | function jsonSerialize() |
||
112 | { |
||
113 | return (string) $this; |
||
115 | |||
116 | |||
117 | } |
||
118 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.