@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | * |
185 | 185 | * @param string $url The URL to call. |
186 | 186 | * @param string $body The data to pass. |
187 | - * @param array $headers The headers to pass. |
|
187 | + * @param string[] $headers The headers to pass. |
|
188 | 188 | * @param string $method The HTTP-method to use. |
189 | 189 | * @param bool $expectXML Do we expect XML? |
190 | - * @return mixed |
|
190 | + * @return \SimpleXMLElement |
|
191 | 191 | * @throws BpostCurlException |
192 | 192 | * @throws BpostInvalidResponseException |
193 | 193 | * @throws BpostInvalidSelectionException |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | /** |
510 | 510 | * Get the possible label formats |
511 | 511 | * |
512 | - * @return array |
|
512 | + * @return string[] |
|
513 | 513 | */ |
514 | 514 | public static function getPossibleLabelFormatValues() |
515 | 515 | { |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function __construct($accountId, $passPhrase, $apiUrl = self::API_URL) |
100 | 100 | { |
101 | - $this->accountId = (string)$accountId; |
|
102 | - $this->passPhrase = (string)$passPhrase; |
|
103 | - $this->apiUrl = (string)$apiUrl; |
|
101 | + $this->accountId = (string) $accountId; |
|
102 | + $this->passPhrase = (string) $passPhrase; |
|
103 | + $this->apiUrl = (string) $apiUrl; |
|
104 | 104 | $this->logger = new Logger(); |
105 | 105 | } |
106 | 106 | |
@@ -141,17 +141,17 @@ discard block |
||
141 | 141 | |
142 | 142 | /** @var \SimpleXMLElement $value */ |
143 | 143 | foreach ($item as $key => $value) { |
144 | - $attributes = (array)$value->attributes(); |
|
144 | + $attributes = (array) $value->attributes(); |
|
145 | 145 | |
146 | 146 | if (!empty($attributes) && isset($attributes['@attributes'])) { |
147 | 147 | $return[$key]['@attributes'] = $attributes['@attributes']; |
148 | 148 | } |
149 | 149 | |
150 | 150 | // empty |
151 | - if (isset($value['nil']) && (string)$value['nil'] === 'true') { |
|
151 | + if (isset($value['nil']) && (string) $value['nil'] === 'true') { |
|
152 | 152 | $return[$key] = null; |
153 | 153 | } // empty |
154 | - elseif (isset($value[0]) && (string)$value == '') { |
|
154 | + elseif (isset($value[0]) && (string) $value == '') { |
|
155 | 155 | if (in_array($key, $arrayKeys)) { |
156 | 156 | $return[$key][] = self::decodeResponse($value); |
157 | 157 | } else { |
@@ -160,18 +160,18 @@ discard block |
||
160 | 160 | } else { |
161 | 161 | // arrays |
162 | 162 | if (in_array($key, $arrayKeys)) { |
163 | - $return[$key][] = (string)$value; |
|
163 | + $return[$key][] = (string) $value; |
|
164 | 164 | } // booleans |
165 | - elseif ((string)$value == 'true') { |
|
165 | + elseif ((string) $value == 'true') { |
|
166 | 166 | $return[$key] = true; |
167 | - } elseif ((string)$value == 'false') { |
|
167 | + } elseif ((string) $value == 'false') { |
|
168 | 168 | $return[$key] = false; |
169 | 169 | } // integers |
170 | 170 | elseif (in_array($key, $integerKeys)) { |
171 | - $return[$key] = (int)$value; |
|
171 | + $return[$key] = (int) $value; |
|
172 | 172 | } // fallback to string |
173 | 173 | else { |
174 | - $return[$key] = (string)$value; |
|
174 | + $return[$key] = (string) $value; |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | } |
205 | 205 | $options[CURLOPT_USERAGENT] = $this->getUserAgent(); |
206 | 206 | $options[CURLOPT_RETURNTRANSFER] = true; |
207 | - $options[CURLOPT_TIMEOUT] = (int)$this->getTimeOut(); |
|
207 | + $options[CURLOPT_TIMEOUT] = (int) $this->getTimeOut(); |
|
208 | 208 | $options[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1; |
209 | 209 | $options[CURLOPT_HTTPHEADER] = $headers; |
210 | 210 | |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | if ($xml !== false && (substr($xml->getName(), 0, 7) == 'invalid') |
250 | 250 | ) { |
251 | 251 | // message |
252 | - $message = (string)$xml->error; |
|
253 | - $code = isset($xml->code) ? (int)$xml->code : null; |
|
252 | + $message = (string) $xml->error; |
|
253 | + $code = isset($xml->code) ? (int) $xml->code : null; |
|
254 | 254 | |
255 | 255 | // throw exception |
256 | 256 | throw new BpostInvalidSelectionException($message, $code); |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | */ |
317 | 317 | public function getPort() |
318 | 318 | { |
319 | - return (int)$this->port; |
|
319 | + return (int) $this->port; |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | /** |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | */ |
327 | 327 | public function getTimeOut() |
328 | 328 | { |
329 | - return (int)$this->timeOut; |
|
329 | + return (int) $this->timeOut; |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | */ |
339 | 339 | public function getUserAgent() |
340 | 340 | { |
341 | - return (string)'PHP Bpost/' . self::VERSION . ' ' . $this->userAgent; |
|
341 | + return (string) 'PHP Bpost/' . self::VERSION . ' ' . $this->userAgent; |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | */ |
350 | 350 | public function setTimeOut($seconds) |
351 | 351 | { |
352 | - $this->timeOut = (int)$seconds; |
|
352 | + $this->timeOut = (int) $seconds; |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | /** |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | */ |
361 | 361 | public function setUserAgent($userAgent) |
362 | 362 | { |
363 | - $this->userAgent = (string)$userAgent; |
|
363 | + $this->userAgent = (string) $userAgent; |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | // webservice methods |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | */ |
419 | 419 | public function fetchOrder($reference) |
420 | 420 | { |
421 | - $url = '/orders/' . (string)$reference; |
|
421 | + $url = '/orders/' . (string) $reference; |
|
422 | 422 | |
423 | 423 | $headers = array( |
424 | 424 | 'Accept: application/vnd.bpost.shm-order-v3.3+XML', |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | $withReturnLabels = false, |
585 | 585 | $asPdf = false |
586 | 586 | ) { |
587 | - $url = '/orders/' . (string)$reference; |
|
587 | + $url = '/orders/' . (string) $reference; |
|
588 | 588 | |
589 | 589 | return $this->getLabel($url, $format, $withReturnLabels, $asPdf); |
590 | 590 | } |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | $withReturnLabels = false, |
607 | 607 | $asPdf = false |
608 | 608 | ) { |
609 | - $url = '/boxes/' . (string)$barcode; |
|
609 | + $url = '/boxes/' . (string) $barcode; |
|
610 | 610 | |
611 | 611 | return $this->getLabel($url, $format, $withReturnLabels, $asPdf); |
612 | 612 | } |
@@ -173,7 +173,7 @@ |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
176 | - * @return array |
|
176 | + * @return string[] |
|
177 | 177 | */ |
178 | 178 | public static function getPossibleStatusValues() |
179 | 179 | { |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function setAdditionalCustomerReference($additionalCustomerReference) |
163 | 163 | { |
164 | - $this->additionalCustomerReference = (string)$additionalCustomerReference; |
|
164 | + $this->additionalCustomerReference = (string) $additionalCustomerReference; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | $box->setRemark((string) $xml->remark); |
326 | 326 | } |
327 | 327 | if (isset($xml->additionalCustomerReference) && $xml->additionalCustomerReference != '') { |
328 | - $box->setAdditionalCustomerReference((string)$xml->additionalCustomerReference); |
|
328 | + $box->setAdditionalCustomerReference((string) $xml->additionalCustomerReference); |
|
329 | 329 | } |
330 | 330 | if (!empty($xml->barcode)) { |
331 | 331 | $box->setBarcode((string) $xml->barcode); |
@@ -239,6 +239,9 @@ |
||
239 | 239 | } |
240 | 240 | } |
241 | 241 | |
242 | + /** |
|
243 | + * @param string|null $prefix |
|
244 | + */ |
|
242 | 245 | private function addToXmlShopHandlingInstruction(\DOMDocument $document, \DOMElement $typeElement, $prefix) |
243 | 246 | { |
244 | 247 | if ($this->getShopHandlingInstruction() !== null) { |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | |
262 | 262 | if (isset($xml->atBpost->product) && $xml->atBpost->product != '') { |
263 | 263 | $atBpost->setProduct( |
264 | - (string)$xml->atBpost->product |
|
264 | + (string) $xml->atBpost->product |
|
265 | 265 | ); |
266 | 266 | } |
267 | 267 | if (isset($xml->atBpost->options)) { |
@@ -296,27 +296,27 @@ discard block |
||
296 | 296 | } |
297 | 297 | if (isset($xml->atBpost->weight) && $xml->atBpost->weight != '') { |
298 | 298 | $atBpost->setWeight( |
299 | - (int)$xml->atBpost->weight |
|
299 | + (int) $xml->atBpost->weight |
|
300 | 300 | ); |
301 | 301 | } |
302 | 302 | if (isset($xml->atBpost->receiverName) && $xml->atBpost->receiverName != '') { |
303 | 303 | $atBpost->setReceiverName( |
304 | - (string)$xml->atBpost->receiverName |
|
304 | + (string) $xml->atBpost->receiverName |
|
305 | 305 | ); |
306 | 306 | } |
307 | 307 | if (isset($xml->atBpost->receiverCompany) && $xml->atBpost->receiverCompany != '') { |
308 | 308 | $atBpost->setReceiverCompany( |
309 | - (string)$xml->atBpost->receiverCompany |
|
309 | + (string) $xml->atBpost->receiverCompany |
|
310 | 310 | ); |
311 | 311 | } |
312 | 312 | if (isset($xml->atBpost->pugoId) && $xml->atBpost->pugoId != '') { |
313 | 313 | $atBpost->setPugoId( |
314 | - (string)$xml->atBpost->pugoId |
|
314 | + (string) $xml->atBpost->pugoId |
|
315 | 315 | ); |
316 | 316 | } |
317 | 317 | if (isset($xml->atBpost->pugoName) && $xml->atBpost->pugoName != '') { |
318 | 318 | $atBpost->setPugoName( |
319 | - (string)$xml->atBpost->pugoName |
|
319 | + (string) $xml->atBpost->pugoName |
|
320 | 320 | ); |
321 | 321 | } |
322 | 322 | if (isset($xml->atBpost->pugoAddress)) { |
@@ -330,12 +330,12 @@ discard block |
||
330 | 330 | } |
331 | 331 | if (isset($xml->atBpost->requestedDeliveryDate) && $xml->atBpost->requestedDeliveryDate != '') { |
332 | 332 | $atBpost->setRequestedDeliveryDate( |
333 | - (string)$xml->atBpost->requestedDeliveryDate |
|
333 | + (string) $xml->atBpost->requestedDeliveryDate |
|
334 | 334 | ); |
335 | 335 | } |
336 | 336 | if (isset($xml->atBpost->shopHandlingInstruction) && $xml->atBpost->shopHandlingInstruction != '') { |
337 | 337 | $atBpost->setShopHandlingInstruction( |
338 | - (string)$xml->atBpost->shopHandlingInstruction |
|
338 | + (string) $xml->atBpost->shopHandlingInstruction |
|
339 | 339 | ); |
340 | 340 | } |
341 | 341 |
@@ -24,7 +24,7 @@ |
||
24 | 24 | /** |
25 | 25 | * @todo Implement it, because today, nothing is specified |
26 | 26 | * @param \SimpleXMLElement $xml |
27 | - * @return ParcelLockerReducedMobilityZone|\Bpost\BpostApiClient\IComplexAttribute |
|
27 | + * @return ParcelLockerReducedMobilityZone |
|
28 | 28 | */ |
29 | 29 | static function createFromXml(\SimpleXMLElement $xml) |
30 | 30 | { |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
112 | - * @param array $closedFrom |
|
112 | + * @param string $closedFrom |
|
113 | 113 | */ |
114 | 114 | public function setClosedFrom($closedFrom) |
115 | 115 | { |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
128 | - * @param array $closedTo |
|
128 | + * @param string $closedTo |
|
129 | 129 | */ |
130 | 130 | public function setClosedTo($closedTo) |
131 | 131 | { |
@@ -162,15 +162,15 @@ |
||
162 | 162 | $self = new self(); |
163 | 163 | |
164 | 164 | if (isset($xml->language) && $xml->language != '') { |
165 | - $self->setLanguage((string)$xml->language); |
|
165 | + $self->setLanguage((string) $xml->language); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | if (isset($xml->mobilePhone) && $xml->mobilePhone != '') { |
169 | - $self->setMobilePhone((string)$xml->mobilePhone); |
|
169 | + $self->setMobilePhone((string) $xml->mobilePhone); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | if (isset($xml->emailAddress) && $xml->emailAddress != '') { |
173 | - $self->setEmailAddress((string)$xml->emailAddress); |
|
173 | + $self->setEmailAddress((string) $xml->emailAddress); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | if (isset($xml->parcelLockerReducedMobilityZone)) { |
@@ -80,7 +80,7 @@ |
||
80 | 80 | */ |
81 | 81 | public function setRequestedDeliveryDate($requestedDeliveryDate) |
82 | 82 | { |
83 | - $this->requestedDeliveryDate = (string)$requestedDeliveryDate; |
|
83 | + $this->requestedDeliveryDate = (string) $requestedDeliveryDate; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function setRequestedDeliveryDate($requestedDeliveryDate) |
195 | 195 | { |
196 | - $this->requestedDeliveryDate = (string)$requestedDeliveryDate; |
|
196 | + $this->requestedDeliveryDate = (string) $requestedDeliveryDate; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | |
307 | 307 | if (isset($xml->{'at24-7'}->product) && $xml->{'at24-7'}->product != '') { |
308 | 308 | $at247->setProduct( |
309 | - (string)$xml->{'at24-7'}->product |
|
309 | + (string) $xml->{'at24-7'}->product |
|
310 | 310 | ); |
311 | 311 | } |
312 | 312 | if (isset($xml->{'at24-7'}->options)) { |
@@ -332,32 +332,32 @@ discard block |
||
332 | 332 | } |
333 | 333 | if (isset($xml->{'at24-7'}->weight) && $xml->{'at24-7'}->weight != '') { |
334 | 334 | $at247->setWeight( |
335 | - (int)$xml->{'at24-7'}->weight |
|
335 | + (int) $xml->{'at24-7'}->weight |
|
336 | 336 | ); |
337 | 337 | } |
338 | 338 | if (isset($xml->{'at24-7'}->memberId) && $xml->{'at24-7'}->memberId != '') { |
339 | 339 | $at247->setMemberId( |
340 | - (string)$xml->{'at24-7'}->memberId |
|
340 | + (string) $xml->{'at24-7'}->memberId |
|
341 | 341 | ); |
342 | 342 | } |
343 | 343 | if (isset($xml->{'at24-7'}->receiverName) && $xml->{'at24-7'}->receiverName != '') { |
344 | 344 | $at247->setReceiverName( |
345 | - (string)$xml->{'at24-7'}->receiverName |
|
345 | + (string) $xml->{'at24-7'}->receiverName |
|
346 | 346 | ); |
347 | 347 | } |
348 | 348 | if (isset($xml->{'at24-7'}->receiverCompany) && $xml->{'at24-7'}->receiverCompany != '') { |
349 | 349 | $at247->setReceiverCompany( |
350 | - (string)$xml->{'at24-7'}->receiverCompany |
|
350 | + (string) $xml->{'at24-7'}->receiverCompany |
|
351 | 351 | ); |
352 | 352 | } |
353 | 353 | if (isset($xml->{'at24-7'}->parcelsDepotId) && $xml->{'at24-7'}->parcelsDepotId != '') { |
354 | 354 | $at247->setParcelsDepotId( |
355 | - (string)$xml->{'at24-7'}->parcelsDepotId |
|
355 | + (string) $xml->{'at24-7'}->parcelsDepotId |
|
356 | 356 | ); |
357 | 357 | } |
358 | 358 | if (isset($xml->{'at24-7'}->parcelsDepotName) && $xml->{'at24-7'}->parcelsDepotName != '') { |
359 | 359 | $at247->setParcelsDepotName( |
360 | - (string)$xml->{'at24-7'}->parcelsDepotName |
|
360 | + (string) $xml->{'at24-7'}->parcelsDepotName |
|
361 | 361 | ); |
362 | 362 | } |
363 | 363 | if (isset($xml->{'at24-7'}->parcelsDepotAddress)) { |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | } |
372 | 372 | if (isset($xml->{'at24-7'}->requestedDeliveryDate) && $xml->{'at24-7'}->requestedDeliveryDate != '') { |
373 | 373 | $at247->setRequestedDeliveryDate( |
374 | - (string)$xml->{'at24-7'}->requestedDeliveryDate |
|
374 | + (string) $xml->{'at24-7'}->requestedDeliveryDate |
|
375 | 375 | ); |
376 | 376 | } |
377 | 377 |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function setInNetworkCutOff($inNetworkCutOff) |
47 | 47 | { |
48 | - $this->inNetworkCutOff = (string)$inNetworkCutOff; |
|
48 | + $this->inNetworkCutOff = (string) $inNetworkCutOff; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | if (isset($bpostOnAppointmentXml->inNetworkCutOff) && $bpostOnAppointmentXml->inNetworkCutOff != '') { |
126 | 126 | $self->setInNetworkCutOff( |
127 | - (string)$bpostOnAppointmentXml->inNetworkCutOff |
|
127 | + (string) $bpostOnAppointmentXml->inNetworkCutOff |
|
128 | 128 | ); |
129 | 129 | } |
130 | 130 |