From 4f9138229d946f70f047097616f9ec9c69059362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20=C4=8Cern=C3=BD?= Date: Fri, 12 Apr 2024 16:12:26 +0200 Subject: [PATCH] Fix session app ID and app secret nullability --- src/FacebookAds/Api.php | 4 ++-- src/FacebookAds/CrashReporter.php | 6 +++++- src/FacebookAds/Session.php | 12 ++++++------ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/FacebookAds/Api.php b/src/FacebookAds/Api.php index 4abeea818..0e59b65d7 100644 --- a/src/FacebookAds/Api.php +++ b/src/FacebookAds/Api.php @@ -61,8 +61,8 @@ public function __construct( } /** - * @param string $app_id - * @param string $app_secret + * @param string|null $app_id + * @param string|null $app_secret * @param string $access_token * @return static */ diff --git a/src/FacebookAds/CrashReporter.php b/src/FacebookAds/CrashReporter.php index 650a61cb9..f2980e32f 100644 --- a/src/FacebookAds/CrashReporter.php +++ b/src/FacebookAds/CrashReporter.php @@ -74,7 +74,11 @@ public static function enable() { if ($api == null) { self::log('Could not initialize API' . PHP_EOL); } - static::$instance = new static($api->getSession()->getAppId()); + $appId = $api->getSession()->getAppId(); + if ($appId == null) { + self::log('Missing session app ID' . PHP_EOL); + } + static::$instance = new static($appId); static::$instance->registerExceptionHandler(); self::log('Enabled' . PHP_EOL); } diff --git a/src/FacebookAds/Session.php b/src/FacebookAds/Session.php index 884130e62..f955a7b40 100644 --- a/src/FacebookAds/Session.php +++ b/src/FacebookAds/Session.php @@ -12,12 +12,12 @@ class Session implements SessionInterface { /** - * @var string + * @var string|null */ protected $appId; /** - * @var string + * @var string|null */ protected $appSecret; @@ -32,8 +32,8 @@ class Session implements SessionInterface { protected $appSecretProof; /** - * @param string $app_id - * @param string $app_secret + * @param string|null $app_id + * @param string|null $app_secret * @param string $access_token */ public function __construct($app_id, $app_secret, $access_token) { @@ -43,14 +43,14 @@ public function __construct($app_id, $app_secret, $access_token) { } /** - * @return string + * @return string|null */ public function getAppId() { return $this->appId; } /** - * @return string + * @return string|null */ public function getAppSecret() { return $this->appSecret;