Skip to content

Commit

Permalink
PHP 8.4 deprecations fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-janu committed Nov 28, 2024
1 parent b9301a7 commit c0626cd
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 53 deletions.
2 changes: 1 addition & 1 deletion src/Authentication/OAuth2Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ protected function requestAnAccessToken(array $params): AccessToken
protected function sendRequestWithClientParams(
string $endpoint,
array $params,
AccessToken|string $accessToken = null,
AccessToken|string|null $accessToken = null,
): Response
{
$params += $this->getClientParams();
Expand Down
15 changes: 8 additions & 7 deletions src/BatchRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ class BatchRequest extends Request implements IteratorAggregate, ArrayAccess
* @param Request[] $requests
*/
public function __construct(
Application $application = null,
?Application $application = null,
array $requests = [],
AccessToken|string $accessToken = null,
AccessToken|string|null $accessToken = null,
?string $graphVersion = null,
) {
parent::__construct($application, $accessToken, 'POST', '', [], null, $graphVersion);
Expand Down Expand Up @@ -221,15 +221,16 @@ public function validateBatchRequestCount(): void
/**
* Converts a Request entity into an array that is batch-friendly.
*
* @param Request $request the request entity to convert
* @param mixed[]|string $options Array of batch request options e.g. 'name', 'omit_response_on_success'. If a string is given, it is the value of the 'name' option.
* @param string|null $attachedFiles names of files associated with the request
* @param Request $request the request entity to convert
* @param string|mixed[]|null $options Array of batch request options e.g. 'name', 'omit_response_on_success'. If a string is given, it is the value of the 'name' option.
* @param string|null $attachedFiles names of files associated with the request
*
* @return mixed[]
*/
public function requestEntityToBatchArray(
Request $request,
array|string $options = null,
string $attachedFiles = null,
array|string|null $options = null,
?string $attachedFiles = null,
): array
{
if ($options === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Client
* Instantiates a new Client object.
*/
public function __construct(
ClientInterface $httpClient = null,
?ClientInterface $httpClient = null,
protected bool $enableBetaMode = false,
) {
$this->httpClient = $httpClient ?? Psr18ClientDiscovery::find();
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ResponseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ResponseException extends SDKException

public function __construct(
protected Response $response,
SDKException $sdkException = null,
?SDKException $sdkException = null,
) {
$this->responseData = $response->getDecodedBody();

Expand Down
38 changes: 19 additions & 19 deletions src/Facebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ public function getPageTabHelper(): PageTabHelper
*/
public function get(
string $endpoint,
AccessToken|string $accessToken = null,
string $eTag = null,
string $graphVersion = null,
AccessToken|string|null $accessToken = null,
?string $eTag = null,
?string $graphVersion = null,
): Response
{
return $this->sendRequest('GET', $endpoint, [], $accessToken, $eTag, $graphVersion);
Expand All @@ -306,9 +306,9 @@ public function get(
public function post(
string $endpoint,
array $params = [],
AccessToken|string $accessToken = null,
string $eTag = null,
string $graphVersion = null,
AccessToken|string|null $accessToken = null,
?string $eTag = null,
?string $graphVersion = null,
): Response
{
return $this->sendRequest('POST', $endpoint, $params, $accessToken, $eTag, $graphVersion);
Expand All @@ -323,9 +323,9 @@ public function post(
public function delete(
string $endpoint,
array $params = [],
AccessToken|string $accessToken = null,
string $eTag = null,
string $graphVersion = null,
AccessToken|string|null $accessToken = null,
?string $eTag = null,
?string $graphVersion = null,
): Response
{
return $this->sendRequest('DELETE', $endpoint, $params, $accessToken, $eTag, $graphVersion);
Expand Down Expand Up @@ -392,9 +392,9 @@ public function sendRequest(
string $method,
string $endpoint,
array $params = [],
AccessToken|string $accessToken = null,
string $eTag = null,
string $graphVersion = null,
AccessToken|string|null $accessToken = null,
?string $eTag = null,
?string $graphVersion = null,
): Response
{
$accessToken ??= $this->defaultAccessToken;
Expand All @@ -413,8 +413,8 @@ public function sendRequest(
*/
public function sendBatchRequest(
array $requests,
AccessToken|string $accessToken = null,
string $graphVersion = null,
AccessToken|string|null $accessToken = null,
?string $graphVersion = null,
): BatchResponse
{
$accessToken ??= $this->defaultAccessToken;
Expand All @@ -433,7 +433,7 @@ public function sendBatchRequest(
*/
public function newBatchRequest(
AccessToken|string|null $accessToken = null,
string $graphVersion = null,
?string $graphVersion = null,
): BatchRequest
{
$accessToken ??= $this->defaultAccessToken;
Expand All @@ -454,9 +454,9 @@ public function request(
string $method,
string $endpoint,
array $params = [],
AccessToken|string $accessToken = null,
string $eTag = null,
string $graphVersion = null,
AccessToken|string|null $accessToken = null,
?string $eTag = null,
?string $graphVersion = null,
): Request
{
$accessToken ??= $this->defaultAccessToken;
Expand Down Expand Up @@ -507,7 +507,7 @@ public function uploadVideo(
array $metadata = [],
string|AccessToken|null $accessToken = null,
int $maxTransferTries = 5,
string $graphVersion = null,
?string $graphVersion = null,
): array
{
$accessToken ??= $this->defaultAccessToken;
Expand Down
20 changes: 10 additions & 10 deletions src/GraphNode/GraphNodeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function __construct(
* @throws SDKException
*/
public function makeGraphNode(
string $subclassName = null,
?string $subclassName = null,
): GraphNode
{
$this->validateResponseCastableAsGraphNode();
Expand All @@ -97,7 +97,7 @@ public function makeGraphNode(
*
* @throws SDKException
*/
public function makeGraphEdge(string $subclassName = null, bool $auto_prefix = true): GraphEdge
public function makeGraphEdge(?string $subclassName = null, bool $auto_prefix = true): GraphEdge
{
$this->validateResponseCastableAsGraphEdge();

Expand Down Expand Up @@ -141,7 +141,7 @@ public function validateResponseCastableAsGraphEdge(): void
*
* @throws SDKException
*/
public function safelyMakeGraphNode(array $data, string $subclassName = null): GraphNode
public function safelyMakeGraphNode(array $data, ?string $subclassName = null): GraphNode
{
$subclassName ??= static::BaseGraphNodeClass;
static::validateSubclass($subclassName);
Expand Down Expand Up @@ -174,18 +174,18 @@ public function safelyMakeGraphNode(array $data, string $subclassName = null): G
/**
* Takes an array of values and determines how to cast each node.
*
* @param array $data the array of data to iterate over
* @param string|null $subclassName the subclass to cast this collection to
* @param string|int $parentKey the key of this data (Graph edge)
* @param string|null $parentNodeId the parent Graph node ID
* @param array $data the array of data to iterate over
* @param string|null $subclassName the subclass to cast this collection to
* @param string|int|null $parentKey the key of this data (Graph edge)
* @param string|null $parentNodeId the parent Graph node ID
*
* @throws SDKException
*/
public function castAsGraphNodeOrGraphEdge(
array $data,
string $subclassName = null,
string|int $parentKey = null,
string $parentNodeId = null,
?string $subclassName = null,
string|int|null $parentKey = null,
?string $parentNodeId = null,
): GraphEdge|GraphNode
{
if (isset($data['data'])) {
Expand Down
6 changes: 3 additions & 3 deletions src/Helper/RedirectLoginHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class RedirectLoginHelper
*/
public function __construct(
protected OAuth2Client $oAuth2Client,
PersistentDataInterface $persistentData = null,
UrlDetectionInterface $urlDetection = null,
?PersistentDataInterface $persistentData = null,
?UrlDetectionInterface $urlDetection = null,
) {
$this->persistentDataHandler = $persistentData ?? new SessionPersistentDataHandler;
$this->urlDetectionHandler = $urlDetection ?? new UrlDetectionHandler;
Expand Down Expand Up @@ -177,7 +177,7 @@ public function getReAuthenticationUrl(string $redirectUrl, array $scope = [], s
*
* @throws SDKException
*/
public function getAccessToken(string $redirectUrl = null): ?AccessToken
public function getAccessToken(?string $redirectUrl = null): ?AccessToken
{
$code = $this->getCode();
if ($code === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/Helper/SignedRequestFromInputHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct(
/**
* Instantiates a new SignedRequest entity.
*/
public function instantiateSignedRequest(string $rawSignedRequest = null): void
public function instantiateSignedRequest(?string $rawSignedRequest = null): void
{
$rawSignedRequest ??= $this->getRawSignedRequest();

Expand Down
2 changes: 1 addition & 1 deletion src/Http/RequestBodyMultipart.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class RequestBodyMultipart implements RequestBodyInterface
public function __construct(
private readonly array $params = [],
private readonly array $files = [],
string $boundary = null,
?string $boundary = null,
) {
$this->boundary = $boundary ?? uniqid();
}
Expand Down
12 changes: 6 additions & 6 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ class Request
* @throws SDKException
*/
public function __construct(
Application $application = null,
AccessToken|string $accessToken = null,
string $method = null,
string $endpoint = null,
?Application $application = null,
AccessToken|string|null $accessToken = null,
?string $method = null,
?string $endpoint = null,
array $params = [],
string $eTag = null,
?string $eTag = null,
protected ?string $graphVersion = null,
) {
$this->setApp($application);
Expand Down Expand Up @@ -135,7 +135,7 @@ public function getAccessTokenEntity(): ?AccessToken
/**
* Set the Application entity used for this request.
*/
public function setApp(Application $application = null): void
public function setApp(?Application $application = null): void
{
$this->app = $application;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public function decodeBody(): void
*
* @throws SDKException
*/
public function getGraphNode(string $subclassName = null): GraphNode
public function getGraphNode(?string $subclassName = null): GraphNode
{
$graphNodeFactory = new GraphNodeFactory($this);

Expand All @@ -238,7 +238,7 @@ public function getGraphNode(string $subclassName = null): GraphNode
*
* @throws SDKException
*/
public function getGraphEdge(string $subclassName = null, bool $auto_prefix = true): GraphEdge
public function getGraphEdge(?string $subclassName = null, bool $auto_prefix = true): GraphEdge
{
$graphNodeFactory = new GraphNodeFactory($this);

Expand Down
2 changes: 1 addition & 1 deletion src/SignedRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SignedRequest
*/
public function __construct(
protected Application $application,
string $rawSignedRequest = null,
?string $rawSignedRequest = null,
) {
if ($rawSignedRequest === null) {
return;
Expand Down

0 comments on commit c0626cd

Please sign in to comment.