1 | <?php |
||
46 | class Presence implements ProtocolImplementationInterface |
||
47 | { |
||
48 | /** |
||
49 | * Signals that the entity is available for communication. |
||
50 | */ |
||
51 | |||
52 | const TYPE_AVAILABLE = 'available'; |
||
53 | |||
54 | /** |
||
55 | * Signals that the entity is no longer available for communication. |
||
56 | */ |
||
57 | const TYPE_UNAVAILABLE = 'unavailable'; |
||
58 | |||
59 | /** |
||
60 | * The sender wishes to subscribe to the recipient's presence. |
||
61 | */ |
||
62 | const TYPE_SUBSCRIBE = 'subscribe'; |
||
63 | |||
64 | /** |
||
65 | * The sender has allowed the recipient to receive their presence. |
||
66 | */ |
||
67 | const TYPE_SUBSCRIBED = 'subscribed'; |
||
68 | |||
69 | /** |
||
70 | * The sender is unsubscribing from another entity's presence. |
||
71 | */ |
||
72 | const TYPE_UNSUBSCRIBE = 'unsubscribe'; |
||
73 | |||
74 | /** |
||
75 | * The subscription request has been denied or a previously-granted subscription has been cancelled. |
||
76 | */ |
||
77 | const TYPE_UNSUBSCRIBED = 'unsubscribed'; |
||
78 | |||
79 | /** |
||
80 | * A request for an entity's current presence; SHOULD be generated only by a server on behalf of a user. |
||
81 | */ |
||
82 | const TYPE_PROBE = 'probe'; |
||
83 | |||
84 | /** |
||
85 | * An error has occurred regarding processing or delivery of a previously-sent presence stanza. |
||
86 | */ |
||
87 | const TYPE_ERROR = 'error'; |
||
88 | |||
89 | /** |
||
90 | * The entity or resource is available. |
||
91 | */ |
||
92 | const SHOW_AVAILABLE = 'available'; |
||
93 | |||
94 | /** |
||
95 | * The entity or resource is temporarily away. |
||
96 | */ |
||
97 | const SHOW_AWAY = 'away'; |
||
98 | |||
99 | /** |
||
100 | * The entity or resource is actively interested in chatting. |
||
101 | */ |
||
102 | const SHOW_CHAT = 'chat'; |
||
103 | |||
104 | /** |
||
105 | * The entity or resource is busy (dnd = "Do Not Disturb"). |
||
106 | */ |
||
107 | const SHOW_DND = 'dnd'; |
||
108 | |||
109 | /** |
||
110 | * The entity or resource is away for an extended period (xa = "eXtended Away"). |
||
111 | */ |
||
112 | const SHOW_XA = 'xa'; |
||
113 | |||
114 | /** |
||
115 | * Presence to. |
||
116 | * |
||
117 | * @var string|null |
||
118 | */ |
||
119 | protected $to; |
||
120 | |||
121 | /** |
||
122 | * Priority. |
||
123 | * |
||
124 | * @var integer |
||
125 | */ |
||
126 | protected $priority = 1; |
||
127 | |||
128 | /** |
||
129 | * Nickname for presence. |
||
130 | * |
||
131 | * @var string |
||
132 | */ |
||
133 | protected $nickname; |
||
134 | |||
135 | /** |
||
136 | * Channel password. |
||
137 | * |
||
138 | * @var string |
||
139 | */ |
||
140 | protected $password; |
||
141 | |||
142 | /** |
||
143 | * Constructor. |
||
144 | * |
||
145 | * @param integer $priority |
||
146 | * @param string $to |
||
147 | * @param string $nickname |
||
148 | */ |
||
149 | 3 | public function __construct($priority = 1, $to = null, $nickname = null) |
|
153 | |||
154 | /** |
||
155 | * {@inheritDoc} |
||
156 | */ |
||
157 | 3 | public function toString() |
|
158 | { |
||
159 | 3 | $presence = '<presence'; |
|
160 | |||
161 | 3 | if (null !== $this->getTo()) { |
|
162 | 3 | $presence .= ' to="' . XML::quote($this->getTo()) . '/' . XML::quote($this->getNickname()) . '"'; |
|
163 | 1 | } |
|
164 | |||
165 | 3 | $presence .= '><priority>' . $this->getPriority() . '</priority>'; |
|
166 | |||
167 | 3 | if (null !== $this->getPassword()) { |
|
168 | $presence .= "<x xmlns='http://jabber.org/protocol/muc'><password>" . $this->getPassword() . "</password></x>"; |
||
169 | } |
||
170 | |||
171 | 3 | $presence .= '</presence>'; |
|
172 | 3 | return $presence; |
|
173 | } |
||
174 | |||
175 | /** |
||
176 | * Get nickname. |
||
177 | * |
||
178 | * @return string |
||
179 | */ |
||
180 | 3 | public function getNickname() |
|
184 | |||
185 | /** |
||
186 | * Set nickname. |
||
187 | * |
||
188 | * @param string $nickname |
||
189 | * @return $this |
||
190 | */ |
||
191 | 3 | public function setNickname($nickname) |
|
196 | |||
197 | /** |
||
198 | * Get to. |
||
199 | * |
||
200 | * @return string¦null |
||
201 | */ |
||
202 | 3 | public function getTo() |
|
206 | |||
207 | /** |
||
208 | * Set to. |
||
209 | * |
||
210 | * @param string|null $to |
||
211 | * @return $this |
||
212 | */ |
||
213 | 3 | public function setTo($to = null) |
|
218 | |||
219 | /** |
||
220 | * Get priority. |
||
221 | * |
||
222 | * @return integer |
||
223 | */ |
||
224 | 3 | public function getPriority() |
|
228 | |||
229 | /** |
||
230 | * Set priority. |
||
231 | * |
||
232 | * @param integer $priority |
||
233 | * @return $this |
||
234 | */ |
||
235 | 3 | public function setPriority($priority) |
|
240 | |||
241 | /** |
||
242 | * Get channel password. |
||
243 | * |
||
244 | * @return string¦null |
||
245 | */ |
||
246 | public function getPassword() |
||
250 | |||
251 | /** |
||
252 | * Set channel password. |
||
253 | * |
||
254 | * @param string|null $to |
||
|
|||
255 | * @return $this |
||
256 | */ |
||
257 | public function setPassword($password = null) |
||
262 | } |
||
263 |
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.