Skip to content

Commit

Permalink
Upgrade and run PHPCS
Browse files Browse the repository at this point in the history
  • Loading branch information
jlevers committed Nov 13, 2022
1 parent f8757d1 commit 5daad5e
Show file tree
Hide file tree
Showing 1,129 changed files with 1,294 additions and 1,284 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ composer.phar
composer.lock

# php-cs-fixer cache
.php_cs.cache
.php-cs-fixer.cache

# PHPUnit cache
.phpunit.result.cache
Expand Down
7 changes: 6 additions & 1 deletion .php_cs → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

return PhpCsFixer\Config::create()
require_once __DIR__ . '/vendor/autoload.php';

$config = new PhpCsFixer\Config();
return $config
->setUsingCache(true)
->setRules([
'@PSR2' => true,
Expand All @@ -14,7 +17,9 @@
'braces' => false,
'single_blank_line_at_eof' => false,
'blank_line_after_namespace' => false,
'elseif' => false,
])
->setRiskyAllowed(true)
->setFinder(
PhpCsFixer\Finder::create()
->exclude('test')
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"require-dev": {
"phpunit/phpunit": "^8.0 || ^9.0",
"friendsofphp/php-cs-fixer": "^2.12"
"friendsofphp/php-cs-fixer": "^3.4"
},
"autoload": {
"psr-4": { "SellingPartnerApi\\" : "lib/" }
Expand Down
10 changes: 5 additions & 5 deletions lib/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
use Aws\Sts\StsClient;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7;
use SellingPartnerApi\Api\TokensV20210301Api as TokensApi;
use SellingPartnerApi\Model\TokensV20210301 as Tokens;
use RuntimeException;
use SellingPartnerApi\Api\TokensV20210301Api as TokensApi;
use SellingPartnerApi\Contract\AuthorizationSignerContract;
use SellingPartnerApi\Contract\RequestSignerContract;
use SellingPartnerApi\Model\TokensV20210301 as Tokens;

class Authentication implements RequestSignerContract
{
Expand Down Expand Up @@ -85,8 +85,8 @@ public function getAuthorizationSigner(): AuthorizationSignerContract
}

/**
* @return array
* @throws \GuzzleHttp\Exception\GuzzleException|\RuntimeException
* @return array
*/
public function requestLWAToken(): array
{
Expand Down Expand Up @@ -166,7 +166,7 @@ public function signRequest(Psr7\Request $request, ?string $scope = null, ?strin
!$this->signingScope && (
// This makes it possible to call restricted operations that take dataElements *without*
// generating an RDT as long as no dataElements are passed.
$restrictedPath === null || ($dataElements === [] && in_array($operation, $hasDataElements))
$restrictedPath === null || ($dataElements === [] && in_array($operation, $hasDataElements, true))
)
) {
$relevantCreds = $this->getAwsCredentials();
Expand Down Expand Up @@ -452,8 +452,8 @@ public function getEndpoint(): array
* Set SP API endpoint. $endpoint should be one of the constants from Endpoint.php.
*
* @param array $endpoint
* @return void
* @throws RuntimeException
* @return void
*/
public function setEndpoint(array $endpoint): void
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ public function getEndpoint(): array
* Set SP API endpoint. $endpoint should be one of the constants from Endpoint.php.
*
* @param array $endpoint
* @return void
* @throws RuntimeException
* @return void
*/
public function setEndpoint(array $endpoint): void
{
Expand Down
11 changes: 6 additions & 5 deletions lib/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct(
$this->reportName = $documentType['name'];

$validContentTypes = ContentType::getContentTypes();
if (!in_array($this->contentType, array_values($validContentTypes))) {
if (!in_array($this->contentType, array_values($validContentTypes), true)) {
$readableContentTypes = [];
foreach ($validContentTypes as $name => $value) {
$readableContentTypes[] = "SellingPartnerApi\ContentType::{$name} ($value)";
Expand Down Expand Up @@ -93,7 +93,7 @@ public function download(?bool $postProcess = true, ?string $encoding = null): s
$response = $this->client->request('GET', $this->url, ['stream' => true]);
} catch (\GuzzleHttp\Exception\ClientException $e) {
$response = $e->getResponse();
if ($response->getStatusCode() == 404) {
if ($response->getStatusCode() === 404) {
throw new RuntimeException("Report document not found ({$response->getStatusCode()}): {$response->getBody()}");
} else {
throw $e;
Expand Down Expand Up @@ -122,7 +122,7 @@ public function download(?bool $postProcess = true, ?string $encoding = null): s
// and PDF reports.
// If encoding is not provided try to automatically detect the encoding from the http response; default is UTF-8
if (!($this->contentType === ContentType::XLSX || $this->contentType === ContentType::PDF)) {
if (!is_null($encoding) && !in_array(strtoupper($encoding), mb_list_encodings())) {
if (!is_null($encoding) && !in_array(strtoupper($encoding), mb_list_encodings(), true)) {
$encoding = null;
} else if (is_null($encoding)) {
$encodings = ['UTF-8'];
Expand All @@ -143,7 +143,7 @@ public function download(?bool $postProcess = true, ?string $encoding = null): s

$this->tmpFilename = tempnam(sys_get_temp_dir(), "tempdoc_spapi");

if (in_array($this->contentType, [ContentType::TAB, ContentType::CSV, ContentType::XLSX])) {
if (in_array($this->contentType, [ContentType::TAB, ContentType::CSV, ContentType::XLSX], true)) {
$tempFile = fopen($this->tmpFilename, "r+");
fwrite($tempFile, $contents);
fclose($tempFile);
Expand All @@ -161,14 +161,15 @@ public function download(?bool $postProcess = true, ?string $encoding = null): s
if($this->reportName !== "GET_LEDGER_DETAIL_VIEW_DATA") {
$reader->setEnclosure(chr(8));
}
// no break
case ContentType::CSV:
case ContentType::XLSX:
$spreadsheet = $reader->load($this->tmpFilename);
if ($this->contentType !== ContentType::XLSX) {
// Avoid spreadsheet formula processing when loading CSV or TAB files
$sheet = $spreadsheet->getSheet(0)->toArray(null, false);
// Turn each row of data into an associative array with the headers as keys
array_walk($sheet, function(&$row) use ($sheet) {
array_walk($sheet, function (&$row) use ($sheet) {
$row = array_combine($sheet[0], $row);
});
// Remove headers line
Expand Down
7 changes: 5 additions & 2 deletions lib/Endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace SellingPartnerApi;

use InvalidArgumentException;

/***************************/
/** Region/endpoint pairs **/
/***************************/
Expand Down Expand Up @@ -44,9 +46,10 @@ class Endpoint
* @param string $marketplace_id The identifier for the marketplace. (required)
* @param bool $sandbox Whether to return the sandbox endpoint for the region. (optional, default to false)
*
* @throws InvalidArgumentException
* @return array of the endpoint details
*
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*
* @link https://docs.developer.amazonservices.com/en_US/dev_guide/DG_Endpoints.html
*/
Expand Down Expand Up @@ -99,7 +102,7 @@ public static function getByMarketplaceId(string $marketplace_id, bool $sandbox
'A1VC38T7YXB528' => 'FE',
];
if (!isset($map[$marketplace_id])) {
throw new \InvalidArgumentException(sprintf(
throw new InvalidArgumentException(sprintf(
'Unknown marketplace ID "%s".',
$marketplace_id
));
Expand Down
2 changes: 1 addition & 1 deletion lib/HeaderSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

namespace SellingPartnerApi;

use SellingPartnerApi\Authentication;
use \Exception;
use SellingPartnerApi\Authentication;

/**
* ApiException Class Doc Comment
Expand Down
2 changes: 1 addition & 1 deletion lib/Model/AplusContentV20201101/AplusPaginatedResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
namespace SellingPartnerApi\Model\AplusContentV20201101;

use \ArrayAccess;
use \SellingPartnerApi\ObjectSerializer;
use \SellingPartnerApi\Model\ModelInterface;
use \SellingPartnerApi\ObjectSerializer;

/**
* AplusPaginatedResponse Class Doc Comment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
namespace SellingPartnerApi\Model\AplusContentV20201101;

use \ArrayAccess;
use \SellingPartnerApi\ObjectSerializer;
use \SellingPartnerApi\Model\ModelInterface;
use \SellingPartnerApi\ObjectSerializer;

/**
* AplusPaginatedResponseAllOf Class Doc Comment
Expand Down
2 changes: 1 addition & 1 deletion lib/Model/AplusContentV20201101/AplusResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
namespace SellingPartnerApi\Model\AplusContentV20201101;

use \ArrayAccess;
use \SellingPartnerApi\ObjectSerializer;
use \SellingPartnerApi\Model\ModelInterface;
use \SellingPartnerApi\ObjectSerializer;

/**
* AplusResponse Class Doc Comment
Expand Down
4 changes: 2 additions & 2 deletions lib/Model/AplusContentV20201101/AsinBadge.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/

namespace SellingPartnerApi\Model\AplusContentV20201101;
use \SellingPartnerApi\ObjectSerializer;
use \SellingPartnerApi\Model\ModelInterface;
use \SellingPartnerApi\ObjectSerializer;

/**
* AsinBadge Class Doc Comment
Expand Down Expand Up @@ -69,7 +69,7 @@ public static function getAllowableEnumValues()

public function __construct($value)
{
if (is_null($value) || !in_array($value, self::getAllowableEnumValues())) {
if (is_null($value) || !in_array($value, self::getAllowableEnumValues(), true)) {
throw new \InvalidArgumentException(sprintf("Invalid value for enum 'AsinBadge', must be one of '%s'", implode("', '", self::getAllowableEnumValues())));
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Model/AplusContentV20201101/AsinMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
namespace SellingPartnerApi\Model\AplusContentV20201101;

use \ArrayAccess;
use \SellingPartnerApi\ObjectSerializer;
use \SellingPartnerApi\Model\ModelInterface;
use \SellingPartnerApi\ObjectSerializer;

/**
* AsinMetadata Class Doc Comment
*
* @category Class
* @description The A+ Content ASIN with additional metadata for content management. If you don&#39;t include the &#x60;includedDataSet&#x60; parameter in a call to the listContentDocumentAsinRelations operation, the related ASINs are returned without metadata.
* @description The A+ Content ASIN with additional metadata for content management. If you don't include the `includedDataSet` parameter in a call to the listContentDocumentAsinRelations operation, the related ASINs are returned without metadata.
* @package SellingPartnerApi
* @group
* @implements \ArrayAccess<TKey, TValue>
Expand Down
4 changes: 2 additions & 2 deletions lib/Model/AplusContentV20201101/ColorType.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/

namespace SellingPartnerApi\Model\AplusContentV20201101;
use \SellingPartnerApi\ObjectSerializer;
use \SellingPartnerApi\Model\ModelInterface;
use \SellingPartnerApi\ObjectSerializer;

/**
* ColorType Class Doc Comment
Expand Down Expand Up @@ -65,7 +65,7 @@ public static function getAllowableEnumValues()

public function __construct($value)
{
if (is_null($value) || !in_array($value, self::getAllowableEnumValues())) {
if (is_null($value) || !in_array($value, self::getAllowableEnumValues(), true)) {
throw new \InvalidArgumentException(sprintf("Invalid value for enum 'ColorType', must be one of '%s'", implode("', '", self::getAllowableEnumValues())));
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Model/AplusContentV20201101/ContentBadge.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/

namespace SellingPartnerApi\Model\AplusContentV20201101;
use \SellingPartnerApi\ObjectSerializer;
use \SellingPartnerApi\Model\ModelInterface;
use \SellingPartnerApi\ObjectSerializer;

/**
* ContentBadge Class Doc Comment
Expand Down Expand Up @@ -71,7 +71,7 @@ public static function getAllowableEnumValues()

public function __construct($value)
{
if (is_null($value) || !in_array($value, self::getAllowableEnumValues())) {
if (is_null($value) || !in_array($value, self::getAllowableEnumValues(), true)) {
throw new \InvalidArgumentException(sprintf("Invalid value for enum 'ContentBadge', must be one of '%s'", implode("', '", self::getAllowableEnumValues())));
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Model/AplusContentV20201101/ContentDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
namespace SellingPartnerApi\Model\AplusContentV20201101;

use \ArrayAccess;
use \SellingPartnerApi\ObjectSerializer;
use \SellingPartnerApi\Model\ModelInterface;
use \SellingPartnerApi\ObjectSerializer;

/**
* ContentDocument Class Doc Comment
Expand Down
2 changes: 1 addition & 1 deletion lib/Model/AplusContentV20201101/ContentMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
namespace SellingPartnerApi\Model\AplusContentV20201101;

use \ArrayAccess;
use \SellingPartnerApi\ObjectSerializer;
use \SellingPartnerApi\Model\ModelInterface;
use \SellingPartnerApi\ObjectSerializer;

/**
* ContentMetadata Class Doc Comment
Expand Down
2 changes: 1 addition & 1 deletion lib/Model/AplusContentV20201101/ContentMetadataRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
namespace SellingPartnerApi\Model\AplusContentV20201101;

use \ArrayAccess;
use \SellingPartnerApi\ObjectSerializer;
use \SellingPartnerApi\Model\ModelInterface;
use \SellingPartnerApi\ObjectSerializer;

/**
* ContentMetadataRecord Class Doc Comment
Expand Down
2 changes: 1 addition & 1 deletion lib/Model/AplusContentV20201101/ContentModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
namespace SellingPartnerApi\Model\AplusContentV20201101;

use \ArrayAccess;
use \SellingPartnerApi\ObjectSerializer;
use \SellingPartnerApi\Model\ModelInterface;
use \SellingPartnerApi\ObjectSerializer;

/**
* ContentModule Class Doc Comment
Expand Down
4 changes: 2 additions & 2 deletions lib/Model/AplusContentV20201101/ContentModuleType.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/

namespace SellingPartnerApi\Model\AplusContentV20201101;
use \SellingPartnerApi\ObjectSerializer;
use \SellingPartnerApi\Model\ModelInterface;
use \SellingPartnerApi\ObjectSerializer;

/**
* ContentModuleType Class Doc Comment
Expand Down Expand Up @@ -91,7 +91,7 @@ public static function getAllowableEnumValues()

public function __construct($value)
{
if (is_null($value) || !in_array($value, self::getAllowableEnumValues())) {
if (is_null($value) || !in_array($value, self::getAllowableEnumValues(), true)) {
throw new \InvalidArgumentException(sprintf("Invalid value for enum 'ContentModuleType', must be one of '%s'", implode("', '", self::getAllowableEnumValues())));
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Model/AplusContentV20201101/ContentRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
namespace SellingPartnerApi\Model\AplusContentV20201101;

use \ArrayAccess;
use \SellingPartnerApi\ObjectSerializer;
use \SellingPartnerApi\Model\ModelInterface;
use \SellingPartnerApi\ObjectSerializer;

/**
* ContentRecord Class Doc Comment
Expand Down
4 changes: 2 additions & 2 deletions lib/Model/AplusContentV20201101/ContentStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/

namespace SellingPartnerApi\Model\AplusContentV20201101;
use \SellingPartnerApi\ObjectSerializer;
use \SellingPartnerApi\Model\ModelInterface;
use \SellingPartnerApi\ObjectSerializer;

/**
* ContentStatus Class Doc Comment
Expand Down Expand Up @@ -69,7 +69,7 @@ public static function getAllowableEnumValues()

public function __construct($value)
{
if (is_null($value) || !in_array($value, self::getAllowableEnumValues())) {
if (is_null($value) || !in_array($value, self::getAllowableEnumValues(), true)) {
throw new \InvalidArgumentException(sprintf("Invalid value for enum 'ContentStatus', must be one of '%s'", implode("', '", self::getAllowableEnumValues())));
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Model/AplusContentV20201101/ContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
*/

namespace SellingPartnerApi\Model\AplusContentV20201101;
use \SellingPartnerApi\ObjectSerializer;
use \SellingPartnerApi\Model\ModelInterface;
use \SellingPartnerApi\ObjectSerializer;

/**
* ContentType Class Doc Comment
Expand Down Expand Up @@ -65,7 +65,7 @@ public static function getAllowableEnumValues()

public function __construct($value)
{
if (is_null($value) || !in_array($value, self::getAllowableEnumValues())) {
if (is_null($value) || !in_array($value, self::getAllowableEnumValues(), true)) {
throw new \InvalidArgumentException(sprintf("Invalid value for enum 'ContentType', must be one of '%s'", implode("', '", self::getAllowableEnumValues())));
}

Expand Down
Loading

0 comments on commit 5daad5e

Please sign in to comment.