Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added required annotations in order to avoid PHP 8.1 severity warnings #123

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
50 changes: 25 additions & 25 deletions lib/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* All CyberSource API specs merged together. These are available at https://developer.cybersource.com/api/reference/api-reference.html
*
* OpenAPI spec version: 0.0.1
*
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*
*/
Expand Down Expand Up @@ -46,7 +46,7 @@
class ApiClient
{
private static $logger = null;

public static $PATCH = "PATCH";
public static $POST = "POST";
public static $GET = "GET";
Expand Down Expand Up @@ -99,7 +99,7 @@ public function __construct(\CyberSource\Configuration $config = null, \CyberSou
if ($config === null) {
$config = Configuration::getDefaultConfiguration();
}

if ($merchantConfig === null) {
echo "Merchant Configuration cannot be null.";
}
Expand All @@ -116,8 +116,8 @@ public function __construct(\CyberSource\Configuration $config = null, \CyberSou
}

/**
* Get Client ID
*
* Get Client ID
*
* @return String
*/
public function getClientId()
Expand Down Expand Up @@ -221,12 +221,12 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header
(array)$this->config->getDefaultHeaders(),
(array)$headerParams
);

if (!empty($queryParams)) {
$resourcePath = ($resourcePath . '?' . http_build_query($queryParams));
$queryParams=null;
}

foreach ($headerParams as $key => $val) {
$headers[] = "$key: $val";
}
Expand Down Expand Up @@ -333,7 +333,7 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header
$printPostData = $postData;
}
self::$logger->debug("HTTP Request Body:\n" . print_r($printPostData, true));

// debugging for curl
if (($this->merchantConfig->getLogConfiguration())->isLoggingEnabled()) {
curl_setopt($curl, CURLOPT_VERBOSE, 1);
Expand All @@ -349,11 +349,11 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header

// File download functionality
$fileHandle = Null;
if (isset($this->downloadFilePath) && trim($this->downloadFilePath) != '') {
if (isset($this->downloadFilePath) && trim((string)$this->downloadFilePath) != '') {
// obtain the HTTP response headers
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_HEADERFUNCTION, array($this, 'header_callback'));

$fileHandle = fopen($this->downloadFilePath, 'w+');
curl_setopt($curl, CURLOPT_FILE, $fileHandle);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
Expand All @@ -374,7 +374,7 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header
// Make the request
$response = curl_exec($curl);

if (!isset($this->downloadFilePath) && trim($this->downloadFilePath) == '') {
if (!isset($this->downloadFilePath) && trim((string)$this->downloadFilePath) == '') {
$http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$http_header = $this->httpParseHeaders(substr($response, 0, $http_header_size));
$http_body = substr($response, $http_header_size);
Expand All @@ -386,19 +386,19 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header
$printHttpBody = $http_body;
}
self::$logger->debug("HTTP Response Body:\n" . print_r($printHttpBody, true));

// Handle the response
if ($response_info['http_code'] === 0) {
$curl_error_message = curl_error($curl);

// curl_exec can sometimes fail but still return a blank message from curl_error().
if (!empty($curl_error_message)) {
$error_message = "API call to $url failed: $curl_error_message";
} else {
$error_message = "API call to $url failed, but for an unknown reason. " .
"This could happen if you are disconnected from the network.";
}

self::$logger->error("ApiException : " . print_r($error_message, true));
$exception = new ApiException($error_message, 0, null, null);
$exception->setResponseObject($response_info);
Expand All @@ -410,7 +410,7 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header
self::$logger->close();
return [$http_body, $response_info['http_code'], $http_header];
}

$data = json_decode($http_body);
if (json_last_error() > 0) { // if response is a string
$data = $http_body;
Expand Down Expand Up @@ -438,13 +438,13 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header
$http_body = substr($response, $http_header_size);
$response_info = curl_getinfo($curl);
curl_close($curl);

if ($fileHandle) {
fclose($fileHandle);
}

$downloadFilePath = null;

// Handle the response
if ($response_info['http_code'] === 0) {
$curl_error_message = curl_error($curl);
Expand Down Expand Up @@ -479,10 +479,10 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header
}
}
}
function header_callback($curl, $header_line) {

function header_callback($curl, $header_line) {
global $stream_headers;

$stream_headers[] = $this->httpParseHeaders($header_line);
return strlen($header_line);
}
Expand Down Expand Up @@ -561,7 +561,7 @@ protected function httpParseHeaders($raw_headers)

return $headers;
}

/*
* Purpose : This function calling the Authentication and making an Auth Header
*
Expand All @@ -570,7 +570,7 @@ public function callAuthenticationHeader($method, $postData, $resourcePath)
{
$merchantConfig = $this->merchantConfig;
$authentication = new Authentication($merchantConfig->getLogConfiguration());
$getToken = $authentication->generateToken($resourcePath, $postData, $method, $merchantConfig);
$getToken = $authentication->generateToken($resourcePath, $postData, $method, $merchantConfig);
if($merchantConfig->getAuthenticationType() == GlobalParameter::HTTP_SIGNATURE){
$host = "Host:".$merchantConfig->getHost();
$vcMerchant = "v-c-merchant-id:".$merchantConfig->getMerchantID();
Expand All @@ -580,7 +580,7 @@ public function callAuthenticationHeader($method, $postData, $resourcePath)
$getToken,
$host,
'Date:'.$date
);
);

} else if($merchantConfig->getAuthenticationType() == GlobalParameter::JWT){
$headers = array(
Expand All @@ -603,7 +603,7 @@ public function callAuthenticationHeader($method, $postData, $resourcePath)
// {
// array_push($headers, "v-c-solution-id:" . $merchantConfig->getSolutionId());
// }

if($method == GlobalParameter::POST || $method == GlobalParameter::PUT || $method== GlobalParameter::PATCH){
$digestCon = new PayloadDigest($merchantConfig->getLogConfiguration());
$digest = $digestCon->generateDigest($postData);
Expand Down
10 changes: 7 additions & 3 deletions lib/Model/AccessTokenResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ public static function getters()
return self::$getters;
}







/**
* Associative array for storing property values
Expand Down Expand Up @@ -325,12 +325,13 @@ public function setRefreshTokenExpiresIn($refreshTokenExpiresIn)
return $this;
}


/**
* Returns true if offset exists. False otherwise.
* @param integer $offset Offset
* @return boolean
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return isset($this->container[$offset]);
Expand All @@ -341,6 +342,7 @@ public function offsetExists($offset)
* @param integer $offset Offset
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return isset($this->container[$offset]) ? $this->container[$offset] : null;
Expand All @@ -352,6 +354,7 @@ public function offsetGet($offset)
* @param mixed $value Value to be set
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
if (is_null($offset)) {
Expand All @@ -366,6 +369,7 @@ public function offsetSet($offset, $value)
* @param integer $offset Offset
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
unset($this->container[$offset]);
Expand Down
10 changes: 7 additions & 3 deletions lib/Model/AddNegativeListRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* All CyberSource API specs merged together. These are available at https://developer.cybersource.com/api/reference/api-reference.html
*
* OpenAPI spec version: 0.0.1
*
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*
*/
Expand Down Expand Up @@ -141,9 +141,9 @@ public static function getters()
return self::$getters;
}







/**
* Associative array for storing property values
Expand Down Expand Up @@ -320,6 +320,7 @@ public function setBuyerInformation($buyerInformation)
* @param integer $offset Offset
* @return boolean
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return isset($this->container[$offset]);
Expand All @@ -330,6 +331,7 @@ public function offsetExists($offset)
* @param integer $offset Offset
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return isset($this->container[$offset]) ? $this->container[$offset] : null;
Expand All @@ -341,6 +343,7 @@ public function offsetGet($offset)
* @param mixed $value Value to be set
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
if (is_null($offset)) {
Expand All @@ -355,6 +358,7 @@ public function offsetSet($offset, $value)
* @param integer $offset Offset
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
unset($this->container[$offset]);
Expand Down
10 changes: 7 additions & 3 deletions lib/Model/AuthReversalRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* All CyberSource API specs merged together. These are available at https://developer.cybersource.com/api/reference/api-reference.html
*
* OpenAPI spec version: 0.0.1
*
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*
*/
Expand Down Expand Up @@ -136,9 +136,9 @@ public static function getters()
return self::$getters;
}







/**
* Associative array for storing property values
Expand Down Expand Up @@ -293,6 +293,7 @@ public function setPointOfSaleInformation($pointOfSaleInformation)
* @param integer $offset Offset
* @return boolean
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return isset($this->container[$offset]);
Expand All @@ -303,6 +304,7 @@ public function offsetExists($offset)
* @param integer $offset Offset
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return isset($this->container[$offset]) ? $this->container[$offset] : null;
Expand All @@ -314,6 +316,7 @@ public function offsetGet($offset)
* @param mixed $value Value to be set
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
if (is_null($offset)) {
Expand All @@ -328,6 +331,7 @@ public function offsetSet($offset, $value)
* @param integer $offset Offset
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
unset($this->container[$offset]);
Expand Down
10 changes: 7 additions & 3 deletions lib/Model/Body.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* All CyberSource API specs merged together. These are available at https://developer.cybersource.com/api/reference/api-reference.html
*
* OpenAPI spec version: 0.0.1
*
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*
*/
Expand Down Expand Up @@ -126,9 +126,9 @@ public static function getters()
return self::$getters;
}







/**
* Associative array for storing property values
Expand Down Expand Up @@ -251,6 +251,7 @@ public function setEmvDetailsList($emvDetailsList)
* @param integer $offset Offset
* @return boolean
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return isset($this->container[$offset]);
Expand All @@ -261,6 +262,7 @@ public function offsetExists($offset)
* @param integer $offset Offset
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return isset($this->container[$offset]) ? $this->container[$offset] : null;
Expand All @@ -272,6 +274,7 @@ public function offsetGet($offset)
* @param mixed $value Value to be set
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
if (is_null($offset)) {
Expand All @@ -286,6 +289,7 @@ public function offsetSet($offset, $value)
* @param integer $offset Offset
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
unset($this->container[$offset]);
Expand Down
Loading