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

Update Package to Support PHP 8.0+ (v1.2) #13

Merged
merged 19 commits into from
Feb 3, 2023
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,13 @@ jobs:
build:
docker:
# Specify the version you desire here
- image: circleci/php:7.1-node-browsers
- image: cimg/php:8.0

steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
# "composer.lock" can be used if it is committed to the repo
- v1-dependencies-{{ checksum "composer.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: composer install -n --prefer-dist

- save_cache:
key: v1-dependencies-{{ checksum "composer.json" }}
paths:
- ./vendor
- run: composer phpcs

- run: ./vendor/bin/phpcs
- run: composer test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@

# OS Specific Files
.DS_Store
/.phpunit.result.cache
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@ This repository contains the open source PHP SDK that allows you to access the [

## Copy of Amazon's Provided Code

This is a public copy of [Amazon's provided code](https://webservices.amazon.com/paapi5/documentation/quick-start/using-sdk.html), as their version is not available through Packagist as of writing.
This is a near identical public copy of [Amazon's provided code](https://webservices.amazon.com/paapi5/documentation/quick-start/using-sdk.html), as their version is not available through Packagist as of writing.

We have not changed the API in any way, however we did cleanup portions of the code and have updated dependencies. A listing of changes are provided below.

### Changes from Amazon

* Replaced usage of `\GuzzleHttp\Psr7\build_query` with `\GuzzleHttp\Psr7\Query::build` https://github.com/thewirecutter/paapi5-php-sdk/pull/8
* Added Support for Guzzle 7 https://github.com/thewirecutter/paapi5-php-sdk/pull/6
* Removed Deprecation Warnings when using PHP 8 https://github.com/thewirecutter/paapi5-php-sdk/pull/13
* Removed Dynamic Property Creation Warnings when using PHP 8 https://github.com/thewirecutter/paapi5-php-sdk/pull/13
* Updated PHP Minimum Version to PHP 8 https://github.com/thewirecutter/paapi5-php-sdk/pull/13
* CodeSniffed to PSR-2 https://github.com/thewirecutter/paapi5-php-sdk/pull/13
* Updated Dev Dependencies to reflect PHP 8 version requirement https://github.com/thewirecutter/paapi5-php-sdk/pull/13

## Installation
The Product Advertising API PHP SDK can be installed with [Composer](https://getcomposer.org/). The SDK is available via [Packagist](http://packagist.org/) under the [`thewirecutter/paapi5-php-sdk`](https://packagist.org/packages/thewirecutter/paapi5-php-sdk) package. If Composer is installed globally on your system, you can run the following in the base directory of your project to add the SDK as a dependency:
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "thewirecutter/paapi5-php-sdk",
"version": "1.1.1",
"version": "1.2.0",
"description": "ProductAdvertisingAPI 5.0 PHP SDK",
"keywords": [
"amazon",
Expand Down Expand Up @@ -28,21 +28,21 @@
}
],
"require": {
"php": ">=5.5",
"php": "^8.0",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this upgrade considered a breacking change (thus we need to bump version to 2.0.0)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@enricobono I don't think so based upon my understanding, referring to this post that sums up how I'm thinking about it https://medium.com/@sampart/semantic-versioning-when-you-change-the-required-programming-language-version-16a3a3555c95.

The short version is: We're not changing the actual API for the package in any breaking way, merely the required PHP version and Composer will handle that if you don't have PHP 8 available on your machine you'll get the last version that does work for you.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense, thanks.

"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"guzzlehttp/guzzle": "^6.2|^7.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"squizlabs/php_codesniffer": "~2.6",
"phpunit/phpunit": "^9.0",
"squizlabs/php_codesniffer": "^3.0",
"friendsofphp/php-cs-fixer": "~2.12"
},
"scripts": {
"test": "vendor/bin/phpunit",
"phpcs": "vendor/bin/phpcs --standard=phpcs.xml -n SampleGetItemsApi.php SampleSearchItemsApi.php SampleGetVariationsApi.php SampleGetBrowseNodesApi.php src/com/amazon/paapi5/v1/auth/SignHelper.php",
"phpcbf": "vendor/bin/phpcbf --standard=phpcs.xml -n SampleGetItemsApi.php SampleSearchItemsApi.php SampleGetVariationsApi.php SampleGetBrowseNodesApi.php src/com/amazon/paapi5/v1/auth/SignHelper.php",
"phpcs": "vendor/bin/phpcs --standard=PSR2 -n SampleGetItemsApi.php SampleSearchItemsApi.php SampleGetVariationsApi.php SampleGetBrowseNodesApi.php src",
"phpcbf": "vendor/bin/phpcbf --standard=PSR2 -n SampleGetItemsApi.php SampleSearchItemsApi.php SampleGetVariationsApi.php SampleGetBrowseNodesApi.php src",
"php-cs-fixer": "vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --allow-risky=yes --using-cache=no --config=.php_cs SampleGetItemsApi.php SampleSearchItemsApi.php SampleGetVariationsApi.php SampleGetBrowseNodesApi.php src/com/amazon/paapi5/v1/auth/SignHelper.php"
},
"autoload": {
Expand Down
31 changes: 12 additions & 19 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false">
<testsuites>
<testsuite>
<directory>./test/Api</directory>
<directory>./test/Model</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/com/amazon/paapi5/v1/api</directory>
<directory suffix=".php">./src/com/amazon/paapi5/v1</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src/com/amazon/paapi5/v1/api</directory>
<directory suffix=".php">./src/com/amazon/paapi5/v1</directory>
</include>
</coverage>
<testsuites>
<testsuite name="api">
<directory>./test/Api</directory>
</testsuite>
</testsuites>
</phpunit>
3 changes: 1 addition & 2 deletions src/com/amazon/paapi5/v1/Availability.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

namespace Amazon\ProductAdvertisingAPI\v1\com\amazon\paapi5\v1;

use \Amazon\ProductAdvertisingAPI\v1\ObjectSerializer;

/**
Expand Down Expand Up @@ -45,5 +46,3 @@ public static function getAllowableEnumValues()
];
}
}


10 changes: 4 additions & 6 deletions src/com/amazon/paapi5/v1/BrowseNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ public function setSalesRank($salesRank)
*
* @return boolean
*/
public function offsetExists($offset)
public function offsetExists(mixed $offset): bool
{
return isset($this->container[$offset]);
}
Expand All @@ -413,7 +413,7 @@ public function offsetExists($offset)
*
* @return mixed
*/
public function offsetGet($offset)
public function offsetGet(mixed $offset): mixed
{
return isset($this->container[$offset]) ? $this->container[$offset] : null;
}
Expand All @@ -426,7 +426,7 @@ public function offsetGet($offset)
*
* @return void
*/
public function offsetSet($offset, $value)
public function offsetSet(mixed $offset, mixed $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
Expand All @@ -442,7 +442,7 @@ public function offsetSet($offset, $value)
*
* @return void
*/
public function offsetUnset($offset)
public function offsetUnset(mixed $offset): void
{
unset($this->container[$offset]);
}
Expand All @@ -464,5 +464,3 @@ public function __toString()
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}


10 changes: 4 additions & 6 deletions src/com/amazon/paapi5/v1/BrowseNodeAncestor.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public function setId($id)
*
* @return boolean
*/
public function offsetExists($offset)
public function offsetExists(mixed $offset): bool
{
return isset($this->container[$offset]);
}
Expand All @@ -323,7 +323,7 @@ public function offsetExists($offset)
*
* @return mixed
*/
public function offsetGet($offset)
public function offsetGet(mixed $offset): mixed
{
return isset($this->container[$offset]) ? $this->container[$offset] : null;
}
Expand All @@ -336,7 +336,7 @@ public function offsetGet($offset)
*
* @return void
*/
public function offsetSet($offset, $value)
public function offsetSet(mixed $offset, mixed $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
Expand All @@ -352,7 +352,7 @@ public function offsetSet($offset, $value)
*
* @return void
*/
public function offsetUnset($offset)
public function offsetUnset(mixed $offset): void
{
unset($this->container[$offset]);
}
Expand All @@ -374,5 +374,3 @@ public function __toString()
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}


10 changes: 4 additions & 6 deletions src/com/amazon/paapi5/v1/BrowseNodeChild.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public function setId($id)
*
* @return boolean
*/
public function offsetExists($offset)
public function offsetExists(mixed $offset): bool
{
return isset($this->container[$offset]);
}
Expand All @@ -293,7 +293,7 @@ public function offsetExists($offset)
*
* @return mixed
*/
public function offsetGet($offset)
public function offsetGet(mixed $offset): mixed
{
return isset($this->container[$offset]) ? $this->container[$offset] : null;
}
Expand All @@ -306,7 +306,7 @@ public function offsetGet($offset)
*
* @return void
*/
public function offsetSet($offset, $value)
public function offsetSet(mixed $offset, mixed $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
Expand All @@ -322,7 +322,7 @@ public function offsetSet($offset, $value)
*
* @return void
*/
public function offsetUnset($offset)
public function offsetUnset(mixed $offset): void
{
unset($this->container[$offset]);
}
Expand All @@ -344,5 +344,3 @@ public function __toString()
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}


10 changes: 4 additions & 6 deletions src/com/amazon/paapi5/v1/BrowseNodeInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public function setWebsiteSalesRank($websiteSalesRank)
*
* @return boolean
*/
public function offsetExists($offset)
public function offsetExists(mixed $offset): bool
{
return isset($this->container[$offset]);
}
Expand All @@ -263,7 +263,7 @@ public function offsetExists($offset)
*
* @return mixed
*/
public function offsetGet($offset)
public function offsetGet(mixed $offset): mixed
{
return isset($this->container[$offset]) ? $this->container[$offset] : null;
}
Expand All @@ -276,7 +276,7 @@ public function offsetGet($offset)
*
* @return void
*/
public function offsetSet($offset, $value)
public function offsetSet(mixed $offset, mixed $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
Expand All @@ -292,7 +292,7 @@ public function offsetSet($offset, $value)
*
* @return void
*/
public function offsetUnset($offset)
public function offsetUnset(mixed $offset): void
{
unset($this->container[$offset]);
}
Expand All @@ -314,5 +314,3 @@ public function __toString()
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}


10 changes: 4 additions & 6 deletions src/com/amazon/paapi5/v1/BrowseNodesResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function setBrowseNodes($browseNodes)
*
* @return boolean
*/
public function offsetExists($offset)
public function offsetExists(mixed $offset): bool
{
return isset($this->container[$offset]);
}
Expand All @@ -233,7 +233,7 @@ public function offsetExists($offset)
*
* @return mixed
*/
public function offsetGet($offset)
public function offsetGet(mixed $offset): mixed
{
return isset($this->container[$offset]) ? $this->container[$offset] : null;
}
Expand All @@ -246,7 +246,7 @@ public function offsetGet($offset)
*
* @return void
*/
public function offsetSet($offset, $value)
public function offsetSet(mixed $offset, mixed $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
Expand All @@ -262,7 +262,7 @@ public function offsetSet($offset, $value)
*
* @return void
*/
public function offsetUnset($offset)
public function offsetUnset(mixed $offset): void
{
unset($this->container[$offset]);
}
Expand All @@ -284,5 +284,3 @@ public function __toString()
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}


10 changes: 4 additions & 6 deletions src/com/amazon/paapi5/v1/ByLineInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public function setManufacturer($manufacturer)
*
* @return boolean
*/
public function offsetExists($offset)
public function offsetExists(mixed $offset): bool
{
return isset($this->container[$offset]);
}
Expand All @@ -293,7 +293,7 @@ public function offsetExists($offset)
*
* @return mixed
*/
public function offsetGet($offset)
public function offsetGet(mixed $offset): mixed
{
return isset($this->container[$offset]) ? $this->container[$offset] : null;
}
Expand All @@ -306,7 +306,7 @@ public function offsetGet($offset)
*
* @return void
*/
public function offsetSet($offset, $value)
public function offsetSet(mixed $offset, mixed $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
Expand All @@ -322,7 +322,7 @@ public function offsetSet($offset, $value)
*
* @return void
*/
public function offsetUnset($offset)
public function offsetUnset(mixed $offset): void
{
unset($this->container[$offset]);
}
Expand All @@ -344,5 +344,3 @@ public function __toString()
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}


Loading