Title: PHP Deprecated errors while using PHP 8.1
Last modified: December 27, 2022

---

# PHP Deprecated errors while using PHP 8.1

 *  [Ram Freedman](https://wordpress.org/support/users/ramf/)
 * (@ramf)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/php-deprecated-errors-while-using-php-8-1-2/)
 * Hi,
 * I’m using Meta pixel for WordPress Version: 3.0.8 – and I want to upgrade to 
   PHP 8.1. while doing so I checked WordPress error log and I see several lines
   regarding the official-facebook-pixel plugin:
   PHP Deprecated: Return type of 
   FacebookAds\Object\ServerSide\AdsPixelSettings::offsetExists($offset) should 
   either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or 
   the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress
   the notice in wp-content/plugins/official-facebook-pixel/vendor/facebook/php-
   business-sdk/src/FacebookAds/Object/ServerSide/AdsPixelSettings.php on line 154
 * PHP Deprecated: Return type of FacebookAds\Object\ServerSide\AdsPixelSettings::
   offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed
   $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to 
   temporarily suppress the notice in wp-content/plugins/official-facebook-pixel/
   vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/AdsPixelSettings.
   php on line 163
 * PHP Deprecated: Return type of FacebookAds\Object\ServerSide\AdsPixelSettings::
   offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(
   mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute
   should be used to temporarily suppress the notice in wp-content/plugins/official-
   facebook-pixel/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/
   AdsPixelSettings.php on line 173
 * PHP Deprecated: Return type of FacebookAds\Object\ServerSide\AdsPixelSettings::
   offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(
   mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used
   to temporarily suppress the notice in wp-content/plugins/official-facebook-pixel/
   vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/AdsPixelSettings.
   php on line 186
 * 
   Is there any version to fix it?
 * Regards,
   Ram

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Kees Lamper](https://wordpress.org/support/users/keeslamper/)
 * (@keeslamper)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/php-deprecated-errors-while-using-php-8-1-2/#post-16324860)
 * I have these exact errors too on my site. I subscribed to the topic so I can 
   see replies.
 * site:L [https://staging-coachcenternl-staging.kinsta.cloud/](https://staging-coachcenternl-staging.kinsta.cloud/)
 *  [damiencal](https://wordpress.org/support/users/damiencal/)
 * (@damiencal)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/php-deprecated-errors-while-using-php-8-1-2/#post-16352033)
 * It looks like you are getting a deprecated error when using the offsetSet() method
   of the FacebookAds\Object\ServerSide\AdsPixelSettings class in PHP. This error
   is occurring because the return type of the offsetSet() method is not compatible
   with the ArrayAccess interface, which it is implementing.
 * To fix this error, you will need to either change the return type of the offsetSet()
   method to void, or use the #[\ReturnTypeWillChange] attribute to temporarily 
   suppress the notice.
 * Here’s an example of how you could modify the offsetSet() method to fix this 
   error:
 *     ```wp-block-code
       public function offsetSet($offset, $value): void
       {
           if (is_null($offset)) {
               $this->data[] = $value;
           } else {
               $this->data[$offset] = $value;
           }
       }
       ```
   
 * Alternatively, you can use the `#[\ReturnTypeWillChange]` attribute to suppress
   the notice:
 *     ```wp-block-code
       #[\ReturnTypeWillChange]
       public function offsetSet($offset, $value)
       {
           if (is_null($offset)) {
               $this->data[] = $value;
           } else {
               $this->data[$offset] = $value;
           }
       }
       ```
   
 * Keep in mind that using the `#[\ReturnTypeWillChange]` attribute is only a temporary
   solution and should be used only if you are unable to change the return type 
   of the `offsetSet()` method to `void`.
 *  Thread Starter [Ram Freedman](https://wordpress.org/support/users/ramf/)
 * (@ramf)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/php-deprecated-errors-while-using-php-8-1-2/#post-16530287)
 * Hi,
 * Any news regarding an update for this plugin that will fix the PHP Deprecated
   errors?
   Regards,
 * Ram
 *  [eclev91](https://wordpress.org/support/users/eclev91/)
 * (@eclev91)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/php-deprecated-errors-while-using-php-8-1-2/#post-16682798)
 * The upstream Facebook PHP SDK dependency was supposed to be bumped from v12 to
   v16 but that change never made it to the Composer lockfile, so it isn’t actually
   shipping.
 * Follow [https://github.com/facebookincubator/Facebook-Pixel-for-Wordpress/issues/42](https://github.com/facebookincubator/Facebook-Pixel-for-Wordpress/issues/42)

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘PHP Deprecated errors while using PHP 8.1’ is closed to new replies.

 * ![](https://ps.w.org/official-facebook-pixel/assets/icon.svg?rev=3158868)
 * [Meta pixel for WordPress](https://wordpress.org/plugins/official-facebook-pixel/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/official-facebook-pixel/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/official-facebook-pixel/)
 * [Active Topics](https://wordpress.org/support/plugin/official-facebook-pixel/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/official-facebook-pixel/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/official-facebook-pixel/reviews/)

## Tags

 * [PHP Deprecated](https://wordpress.org/support/topic-tag/php-deprecated/)

 * 4 replies
 * 4 participants
 * Last reply from: [eclev91](https://wordpress.org/support/users/eclev91/)
 * Last activity: [3 years, 1 month ago](https://wordpress.org/support/topic/php-deprecated-errors-while-using-php-8-1-2/#post-16682798)
 * Status: not resolved