From 40840c31e1b2a68f3624013b8eab90d6c5d4a965 Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Tue, 8 Oct 2024 14:36:25 +0200 Subject: [PATCH] Fix handling of some attributes --- MatomoTracker.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/MatomoTracker.php b/MatomoTracker.php index 91461cf..cbb7b80 100644 --- a/MatomoTracker.php +++ b/MatomoTracker.php @@ -105,7 +105,7 @@ class MatomoTracker public $hasCookies = false; - public $token_auth = false; + public $token_auth = null; public $userAgent = false; @@ -159,7 +159,7 @@ class MatomoTracker public $configReferralCookieTimeout = 15768000; // 6 months // Visitor Ids in order - public $userId = false; + public $userId = null; public $forcedVisitorId = false; @@ -1571,11 +1571,11 @@ public function setIp(string $ip) * * A User ID can be a username, UUID or an email address, or any number or string that uniquely identifies a user or client. * - * @param string $userId Any user ID string (eg. email address, ID, username). Must be non empty. Set to false to de-assign a user id previously set. + * @param string|null $userId Any user ID string (eg. email address, ID, username). Must be non empty. Set to null to de-assign a user id previously set. * @return $this * @throws Exception */ - public function setUserId(string $userId) + public function setUserId(?string $userId) { if ($userId === '') { throw new Exception("User ID cannot be empty."); @@ -1674,9 +1674,9 @@ public function getIp() * Returns the User ID string, which may have been set via: * $v->setUserId('username@example.org'); * - * @return bool + * @return string|null */ - public function getUserId() + public function getUserId(): ?string { return $this->userId; } @@ -1743,10 +1743,10 @@ public function getAttributionInfo() * - force the visitor IP * - force the date & time of the tracking requests rather than track for the current datetime * - * @param string $token_auth token_auth 32 chars token_auth string + * @param string|null $token_auth token_auth 32 chars token_auth string * @return $this */ - public function setTokenAuth(string $token_auth) + public function setTokenAuth(?string $token_auth) { $this->token_auth = $token_auth; @@ -2052,7 +2052,7 @@ protected function prepareStreamOptions(string $method, $data, bool $forcePostUr /** * @ignore */ - protected function sendRequest(string $url, string $method = 'GET', $data = null, bool $force = false): string + protected function sendRequest(string $url, string $method = 'GET', $data = null, bool $force = false) { self::$DEBUG_LAST_REQUESTED_URL = $url; @@ -2114,7 +2114,7 @@ protected function sendRequest(string $url, string $method = 'GET', $data = null curl_setopt_array($ch, $options); ob_start(); $response = @curl_exec($ch); - + try { $header = '';