Skip to content

Commit

Permalink
Merge pull request #157 from gigya/Magento-2.4.7-PHP-8.3
Browse files Browse the repository at this point in the history
adding modifications for PHP 8.3 and Magento 2.4.7
  • Loading branch information
cristian-vatca-osf authored Nov 7, 2024
2 parents 71cbd01 + c824de8 commit 20d047c
Show file tree
Hide file tree
Showing 49 changed files with 386 additions and 293 deletions.
2 changes: 1 addition & 1 deletion Block/GigyaScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class GigyaScript extends Template
protected EncoderInterface $urlEncoder;

protected GigyaScriptHelper $scriptHelper;
private StoreInterface $store;
protected StoreInterface $store;

/**
* GigyaScript constructor.
Expand Down
2 changes: 1 addition & 1 deletion Controller/Raas/GigyaPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class GigyaPost extends LoginPost
/**
* @var AccountManagementInterface
*/
protected AccountManagementInterface $customerAccountManagement;
protected $customerAccountManagement;

/**
* @var Address
Expand Down
12 changes: 7 additions & 5 deletions Helper/CmsStarterKit/GSFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Gigya\GigyaIM\Helper\CmsStarterKit;

use Exception;
use Gigya\PHP\GSException;
use Gigya\PHP\GSKeyNotFoundException;
use Gigya\PHP\GSObject;

class GSFactory
Expand All @@ -17,7 +19,7 @@ class GSFactory
*
* @return GigyaApiRequest
*
* @throws \Exception
* @throws Exception
*/
public static function createGsRequest($apiKey, $secret, $apiMethod, $params, $dataCenter = "us1.gigya.com", $useHTTPS = true)
{
Expand All @@ -35,7 +37,7 @@ public static function createGsRequest($apiKey, $secret, $apiMethod, $params, $d
*
* @return GigyaApiRequest
*
* @throws \Exception
* @throws Exception
*/
public static function createGSRequestAppKey($apiKey, $key, $secret, $apiMethod, $params, $dataCenter = "us1.gigya.com", $useHTTPS = true)
{
Expand All @@ -52,7 +54,7 @@ public static function createGSRequestAppKey($apiKey, $key, $secret, $apiMethod,
* @param bool $useHTTPS
*
* @return GigyaAuthRequest
* @throws \Gigya\PHP\GSKeyNotFoundException
* @throws GSKeyNotFoundException
*/
public static function createGSRequestPrivateKey($apiKey, $userKey, $privateKey, $apiMethod, $params, $dataCenter = "us1.gigya.com", $useHTTPS = true)
{
Expand All @@ -68,7 +70,7 @@ public static function createGSRequestPrivateKey($apiKey, $userKey, $privateKey,
*
* @return GigyaApiRequest
*
* @throws \Exception
* @throws Exception
*/
public static function createGSRequestAccessToken($token, $apiMethod, $params, $dataCenter = "us1.gigya.com", $useHTTPS = true)
{
Expand All @@ -80,7 +82,7 @@ public static function createGSRequestAccessToken($token, $apiMethod, $params, $
*
* @return GSObject
* @throws GSException
* @throws \Exception
* @throws Exception
*/
public static function createGSObjectFromArray($array)
{
Expand Down
20 changes: 10 additions & 10 deletions Helper/CmsStarterKit/GigyaApiHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace Gigya\GigyaIM\Helper\CmsStarterKit;

use Exception;
use Gigya\GigyaIM\Helper\CmsStarterKit\user\GigyaUser;
use Gigya\GigyaIM\Helper\CmsStarterKit\user\GigyaUserFactory;
use Gigya\PHP\GSException;
use Gigya\PHP\GSObject;
use Gigya\PHP\GSResponse;
use Gigya\PHP\JWTUtils;
use Gigya\PHP\SigUtils;
use stdClass;
use Magento\Framework\Module\Dir;

class GigyaApiHelper
Expand Down Expand Up @@ -72,7 +72,7 @@ public function __construct(
*
* @throws GSApiException
* @throws GSException
* @throws \Exception
* @throws Exception
*/
public function sendApiCall($method, $params)
{
Expand Down Expand Up @@ -111,7 +111,7 @@ public function sendApiCall($method, $params)
*
* @return GigyaUser|false
*
* @throws \Exception
* @throws Exception
* @throws GSApiException
*/
public function validateUid($uid, $uidSignature, $signatureTimestamp, $include = null, $extraProfileFields = null, $orgParams = [])
Expand Down Expand Up @@ -143,13 +143,13 @@ public function validateUid($uid, $uidSignature, $signatureTimestamp, $include =
*
* @return GigyaUser|false
*
* @throws \Gigya\GigyaIM\Helper\CmsStarterKit\GSApiException
* @throws GSApiException
*/
public function validateJwtAuth($uid, $idToken, $include = null, $extraProfileFields = null, $orgParams = null)
{
try {
$jwt = JWTUtils::validateSignature($idToken, $this->apiKey, $this->dataCenter);
} catch (\Exception $e) {
} catch (Exception $e) {
return false;
}

Expand All @@ -168,7 +168,7 @@ public function validateJwtAuth($uid, $idToken, $include = null, $extraProfileFi
*
* @return GigyaUser
*
* @throws \Exception
* @throws Exception
* @throws GSApiException
*/
public function fetchGigyaAccount($uid, $include = null, $extraProfileFields = null, $params = [])
Expand Down Expand Up @@ -283,7 +283,7 @@ public function searchGigyaUsers($query, $useCursor = false)
* @param string $uid UID
* @param array $data data
*
* @throws \Exception
* @throws Exception
* @throws \InvalidArgumentException
* @throws GSApiException
*/
Expand Down Expand Up @@ -314,7 +314,7 @@ public function updateGigyaAccount($uid, $data)
}

/**
* @throws \Exception
* @throws Exception
* @throws GSApiException
*/
public function getSiteSchema()
Expand All @@ -328,7 +328,7 @@ public function getSiteSchema()
*
* @return bool
*
* @throws \Exception
* @throws Exception
* @throws GSException
*/
public function isRaasEnabled($apiKey = null)
Expand All @@ -345,7 +345,7 @@ public function isRaasEnabled($apiKey = null)
if ($e->getErrorCode() == 403036) {
return false;
}
throwException($e);
throw new Exception($e);
}

return false;
Expand Down
5 changes: 3 additions & 2 deletions Helper/CmsStarterKit/GigyaJsonObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Gigya\GigyaIM\Helper\CmsStarterKit;

use Exception;
use stdClass;

abstract class GigyaJsonObject extends stdClass
Expand All @@ -26,7 +27,7 @@ public function __construct($json)
* @param $arguments
*
* @return mixed|null
* @throws \Exception
* @throws Exception
*/
public function __call($name, $arguments)
{
Expand All @@ -39,7 +40,7 @@ public function __call($name, $arguments)

return $this->$property = $arguments[0];
} else {
throw new \Exception("Method $name does not exist");
throw new Exception("Method $name does not exist");
}
}

Expand Down
11 changes: 4 additions & 7 deletions Helper/CmsStarterKit/fieldMapping/GigyaUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Gigya\GigyaIM\Helper\CmsStarterKit\fieldMapping;

use DateTime;
use Exception;
use Gigya\GigyaIM\Helper\CmsStarterKit\GigyaApiHelper;
use Gigya\GigyaIM\Helper\CmsStarterKit\GSApiException;
Expand Down Expand Up @@ -58,7 +59,7 @@ public function __construct(
$apiHelper
) {
$this->cmsArray = (!empty($cmsValuesArray)) ? $cmsValuesArray : [];
$this->gigyaUid = $gigyaUid;
$this->gigyaUid = (string)$gigyaUid;
$this->path = (string) $path;
$this->mapped = !empty($this->path);
$this->apiHelper = $apiHelper;
Expand Down Expand Up @@ -189,6 +190,7 @@ protected function retrieveFieldMappings(): void

/**
* @return array
* @throws Exception
*/
protected function createGigyaArray(): array
{
Expand Down Expand Up @@ -221,32 +223,27 @@ private function castVal(mixed $val, $conf): mixed
case "text":
case "varchar":
return (string) $val;
break;
case "long";
case "integer":
case "int":
return (int) $val;
break;
case "boolean":
case "bool":
if (is_string($val)) {
$val = strtolower($val);
}

return filter_var($val, FILTER_VALIDATE_BOOLEAN);
break;
case 'date':
if ($val and !preg_match('/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(Z|(\+|-)\d{2}(:?\d{2})?)/', $val)) {
$datetime = new \DateTime($val);
$datetime = new DateTime($val);
// Return date in format ISO 8601 (https://en.wikipedia.org/wiki/ISO_8601)
$val = $datetime->format('c');
}

return $val;
break;
default:
return $val;
break;
}
}

Expand Down
12 changes: 6 additions & 6 deletions Helper/CmsStarterKit/user/GigyaProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ class GigyaProfile extends GigyaJsonObject
/**
* @var int
*/
private int $birthDay;
private ?int $birthDay=null;

/**
* @var int
*/
private int $birthMonth;
private ?int $birthMonth=null;

/**
* @var int
Expand Down Expand Up @@ -45,7 +45,7 @@ class GigyaProfile extends GigyaJsonObject
/**
* @var string
*/
private string $gender;
private ?string $gender=null;

/**
* @var string
Expand Down Expand Up @@ -205,7 +205,7 @@ class GigyaProfile extends GigyaJsonObject
/**
* @return int
*/
public function getBirthDay(): int
public function getBirthDay(): int | null
{
return $this->birthDay;
}
Expand All @@ -221,7 +221,7 @@ public function setBirthDay($birthDay): void
/**
* @return int
*/
public function getBirthMonth(): int
public function getBirthMonth(): int | null
{
return $this->birthMonth;
}
Expand Down Expand Up @@ -317,7 +317,7 @@ public function setFirstName($firstName): void
/**
* @return string
*/
public function getGender(): string
public function getGender(): string | null
{
return $this->gender;
}
Expand Down
10 changes: 5 additions & 5 deletions Helper/CmsStarterKit/user/GigyaUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class GigyaUser extends GigyaJsonObject
/**
* @var string
*/
private string $isActive;
private ?string $isActive = "";

/**
* @var array
Expand All @@ -102,19 +102,19 @@ class GigyaUser extends GigyaJsonObject
private string $time;

/**
* @var array
* @var array|null
*/
private array $data;
private ?array $data = [];

/**
* @var array
*/
private array $subscriptions;
private ?array $subscriptions = [];

/**
* @var boolean
*/
private bool $isVerified;
private ?bool $isVerified = false;

/**
* @return string
Expand Down
8 changes: 5 additions & 3 deletions Helper/GigyaCronHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Store\Model\StoreManagerInterface;
use Zend_Mail;
use Zend_Mail_Exception;

class GigyaCronHelper extends AbstractHelper
{
Expand Down Expand Up @@ -95,7 +97,7 @@ public function getCustomersByAttributeValue($attributeCode, $value): array
* @param $attributeCode
* @param $value
*
* @return CustomerInterface
* @return CustomerInterface|null
*
* @throws LocalizedException
*/
Expand Down Expand Up @@ -169,7 +171,7 @@ public function sendEmail($job_type, $job_status, $email_to, $processed_items =
}

/* Generic email sender init */
$email_sender = new \Zend_Mail();
$email_sender = new Zend_Mail();

/* Set email body */
$email_body = $custom_email_body;
Expand All @@ -196,7 +198,7 @@ public function sendEmail($job_type, $job_status, $email_to, $processed_items =
$email_sender->send();

$this->logger->info($job_type . ' cron: mail sent to: ' . implode(', ', $email_to) . ' with status ' . $job_status);
} catch (\Zend_Mail_Exception $e) {
} catch (Zend_Mail_Exception $e) {
$this->logger->warning($job_type . ' cron: unable to send email: ' . $e->getMessage());
return false;
}
Expand Down
Loading

0 comments on commit 20d047c

Please sign in to comment.