for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PHPSC\PagSeguro\Client;
use GuzzleHttp\Client as HttpClient;
use GuzzleHttp\Exception\RequestException;
use SimpleXMLElement;
/**
* @author Luís Otávio Cobucci Oblonczyk <[email protected]>
* @author Paulo Peixoto Filho <[email protected]>
*/
class Client {
* @var HttpClient
private $client;
* @param HttpClient $client
public function __construct(HttpClient $client = null) {
$this->client = $client ?: new HttpClient();
}
* @param string $url
* @param SimpleXMLElement $body
*
* @return SimpleXMLElement
public function post($url, SimpleXMLElement $body) {
try {
$response = $this->client->post($url, ['headers' => ['Content-Type' => 'application/xml; charset=UTF-8'], 'body' => $body->asXML(), 'verify' => false]);
} catch (RequestException $e) {
throw PagSeguroException::create($e->getResponse());
$e->getResponse()
object<Psr\Http\Message\ResponseInterface>
object<GuzzleHttp\Message\Response>
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
return new SimpleXMLElement((string) $response->getBody());
public function get($url) {
$response = $this->client->get($url, ['verify' => false]);
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: