Skip to content

Commit 8193ecb

Browse files
mpesarifacebook-github-bot
authored andcommitted
Fix deprecations & support current PHP versions (#624)
Summary: Pull Request resolved: #624 Reviewed By: satwikareddy3 Differential Revision: D69256661 Pulled By: stcheng fbshipit-source-id: c8c8420cc52d3954267f8bc10e0e284d99baa77d
1 parent ef5a6d9 commit 8193ecb

37 files changed

Lines changed: 48 additions & 41 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
strategy:
88
matrix:
99
operating-system: [ubuntu-latest]
10-
php-versions: ['8.0', '8.1', '8.2']
10+
php-versions: ['8.0', '8.1', '8.2', '8.3', '8.4']
1111
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
1212
steps:
1313
- name: Checkout

src/FacebookAds/ApiRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(
3636
$return_prototype = null,
3737
$api_type = null,
3838
$accepted_fields = array(),
39-
TypeChecker $param_checker = null,
39+
?TypeChecker $param_checker = null,
4040
$allow_file_upload = false,
4141
$use_graph_video_endpoint = false) {
4242
$this->fields = [];

src/FacebookAds/Cursor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Cursor implements \Iterator, \Countable, \ArrayAccess {
6363
public function __construct(
6464
ResponseInterface $response,
6565
AbstractObject $object_prototype,
66-
Api $api = null) {
66+
?Api $api = null) {
6767
$this->response = $response;
6868
$this->objectPrototype = $object_prototype;
6969
$this->api = $api !== null ? $api : Api::instance();

src/FacebookAds/Http/Adapter/CurlAdapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class CurlAdapter extends AbstractAdapter {
4949
* @param Client $client
5050
* @param CurlInterface $curl
5151
*/
52-
public function __construct(Client $client, CurlInterface $curl = null) {
52+
public function __construct(Client $client, ?CurlInterface $curl = null) {
5353
parent::__construct($client);
5454
$this->curl = $curl ?: AbstractCurl::createOptimalVersion();
5555
$this->curl->init();
@@ -90,7 +90,7 @@ public function setOpts(\ArrayObject $opts) {
9090
* @return int
9191
*/
9292
protected function getheaderSize() {
93-
return $this->getCurl()->getInfo(CURLINFO_HEADER_SIZE);
93+
return $this->getCurl()->getInfo(CURLINFO_HEADER_SIZE) ?? 0;
9494
}
9595

9696
/**

src/FacebookAds/Http/Exception/RequestException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function __construct(ResponseInterface $response) {
8787
$this->response = $response;
8888
$error_data = static::getErrorData($response);
8989

90-
parent::__construct($error_data['message'], $error_data['code'] ?? 0);
90+
parent::__construct($error_data['message'] ?? '', $error_data['code'] ?? 0);
9191

9292
$this->errorSubcode = $error_data['error_subcode'];
9393
$this->errorUserTitle = $error_data['error_user_title'];

src/FacebookAds/Object/AbstractCrudObject.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class AbstractCrudObject extends AbstractObject {
4040
* @param string $parent_id Optional, needed for creating new objects.
4141
* @param Api $api The Api instance this object should use to make calls
4242
*/
43-
public function __construct($id = null, $parent_id = null, Api $api = null) {
43+
public function __construct($id = null, $parent_id = null, ?Api $api = null) {
4444
parent::__construct();
4545

4646
// check that $id is an integer or a string integer or a string of
@@ -113,7 +113,7 @@ protected function getEndpoint() {
113113
* @return Api
114114
* @throws \InvalidArgumentException
115115
*/
116-
protected static function assureApi(Api $instance = null) {
116+
protected static function assureApi(?Api $instance = null) {
117117
$instance = $instance ?: Api::instance();
118118
if (!$instance) {
119119
throw new \InvalidArgumentException(
@@ -460,7 +460,7 @@ protected function createAsyncJob(
460460
* @param Api $api Api Object to use
461461
* @return bool Returns true on success
462462
*/
463-
public static function deleteIds(array $ids, Api $api = null) {
463+
public static function deleteIds(array $ids, ?Api $api = null) {
464464
$batch = array();
465465
foreach ($ids as $id) {
466466
$request = array(
@@ -495,7 +495,7 @@ public static function readIds(
495495
array $ids,
496496
array $fields = array(),
497497
array $params = array(),
498-
Api $api = null) {
498+
?Api $api = null) {
499499
if (empty($fields)) {
500500
$fields = static::getDefaultReadFields();
501501
}

src/FacebookAds/Object/AdImage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function getSelf(array $fields = array(), array $params = array(), $pendi
8181
* @return array
8282
*/
8383
public static function createFromZip(
84-
$file_path, $account_id, array $params = array(), Api $api = null) {
84+
$file_path, $account_id, array $params = array(), ?Api $api = null) {
8585

8686
$image = new AdImage(null, $account_id, $api);
8787
$image->{AdImageFields::FILENAME} = $file_path;

src/FacebookAds/Object/BusinessDataAPI/Content.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Content {
3535
* Constructor
3636
* @param mixed[] $data Associated array of property value initializing the model
3737
*/
38-
public function __construct(array $data = null) {
38+
public function __construct(?array $data = null) {
3939
$this->container['product_id'] = isset($data['product_id']) ? $data['product_id'] : null;;
4040
$this->container['quantity'] = isset($data['quantity']) ? $data['quantity'] : null;
4141
$this->container['price'] = isset($data['price']) ? $data['price'] : null;

src/FacebookAds/Object/BusinessDataAPI/CustomData.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class CustomData {
3636
* Constructor
3737
* @param mixed[] $data Associated array of property value initializing the model
3838
*/
39-
public function __construct(array $data = null) {
39+
public function __construct(?array $data = null) {
4040
$this->container['value'] = isset($data['value']) ? $data['value'] : null;
4141
$this->container['currency'] = isset($data['currency']) ? $data['currency'] : null;
4242
$this->container['contents'] = isset($data['contents']) ? $data['contents'] : null;

src/FacebookAds/Object/BusinessDataAPI/Event.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Event {
3636
* Constructor
3737
* @param mixed[] $data Associated array of property value initalizing the model
3838
*/
39-
public function __construct(array $data = null) {
39+
public function __construct(?array $data = null) {
4040
$this->container['event_name'] = isset($data['event_name']) ? $data['event_name'] : null;
4141
$this->container['event_time'] = isset($data['event_time']) ? $data['event_time'] : null;
4242
$this->container['event_id'] = isset($data['event_id']) ? $data['event_id'] : null;

0 commit comments

Comments
 (0)