PatronBase /
omnipay-gocardless
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Omnipay\GoCardless\Message; |
||
| 4 | |||
| 5 | /** |
||
| 6 | * Fetch the details of a specific event (webhook notification) from GoCardless |
||
| 7 | * |
||
| 8 | * @see https://developer.gocardless.com/api-reference/#events-get-a-single-event |
||
| 9 | */ |
||
| 10 | class FetchEventRequest extends AbstractRequest |
||
| 11 | { |
||
| 12 | public function getEventId() |
||
| 13 | { |
||
| 14 | return $this->getParameter('eventId'); |
||
| 15 | } |
||
| 16 | |||
| 17 | public function setEventId($value) |
||
| 18 | { |
||
| 19 | return $this->setParameter('eventId', $value); |
||
| 20 | } |
||
| 21 | |||
| 22 | public function getData() |
||
| 23 | { |
||
| 24 | $this->validate('eventId'); |
||
| 25 | $this->action = '/events/'.$this->getEventId(); |
||
| 26 | return null; |
||
| 27 | } |
||
| 28 | |||
| 29 | public function sendData($data) |
||
| 30 | { |
||
| 31 | $response = $this->sendRequest($data, 'GET'); |
||
| 32 | $json = json_decode($response->getBody()->getContents(), true); |
||
| 33 | // if there's an event, retrieve the details, otherwise pass through the error |
||
| 34 | $notification = isset($json['events']) ? $json['events'] : $json; |
||
| 35 | |||
| 36 | $this->response = new WebhookEventNotification($this->httpClient, $this->httpRequest); |
||
|
0 ignored issues
–
show
|
|||
| 37 | $this->response->initialize(array_replace($this->getParameters(), ['notification' => $notification])); |
||
| 38 | |||
| 39 | return $this->response; |
||
|
0 ignored issues
–
show
The expression
return $this->response returns the type Omnipay\GoCardless\Messa...ebhookEventNotification which is incompatible with the return type mandated by Omnipay\Common\Message\R...stInterface::sendData() of Omnipay\Common\Message\ResponseInterface.
In the issue above, the returned value is violating the contract defined by the mentioned interface. Let's take a look at an example: interface HasName {
/** @return string */
public function getName();
}
class Name {
public $name;
}
class User implements HasName {
/** @return string|Name */
public function getName() {
return new Name('foo'); // This is a violation of the ``HasName`` interface
// which only allows a string value to be returned.
}
}
Loading history...
|
|||
| 40 | } |
||
| 41 | } |
||
| 42 |
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..