From ae8c46018f0a84405f08a52029a30ffb263f9ff8 Mon Sep 17 00:00:00 2001 From: Martin Seitz Date: Fri, 17 Oct 2025 14:48:50 +0200 Subject: [PATCH 1/2] Add ReturnTypeWillChange annotation ArrayAccess::offsetGet() has return type `mixed` now. Not having `mixed` as a return type, which causes a `Deprecated` warning. We could add `mixed` as a return type, but that would break support for PHP 7.x where `mixed` is not supported yet. --- src/Facebook/GraphNodes/Collection.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Facebook/GraphNodes/Collection.php b/src/Facebook/GraphNodes/Collection.php index 42e1f0dff..9603002a8 100644 --- a/src/Facebook/GraphNodes/Collection.php +++ b/src/Facebook/GraphNodes/Collection.php @@ -184,6 +184,7 @@ public function offsetExists($offset): bool /** * Get an item at a given offset. */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->items[$offset] ?? null; From 1270b83c2444c472abc5a0557026a32fddbd279f Mon Sep 17 00:00:00 2001 From: Martin Seitz Date: Fri, 17 Oct 2025 14:55:19 +0200 Subject: [PATCH 2/2] Use 0 as default $code It is passed as parameter to the constructor of `FacebookAuthenticationException`, which extends `FacebookSDKException`, which extends `\Exception`. The `code` parameter of the `Exception` constructor needs to be of type `int` since PHP 8.0. This happens, if there is a response, which does not contain `{"code": 123}` in the body of the response. This can happen both if there's a problem with Facebook and during tests. --- src/Facebook/Exceptions/FacebookResponseException.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Facebook/Exceptions/FacebookResponseException.php b/src/Facebook/Exceptions/FacebookResponseException.php index 72bd0bda3..9cac6931f 100644 --- a/src/Facebook/Exceptions/FacebookResponseException.php +++ b/src/Facebook/Exceptions/FacebookResponseException.php @@ -74,7 +74,7 @@ public static function create(FacebookResponse $response) $data = ['error' => $data]; } - $code = isset($data['error']['code']) ? $data['error']['code'] : null; + $code = isset($data['error']['code']) ? $data['error']['code'] : 0; $message = isset($data['error']['message']) ? $data['error']['message'] : 'Unknown error from Graph.'; if (isset($data['error']['error_subcode'])) {