From 3a08836e027595f99c008dc9b1576d64f51ac0ea Mon Sep 17 00:00:00 2001 From: Emanuele Minotto Date: Tue, 27 Oct 2015 22:17:41 +0100 Subject: [PATCH 1/2] single internal type for response headers --- src/Facebook/HttpClients/FacebookStream.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Facebook/HttpClients/FacebookStream.php b/src/Facebook/HttpClients/FacebookStream.php index 95aa22e7a..1ec7177dc 100644 --- a/src/Facebook/HttpClients/FacebookStream.php +++ b/src/Facebook/HttpClients/FacebookStream.php @@ -41,7 +41,7 @@ class FacebookStream /** * @var array Response headers from the stream wrapper */ - protected $responseHeaders; + protected $responseHeaders = []; /** * Make a new context stream reference instance @@ -56,7 +56,7 @@ public function streamContextCreate(array $options) /** * The response headers from the stream wrapper * - * @return array|null + * @return array */ public function getResponseHeaders() { @@ -73,7 +73,7 @@ public function getResponseHeaders() public function fileGetContents($url) { $rawResponse = file_get_contents($url, false, $this->stream); - $this->responseHeaders = $http_response_header; + $this->responseHeaders = $http_response_header ?: []; return $rawResponse; } From d4ae9ff4f6a50f91910821edbea1fc055f0a33cb Mon Sep 17 00:00:00 2001 From: Emanuele Minotto Date: Tue, 27 Oct 2015 22:18:13 +0100 Subject: [PATCH 2/2] use the empty function instead of implicit casting --- src/Facebook/HttpClients/FacebookStreamHttpClient.php | 2 +- src/Facebook/Url/FacebookUrlManipulator.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Facebook/HttpClients/FacebookStreamHttpClient.php b/src/Facebook/HttpClients/FacebookStreamHttpClient.php index b15751431..b88a6625a 100644 --- a/src/Facebook/HttpClients/FacebookStreamHttpClient.php +++ b/src/Facebook/HttpClients/FacebookStreamHttpClient.php @@ -66,7 +66,7 @@ public function send($url, $method, $body, array $headers, $timeOut) $rawBody = $this->facebookStream->fileGetContents($url); $rawHeaders = $this->facebookStream->getResponseHeaders(); - if ($rawBody === false || !$rawHeaders) { + if ($rawBody === false || empty($rawHeaders)) { throw new FacebookSDKException('Stream returned an empty response', 660); } diff --git a/src/Facebook/Url/FacebookUrlManipulator.php b/src/Facebook/Url/FacebookUrlManipulator.php index 20a0299e0..2e540956e 100644 --- a/src/Facebook/Url/FacebookUrlManipulator.php +++ b/src/Facebook/Url/FacebookUrlManipulator.php @@ -76,7 +76,7 @@ public static function removeParamsFromUrl($url, array $paramsToFilter) */ public static function appendParamsToUrl($url, array $newParams = []) { - if (!$newParams) { + if (empty($newParams)) { return $url; }