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 | * Slince shipment tracker library |
||
| 4 | * @author Tao <[email protected]> |
||
| 5 | */ |
||
| 6 | namespace Slince\ShipmentTracking\Foundation; |
||
| 7 | |||
| 8 | use Slince\ShipmentTracking\Foundation\Location\LocationInterface; |
||
| 9 | |||
| 10 | class ShipmentEvent implements \JsonSerializable |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var \DateTime |
||
| 14 | * @deprecated |
||
| 15 | */ |
||
| 16 | protected $date; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var string |
||
| 20 | */ |
||
| 21 | protected $description; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var string|LocationInterface |
||
| 25 | */ |
||
| 26 | protected $location; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @var string |
||
| 30 | */ |
||
| 31 | protected $status; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @var \DateTime |
||
| 35 | */ |
||
| 36 | protected $time; |
||
| 37 | |||
| 38 | public function __construct(\DateTime $time = null, $description = null, $location = null) |
||
| 39 | { |
||
| 40 | $this->setTime($time); |
||
|
0 ignored issues
–
show
|
|||
| 41 | $this->description = $description; |
||
| 42 | $this->location = $location; |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @return \DateTime |
||
| 47 | * @deprecated |
||
| 48 | */ |
||
| 49 | public function getDate() |
||
| 50 | { |
||
| 51 | return $this->date; |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @param \DateTime $date |
||
| 56 | * @return ShipmentEvent |
||
| 57 | * @deprecated |
||
| 58 | */ |
||
| 59 | public function setDate($date) |
||
| 60 | { |
||
| 61 | if (!$date instanceof \DateTime) { |
||
| 62 | $date = new \DateTime($date); |
||
| 63 | } |
||
| 64 | $this->setTime($date); |
||
| 65 | return $this; |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @return \DateTime |
||
| 70 | */ |
||
| 71 | public function getTime() |
||
| 72 | { |
||
| 73 | return $this->time; |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @param \DateTime $time |
||
| 78 | * @return ShipmentEvent |
||
| 79 | */ |
||
| 80 | public function setTime($time) |
||
| 81 | { |
||
| 82 | $this->time = $time; |
||
| 83 | if ($time) { |
||
| 84 | $this->date = $time->format('Y-m-d H:i:s'); |
||
|
0 ignored issues
–
show
It seems like
$time->format('Y-m-d H:i:s') of type string is incompatible with the declared type object<DateTime> of property $date.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||
| 85 | } |
||
| 86 | return $this; |
||
| 87 | } |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @return string |
||
| 91 | */ |
||
| 92 | public function getDescription() |
||
| 93 | { |
||
| 94 | return $this->description; |
||
| 95 | } |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @param string $description |
||
| 99 | * @return ShipmentEvent |
||
| 100 | */ |
||
| 101 | public function setDescription($description) |
||
| 102 | { |
||
| 103 | $this->description = $description; |
||
| 104 | return $this; |
||
| 105 | } |
||
| 106 | |||
| 107 | /** |
||
| 108 | * @return string|LocationInterface |
||
| 109 | */ |
||
| 110 | public function getLocation() |
||
| 111 | { |
||
| 112 | return $this->location; |
||
| 113 | } |
||
| 114 | |||
| 115 | /** |
||
| 116 | * @param string|LocationInterface $location |
||
| 117 | * @return ShipmentEvent |
||
| 118 | */ |
||
| 119 | public function setLocation($location) |
||
| 120 | { |
||
| 121 | $this->location = $location; |
||
| 122 | return $this; |
||
| 123 | } |
||
| 124 | |||
| 125 | /** |
||
| 126 | * @return string |
||
| 127 | */ |
||
| 128 | public function getStatus() |
||
| 129 | { |
||
| 130 | return $this->status; |
||
| 131 | } |
||
| 132 | |||
| 133 | /** |
||
| 134 | * @param string $status |
||
| 135 | * @return ShipmentEvent |
||
| 136 | */ |
||
| 137 | public function setStatus($status) |
||
| 138 | { |
||
| 139 | $this->status = $status; |
||
| 140 | return $this; |
||
| 141 | } |
||
| 142 | |||
| 143 | /** |
||
| 144 | * Creates an event from an array |
||
| 145 | * @param array $data |
||
| 146 | * @return static |
||
| 147 | */ |
||
| 148 | public static function fromArray($data) |
||
| 149 | { |
||
| 150 | $event = new static(); |
||
| 151 | foreach ($data as $property => $value) { |
||
| 152 | if (method_exists($event, $method = 'set' . ucfirst($property))) { |
||
| 153 | $event->$method($value); |
||
| 154 | } |
||
| 155 | } |
||
| 156 | return $event; |
||
| 157 | } |
||
| 158 | |||
| 159 | /** |
||
| 160 | * Converts the event to array |
||
| 161 | * @return array |
||
| 162 | */ |
||
| 163 | public function toArray() |
||
| 164 | { |
||
| 165 | $methods = get_class_methods($this); |
||
| 166 | $data = []; |
||
| 167 | foreach ($methods as $method) { |
||
| 168 | if (substr($method, 0, 3) == 'get') { |
||
| 169 | $property = lcfirst(substr($method, 3)); |
||
| 170 | $data[$property] = $this->$method(); |
||
| 171 | } elseif (substr($method, 0, 2) == 'is') { |
||
| 172 | $property = lcfirst(substr($method, 2)); |
||
| 173 | $data[$property] = $this->$method(); |
||
| 174 | } |
||
| 175 | } |
||
| 176 | return $data; |
||
| 177 | } |
||
| 178 | |||
| 179 | /** |
||
| 180 | * {@inheritdoc} |
||
| 181 | */ |
||
| 182 | public function jsonSerialize() |
||
| 183 | { |
||
| 184 | return $this->toArray(); |
||
| 185 | } |
||
| 186 | } |
||
| 187 |
It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.
We recommend to add an additional type check (or disallow null for the parameter):