This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of Smsa WebService package. |
||
5 | * (c) Hamoud Alhoqbani <[email protected]> |
||
6 | * For the full copyright and license information, please view the LICENSE |
||
7 | * file that was distributed with this source code. |
||
8 | */ |
||
9 | |||
10 | namespace Alhoqbani\SmsaWebService\Models; |
||
11 | |||
12 | use Alhoqbani\SmsaWebService\Soap\Type\AddShip; |
||
13 | use Alhoqbani\SmsaWebService\Soap\Type\AddShipment; |
||
14 | use WsdlToPhp\PackageBase\AbstractStructBase; |
||
15 | |||
16 | class Shipment |
||
17 | { |
||
18 | const TYPE_DLV = 'DLV'; |
||
19 | const TYPE_VAL = 'VAL'; |
||
20 | const TYPE_HAL = 'HAL'; |
||
21 | const TYPE_BLT = 'BLT'; |
||
22 | |||
23 | /** |
||
24 | * Unique Number for each day (Required). |
||
25 | * Cannot be Null |
||
26 | * Correspond to (refNo) |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | private $referenceNumber; |
||
31 | /** |
||
32 | * DLV for normal Shipments for other special cases we will provide. |
||
33 | * Mandatory Value from DLV,VAL,HAL or BLT |
||
34 | * Correspond to (shipType) |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | private $type; |
||
39 | /** |
||
40 | * No. of Pieces. |
||
41 | * Mandatory Integer |
||
42 | * Correspond to (PCs) |
||
43 | * |
||
44 | * @var int |
||
45 | */ |
||
46 | private $itemsCount = 1; |
||
47 | /** |
||
48 | * Weight of the Shipment |
||
49 | * It has to be numeric, but will be converted string. |
||
50 | * |
||
51 | * @var int |
||
52 | */ |
||
53 | private $weight = 0; |
||
54 | |||
55 | /** Optional Properties */ |
||
56 | |||
57 | /** |
||
58 | * Id. |
||
59 | * Optional |
||
60 | * Correspond to (idNo) |
||
61 | * |
||
62 | * @var string |
||
63 | */ |
||
64 | private $id; |
||
65 | /** |
||
66 | * Description of the items present in shipment. |
||
67 | * Optional |
||
68 | * Correspond to (itemDesc) |
||
69 | * |
||
70 | * @var string |
||
71 | */ |
||
72 | private $description; |
||
73 | /** |
||
74 | * Shipment Sent Date. |
||
75 | * Optional |
||
76 | * |
||
77 | * @var string |
||
78 | */ |
||
79 | private $sentDate; |
||
80 | |||
81 | /** Value Properties */ |
||
82 | |||
83 | /** |
||
84 | * Value Either 0 or greater than 0 in case of COD. |
||
85 | * Required if CASH ON DELIVERY |
||
86 | * Correspond to (codAmt) |
||
87 | * |
||
88 | * @var int |
||
89 | */ |
||
90 | private $cashOnDelivery = 0; |
||
91 | |||
92 | /** |
||
93 | * A default currency for value, insurance and customs . |
||
94 | * |
||
95 | * This value will be used when either of value, insurance or customs are set without specifying specific currency. |
||
96 | * |
||
97 | * @var string |
||
98 | */ |
||
99 | private $defaultCurrency; |
||
100 | /** |
||
101 | * Carriage Value. |
||
102 | * Optional |
||
103 | * Correspond to (carrValue) |
||
104 | * |
||
105 | * @var string |
||
106 | */ |
||
107 | private $value; |
||
108 | /** |
||
109 | * Carriage Currency. |
||
110 | * Optional |
||
111 | * Correspond to (carrCurr) |
||
112 | * |
||
113 | * @var string |
||
114 | */ |
||
115 | private $valueCurrency; |
||
116 | /** |
||
117 | * Customs Value. |
||
118 | * Optional |
||
119 | * Correspond to (custVal) |
||
120 | * |
||
121 | * @var string |
||
122 | */ |
||
123 | private $customs; |
||
124 | /** |
||
125 | * Customs Currency. |
||
126 | * Optional |
||
127 | * Correspond to (custCurr) |
||
128 | * |
||
129 | * @var string |
||
130 | */ |
||
131 | private $customsCurrency; |
||
132 | /** |
||
133 | * Insurance Value. |
||
134 | * Optional |
||
135 | * Correspond to (insrAmt) |
||
136 | * |
||
137 | * @var string |
||
138 | */ |
||
139 | private $insurance; |
||
140 | /** |
||
141 | * Insurance Currency. |
||
142 | * Optional |
||
143 | * Correspond to (insrCurr) |
||
144 | * |
||
145 | * @var string |
||
146 | */ |
||
147 | private $insuranceCurrency; |
||
148 | |||
149 | /** |
||
150 | * Preferred Delivery date in case of future or delayed delivery. |
||
151 | * Optional |
||
152 | * Correspond to (prefDelvDate) |
||
153 | * |
||
154 | * @var string |
||
155 | */ |
||
156 | private $deliveryDate; |
||
157 | /** |
||
158 | * Google GPS points separated by comma for delivery to customer by Google maps |
||
159 | * Optional |
||
160 | * |
||
161 | * @var string |
||
162 | */ |
||
163 | private $gpsPoints; |
||
164 | |||
165 | /** Related Objects */ |
||
166 | |||
167 | /** |
||
168 | * Customer associated with the shipment. |
||
169 | * |
||
170 | * @var \Alhoqbani\SmsaWebService\Models\Customer |
||
171 | */ |
||
172 | private $customer; |
||
173 | /** |
||
174 | * Shipper associated with the shipment. |
||
175 | * |
||
176 | * @var \Alhoqbani\SmsaWebService\Models\Shipper |
||
177 | */ |
||
178 | private $shipper; |
||
179 | |||
180 | /** |
||
181 | * Shipment constructor. |
||
182 | * |
||
183 | * @param string $referenceNumber |
||
184 | * @param \Alhoqbani\SmsaWebService\Models\Customer $customer |
||
185 | * @param string $type |
||
186 | */ |
||
187 | public function __construct( |
||
188 | string $referenceNumber, |
||
189 | Customer $customer, |
||
190 | string $type = self::TYPE_DLV |
||
191 | ) { |
||
192 | $this->referenceNumber = $referenceNumber; |
||
193 | $this->customer = $customer; |
||
194 | $this->type = $type; |
||
195 | } |
||
196 | |||
197 | public function getTypeObject(string $passKey): AbstractStructBase |
||
198 | { |
||
199 | $shipmentObject = $this->createShipmentObject(); |
||
200 | |||
201 | // We set the properties that are available in all Shipments types. |
||
202 | $shipmentObject |
||
203 | // Mandatory fields |
||
204 | ->setPassKey($passKey) |
||
205 | ->setRefNo($this->referenceNumber) |
||
206 | ->setPCs($this->itemsCount) |
||
207 | ->setShipType($this->type) |
||
208 | ->setWeight((string) $this->weight)// Must be string intval |
||
209 | |||
210 | // Optional |
||
211 | ->setSentDate($this->sentDate ?? '') |
||
212 | ->setIdNo($this->id ?? '') |
||
213 | ->setItemDesc($this->description ?? '') |
||
214 | // Values |
||
215 | // Cash on delivery must be >= 0 and must be a string. |
||
216 | ->setCodAmt((string) $this->cashOnDelivery) |
||
217 | // Set the values and currencies only when they are provided. |
||
218 | // This code is hard to read. Should be refactored !! |
||
219 | ->setCarrValue($this->value ?? '') |
||
220 | ->setCarrCurr(!is_null($this->value) ? $this->valueCurrency ?? $this->defaultCurrency ?? '' : $this->valueCurrency ?? '') |
||
221 | ->setCustVal($this->customs ?? '') |
||
222 | ->setCustCurr(!is_null($this->customs) ? $this->customsCurrency ?? $this->defaultCurrency ?? '' : $this->customsCurrency ?? '') |
||
223 | ->setInsrAmt($this->insurance ?? '') |
||
224 | ->setInsrCurr(!is_null($this->insurance) ? $this->insuranceCurrency ?? $this->defaultCurrency ?? '' : $this->insuranceCurrency ?? ''); |
||
225 | |||
226 | $shipmentObject = $this->customer->prepareForShipment($shipmentObject); |
||
227 | |||
228 | // If the shipment has a shipper, then we have extra parameters to assign to the request. |
||
229 | if ($this->hasShipper() && method_exists($shipmentObject, 'setPrefDelvDate')) { |
||
230 | $shipmentObject = $this->shipper->prepareForShipment($shipmentObject); |
||
231 | $shipmentObject->setPrefDelvDate($this->deliveryDate ?? ''); |
||
0 ignored issues
–
show
|
|||
232 | $shipmentObject->setGpsPoints($this->gpsPoints ?? ''); |
||
0 ignored issues
–
show
The method
setGpsPoints does only exist in Alhoqbani\SmsaWebService\Soap\Type\AddShip , but not in Alhoqbani\SmsaWebService\Soap\Type\AddShipment .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
233 | } |
||
234 | |||
235 | return $shipmentObject; |
||
236 | } |
||
237 | |||
238 | /** |
||
239 | * Determines the SOAP type and method used to create the shipment |
||
240 | * |
||
241 | * @return string |
||
242 | */ |
||
243 | public function getServiceMethod(): string |
||
244 | { |
||
245 | // If we don't have a shipper, we want to create a shipment without shipper. |
||
246 | return $this->hasShipper() ? 'addShip' : 'addShipment'; |
||
247 | } |
||
248 | |||
249 | /** |
||
250 | * Create an instance of the shipment type. |
||
251 | * |
||
252 | * If we have a shipper, we create an instance of (AddShip), otherwise (AddShipment) |
||
253 | * |
||
254 | * @return AddShip|AddShipment |
||
255 | */ |
||
256 | private function createShipmentObject() |
||
257 | { |
||
258 | switch ($this->getServiceMethod()) { |
||
259 | case 'addShip': |
||
0 ignored issues
–
show
case statements should be defined using a colon.
As per the PSR-2 coding standard, case statements should not be wrapped in curly braces.
There is no need for braces, since each case is terminated by the next There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages. switch ($expr) {
case "A": { //wrong
doSomething();
break;
}
case "B"; //wrong
doSomething();
break;
case "C": //right
doSomething();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
260 | return new AddShip(); |
||
261 | case 'addShipment': |
||
0 ignored issues
–
show
case statements should be defined using a colon.
As per the PSR-2 coding standard, case statements should not be wrapped in curly braces.
There is no need for braces, since each case is terminated by the next There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages. switch ($expr) {
case "A": { //wrong
doSomething();
break;
}
case "B"; //wrong
doSomething();
break;
case "C": //right
doSomething();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
262 | return new AddShipment(); |
||
263 | } |
||
264 | } |
||
265 | |||
266 | /** |
||
267 | * Check if we have a shipper to attach to the shipment |
||
268 | * |
||
269 | * @return bool |
||
270 | */ |
||
271 | private function hasShipper() |
||
272 | { |
||
273 | return !is_null($this->shipper); |
||
274 | } |
||
275 | |||
276 | /** ************************************************************************************************************** |
||
277 | * Setters and Getters |
||
278 | * **************************************************************************************************************/ |
||
279 | |||
280 | /** |
||
281 | * @return string |
||
282 | */ |
||
283 | public function getReferenceNumber(): string |
||
284 | { |
||
285 | return $this->referenceNumber; |
||
286 | } |
||
287 | |||
288 | /** |
||
289 | * @param string $referenceNumber |
||
290 | * |
||
291 | * @return Shipment |
||
292 | */ |
||
293 | public function setReferenceNumber(string $referenceNumber): self |
||
294 | { |
||
295 | $this->referenceNumber = $referenceNumber; |
||
296 | |||
297 | return $this; |
||
298 | } |
||
299 | |||
300 | /** |
||
301 | * @return string |
||
302 | */ |
||
303 | public function getType(): string |
||
304 | { |
||
305 | return $this->type; |
||
306 | } |
||
307 | |||
308 | /** |
||
309 | * @param string $type |
||
310 | * |
||
311 | * @return Shipment |
||
312 | */ |
||
313 | public function setType(string $type): self |
||
314 | { |
||
315 | $this->type = $type; |
||
316 | |||
317 | return $this; |
||
318 | } |
||
319 | |||
320 | /** |
||
321 | * @return int |
||
322 | */ |
||
323 | public function getItemsCount(): int |
||
324 | { |
||
325 | return $this->itemsCount; |
||
326 | } |
||
327 | |||
328 | /** |
||
329 | * @param int $itemsCount |
||
330 | * |
||
331 | * @return Shipment |
||
332 | */ |
||
333 | public function setItemsCount(int $itemsCount): self |
||
334 | { |
||
335 | $this->itemsCount = $itemsCount; |
||
336 | |||
337 | return $this; |
||
338 | } |
||
339 | |||
340 | /** |
||
341 | * @return int |
||
342 | */ |
||
343 | public function getWeight(): int |
||
344 | { |
||
345 | return $this->weight; |
||
346 | } |
||
347 | |||
348 | /** |
||
349 | * @param int $weight |
||
350 | * |
||
351 | * @return Shipment |
||
352 | */ |
||
353 | public function setWeight(int $weight): self |
||
354 | { |
||
355 | $this->weight = $weight; |
||
356 | |||
357 | return $this; |
||
358 | } |
||
359 | |||
360 | /** |
||
361 | * @return string |
||
362 | */ |
||
363 | public function getId() |
||
364 | { |
||
365 | return $this->id; |
||
366 | } |
||
367 | |||
368 | /** |
||
369 | * @param string $id |
||
370 | * |
||
371 | * @return Shipment |
||
372 | */ |
||
373 | public function setId(string $id): self |
||
374 | { |
||
375 | $this->id = $id; |
||
376 | |||
377 | return $this; |
||
378 | } |
||
379 | |||
380 | /** |
||
381 | * @return string |
||
382 | */ |
||
383 | public function getDescription() |
||
384 | { |
||
385 | return $this->description; |
||
386 | } |
||
387 | |||
388 | /** |
||
389 | * @param string $description |
||
390 | * |
||
391 | * @return Shipment |
||
392 | */ |
||
393 | public function setDescription(string $description): self |
||
394 | { |
||
395 | $this->description = $description; |
||
396 | |||
397 | return $this; |
||
398 | } |
||
399 | |||
400 | /** |
||
401 | * @return string |
||
402 | */ |
||
403 | public function getSentDate() |
||
404 | { |
||
405 | return $this->sentDate; |
||
406 | } |
||
407 | |||
408 | /** |
||
409 | * @param string $sentDate |
||
410 | * |
||
411 | * @return Shipment |
||
412 | */ |
||
413 | public function setSentDate(string $sentDate): self |
||
414 | { |
||
415 | $this->sentDate = $sentDate; |
||
416 | |||
417 | return $this; |
||
418 | } |
||
419 | |||
420 | /** |
||
421 | * @return int |
||
422 | */ |
||
423 | public function getCashOnDelivery() |
||
424 | { |
||
425 | return $this->cashOnDelivery; |
||
426 | } |
||
427 | |||
428 | /** |
||
429 | * @param int $cashOnDelivery |
||
430 | * |
||
431 | * @return Shipment |
||
432 | */ |
||
433 | public function setCashOnDelivery(int $cashOnDelivery): self |
||
434 | { |
||
435 | $this->cashOnDelivery = $cashOnDelivery; |
||
436 | |||
437 | return $this; |
||
438 | } |
||
439 | |||
440 | /** |
||
441 | * @return string |
||
442 | */ |
||
443 | public function getDefaultCurrency() |
||
444 | { |
||
445 | return $this->defaultCurrency; |
||
446 | } |
||
447 | |||
448 | /** |
||
449 | * @param string $defaultCurrency |
||
450 | * |
||
451 | * @return Shipment |
||
452 | */ |
||
453 | public function setDefaultCurrency(string $defaultCurrency): self |
||
454 | { |
||
455 | $this->defaultCurrency = $defaultCurrency; |
||
456 | |||
457 | return $this; |
||
458 | } |
||
459 | |||
460 | /** |
||
461 | * @return string |
||
462 | */ |
||
463 | public function getValue() |
||
464 | { |
||
465 | return $this->value; |
||
466 | } |
||
467 | |||
468 | /** |
||
469 | * @param string $value |
||
470 | * |
||
471 | * @return Shipment |
||
472 | */ |
||
473 | public function setValue(string $value): self |
||
474 | { |
||
475 | $this->value = $value; |
||
476 | |||
477 | return $this; |
||
478 | } |
||
479 | |||
480 | /** |
||
481 | * @return string |
||
482 | */ |
||
483 | public function getValueCurrency() |
||
484 | { |
||
485 | return $this->valueCurrency; |
||
486 | } |
||
487 | |||
488 | /** |
||
489 | * @param string $valueCurrency |
||
490 | * |
||
491 | * @return Shipment |
||
492 | */ |
||
493 | public function setValueCurrency(string $valueCurrency): self |
||
494 | { |
||
495 | $this->valueCurrency = $valueCurrency; |
||
496 | |||
497 | return $this; |
||
498 | } |
||
499 | |||
500 | /** |
||
501 | * @return string |
||
502 | */ |
||
503 | public function getCustoms() |
||
504 | { |
||
505 | return $this->customs; |
||
506 | } |
||
507 | |||
508 | /** |
||
509 | * @param string $customs |
||
510 | * |
||
511 | * @return Shipment |
||
512 | */ |
||
513 | public function setCustoms(string $customs): self |
||
514 | { |
||
515 | $this->customs = $customs; |
||
516 | |||
517 | return $this; |
||
518 | } |
||
519 | |||
520 | /** |
||
521 | * @return string |
||
522 | */ |
||
523 | public function getCustomsCurrency() |
||
524 | { |
||
525 | return $this->customsCurrency; |
||
526 | } |
||
527 | |||
528 | /** |
||
529 | * @param string $customsCurrency |
||
530 | * |
||
531 | * @return Shipment |
||
532 | */ |
||
533 | public function setCustomsCurrency(string $customsCurrency): self |
||
534 | { |
||
535 | $this->customsCurrency = $customsCurrency; |
||
536 | |||
537 | return $this; |
||
538 | } |
||
539 | |||
540 | /** |
||
541 | * @return string |
||
542 | */ |
||
543 | public function getInsurance() |
||
544 | { |
||
545 | return $this->insurance; |
||
546 | } |
||
547 | |||
548 | /** |
||
549 | * @param string $insurance |
||
550 | * |
||
551 | * @return Shipment |
||
552 | */ |
||
553 | public function setInsurance(string $insurance): self |
||
554 | { |
||
555 | $this->insurance = $insurance; |
||
556 | |||
557 | return $this; |
||
558 | } |
||
559 | |||
560 | /** |
||
561 | * @return string |
||
562 | */ |
||
563 | public function getInsuranceCurrency() |
||
564 | { |
||
565 | return $this->insuranceCurrency; |
||
566 | } |
||
567 | |||
568 | /** |
||
569 | * @param string $insuranceCurrency |
||
570 | * |
||
571 | * @return Shipment |
||
572 | */ |
||
573 | public function setInsuranceCurrency(string $insuranceCurrency): self |
||
574 | { |
||
575 | $this->insuranceCurrency = $insuranceCurrency; |
||
576 | |||
577 | return $this; |
||
578 | } |
||
579 | |||
580 | /** |
||
581 | * @return string |
||
582 | */ |
||
583 | public function getDeliveryDate() |
||
584 | { |
||
585 | return $this->deliveryDate; |
||
586 | } |
||
587 | |||
588 | /** |
||
589 | * @param string $deliveryDate |
||
590 | * |
||
591 | * @return Shipment |
||
592 | */ |
||
593 | public function setDeliveryDate(string $deliveryDate): self |
||
594 | { |
||
595 | $this->deliveryDate = $deliveryDate; |
||
596 | |||
597 | return $this; |
||
598 | } |
||
599 | |||
600 | /** |
||
601 | * @return string |
||
602 | */ |
||
603 | public function getGpsPoints() |
||
604 | { |
||
605 | return $this->gpsPoints; |
||
606 | } |
||
607 | |||
608 | /** |
||
609 | * @param string $gpsPoints |
||
610 | * |
||
611 | * @return Shipment |
||
612 | */ |
||
613 | public function setGpsPoints(string $gpsPoints): self |
||
614 | { |
||
615 | $this->gpsPoints = $gpsPoints; |
||
616 | |||
617 | return $this; |
||
618 | } |
||
619 | |||
620 | /** |
||
621 | * @return Customer |
||
622 | */ |
||
623 | public function getCustomer(): Customer |
||
624 | { |
||
625 | return $this->customer; |
||
626 | } |
||
627 | |||
628 | /** |
||
629 | * @param Customer $customer |
||
630 | * |
||
631 | * @return Shipment |
||
632 | */ |
||
633 | public function setCustomer(Customer $customer): self |
||
634 | { |
||
635 | $this->customer = $customer; |
||
636 | |||
637 | return $this; |
||
638 | } |
||
639 | |||
640 | /** |
||
641 | * @return Shipper |
||
642 | */ |
||
643 | public function getShipper() |
||
644 | { |
||
645 | return $this->shipper; |
||
646 | } |
||
647 | |||
648 | /** |
||
649 | * @param Shipper $shipper |
||
650 | * |
||
651 | * @return Shipment |
||
652 | */ |
||
653 | public function setShipper(Shipper $shipper): self |
||
654 | { |
||
655 | $this->shipper = $shipper; |
||
656 | |||
657 | return $this; |
||
658 | } |
||
659 | } |
||
660 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: