Skip to content

Support php81 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: 5.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Starting with version 5, the Facebook PHP SDK follows [SemVer](http://semver.org

Version 5 of the Facebook PHP SDK is a complete refactor of version 4. It comes loaded with lots of new features and a friendlier API.

- 5.9.0 (2022-01-20) Support php8.1
- 5.7.1 (2018-XX-XX)
- 5.7.0 (2018-12-12)
- Add `joined` to list of fields to be cast to `\DateTime` (#950)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}
],
"require": {
"php": "^5.4|^7.0"
"php": "^5.4|^7.0|^8.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Facebook/Authentication/OAuth2Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function getAuthorizationUrl($redirectUrl, $state, array $scope = [], arr
'scope' => implode(',', $scope)
];

return static::BASE_AUTHORIZATION_URL . '/' . $this->graphVersion . '/dialog/oauth?' . http_build_query($params, null, $separator);
return static::BASE_AUTHORIZATION_URL . '/' . $this->graphVersion . '/dialog/oauth?' . http_build_query($params, '', $separator);
}

/**
Expand Down
27 changes: 21 additions & 6 deletions src/Facebook/FacebookApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class FacebookApp implements \Serializable
public function __construct($id, $secret)
{
if (!is_string($id)
// Keeping this for BC. Integers greater than PHP_INT_MAX will make is_int() return false
&& !is_int($id)) {
// Keeping this for BC. Integers greater than PHP_INT_MAX will make is_int() return false
&& !is_int($id)) {
throw new FacebookSDKException('The "app_id" must be formatted as a string since many app ID\'s are greater than PHP_INT_MAX on some systems.');
}
// We cast as a string in case a valid int was set on a 64-bit system and this is unserialised on a 32-bit system
Expand Down Expand Up @@ -91,20 +91,35 @@ public function getAccessToken()
*
* @return string
*/
public function serialize()
public function serialize(): string
{
return implode('|', [$this->id, $this->secret]);
return implode('|', $this->__serialize());
}

/**
* Unserializes a string as a FacebookApp entity.
*
* @param string $serialized
*/
public function unserialize($serialized)
public function unserialize(string $serialized): void
{
list($id, $secret) = explode('|', $serialized);
$this->__unserialize(explode('|', $serialized));
}

/**
* @internal
*/
public function __serialize(): array
{
return [$this->id, $this->secret];
}

/**
* @internal
*/
public function __unserialize(array $data): void
{
list($id, $secret) = $data;
$this->__construct($id, $secret);
}
}
2 changes: 1 addition & 1 deletion src/Facebook/Http/RequestBodyMultipart.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private function getParamString($name, $value)
*/
private function getNestedParams(array $params)
{
$query = http_build_query($params, null, '&');
$query = http_build_query($params, '', '&');
$params = explode('&', $query);
$result = [];

Expand Down
2 changes: 1 addition & 1 deletion src/Facebook/Http/RequestBodyUrlEncoded.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ public function __construct(array $params)
*/
public function getBody()
{
return http_build_query($this->params, null, '&');
return http_build_query($this->params, '', '&');
}
}
6 changes: 3 additions & 3 deletions src/Facebook/Url/FacebookUrlManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function removeParamsFromUrl($url, array $paramsToFilter)
}

if (count($params) > 0) {
$query = '?' . http_build_query($params, null, '&');
$query = '?' . http_build_query($params, '', '&');
}
}

Expand Down Expand Up @@ -81,7 +81,7 @@ public static function appendParamsToUrl($url, array $newParams = [])
}

if (strpos($url, '?') === false) {
return $url . '?' . http_build_query($newParams, null, '&');
return $url . '?' . http_build_query($newParams, '', '&');
}

list($path, $query) = explode('?', $url, 2);
Expand All @@ -94,7 +94,7 @@ public static function appendParamsToUrl($url, array $newParams = [])
// Sort for a predicable order
ksort($newParams);

return $path . '?' . http_build_query($newParams, null, '&');
return $path . '?' . http_build_query($newParams, '', '&');
}

/**
Expand Down