Skip to content

Commit e70d2ca

Browse files
authored
Merge pull request #13 from thewirecutter/fully-support-php8
Update Package to Support PHP 8.0+ (v1.2)
2 parents 4f5cc6b + b2a1d75 commit e70d2ca

File tree

97 files changed

+372
-562
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+372
-562
lines changed

.circleci/config.yml

+3-14
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,13 @@ jobs:
77
build:
88
docker:
99
# Specify the version you desire here
10-
- image: circleci/php:7.1-node-browsers
10+
- image: cimg/php:8.0
1111

1212
steps:
1313
- checkout
1414

15-
# Download and cache dependencies
16-
- restore_cache:
17-
keys:
18-
# "composer.lock" can be used if it is committed to the repo
19-
- v1-dependencies-{{ checksum "composer.json" }}
20-
# fallback to using the latest cache if no exact match is found
21-
- v1-dependencies-
22-
2315
- run: composer install -n --prefer-dist
2416

25-
- save_cache:
26-
key: v1-dependencies-{{ checksum "composer.json" }}
27-
paths:
28-
- ./vendor
17+
- run: composer phpcs
2918

30-
- run: ./vendor/bin/phpcs
19+
- run: composer test

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77

88
# OS Specific Files
99
.DS_Store
10+
/.phpunit.result.cache

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,19 @@ This repository contains the open source PHP SDK that allows you to access the [
88

99
## Copy of Amazon's Provided Code
1010

11-
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.
11+
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.
12+
13+
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.
14+
15+
### Changes from Amazon
16+
17+
* Replaced usage of `\GuzzleHttp\Psr7\build_query` with `\GuzzleHttp\Psr7\Query::build` https://github.com/thewirecutter/paapi5-php-sdk/pull/8
18+
* Added Support for Guzzle 7 https://github.com/thewirecutter/paapi5-php-sdk/pull/6
19+
* Removed Deprecation Warnings when using PHP 8 https://github.com/thewirecutter/paapi5-php-sdk/pull/13
20+
* Removed Dynamic Property Creation Warnings when using PHP 8 https://github.com/thewirecutter/paapi5-php-sdk/pull/13
21+
* Updated PHP Minimum Version to PHP 8 https://github.com/thewirecutter/paapi5-php-sdk/pull/13
22+
* CodeSniffed to PSR-2 https://github.com/thewirecutter/paapi5-php-sdk/pull/13
23+
* Updated Dev Dependencies to reflect PHP 8 version requirement https://github.com/thewirecutter/paapi5-php-sdk/pull/13
1224

1325
## Installation
1426
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:

composer.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "thewirecutter/paapi5-php-sdk",
3-
"version": "1.1.1",
3+
"version": "1.2.0",
44
"description": "ProductAdvertisingAPI 5.0 PHP SDK",
55
"keywords": [
66
"amazon",
@@ -28,21 +28,21 @@
2828
}
2929
],
3030
"require": {
31-
"php": ">=5.5",
31+
"php": "^8.0",
3232
"ext-curl": "*",
3333
"ext-json": "*",
3434
"ext-mbstring": "*",
3535
"guzzlehttp/guzzle": "^6.2|^7.0"
3636
},
3737
"require-dev": {
38-
"phpunit/phpunit": "^4.8",
39-
"squizlabs/php_codesniffer": "~2.6",
38+
"phpunit/phpunit": "^9.0",
39+
"squizlabs/php_codesniffer": "^3.0",
4040
"friendsofphp/php-cs-fixer": "~2.12"
4141
},
4242
"scripts": {
4343
"test": "vendor/bin/phpunit",
44-
"phpcs": "vendor/bin/phpcs --standard=phpcs.xml -n SampleGetItemsApi.php SampleSearchItemsApi.php SampleGetVariationsApi.php SampleGetBrowseNodesApi.php src/com/amazon/paapi5/v1/auth/SignHelper.php",
45-
"phpcbf": "vendor/bin/phpcbf --standard=phpcs.xml -n SampleGetItemsApi.php SampleSearchItemsApi.php SampleGetVariationsApi.php SampleGetBrowseNodesApi.php src/com/amazon/paapi5/v1/auth/SignHelper.php",
44+
"phpcs": "vendor/bin/phpcs --standard=PSR2 -n SampleGetItemsApi.php SampleSearchItemsApi.php SampleGetVariationsApi.php SampleGetBrowseNodesApi.php src",
45+
"phpcbf": "vendor/bin/phpcbf --standard=PSR2 -n SampleGetItemsApi.php SampleSearchItemsApi.php SampleGetVariationsApi.php SampleGetBrowseNodesApi.php src",
4646
"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"
4747
},
4848
"autoload": {

phpunit.xml.dist

+12-19
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="./vendor/autoload.php"
3-
colors="true"
4-
convertErrorsToExceptions="true"
5-
convertNoticesToExceptions="true"
6-
convertWarningsToExceptions="true"
7-
stopOnFailure="false">
8-
<testsuites>
9-
<testsuite>
10-
<directory>./test/Api</directory>
11-
<directory>./test/Model</directory>
12-
</testsuite>
13-
</testsuites>
14-
15-
<filter>
16-
<whitelist processUncoveredFilesFromWhitelist="true">
17-
<directory suffix=".php">./src/com/amazon/paapi5/v1/api</directory>
18-
<directory suffix=".php">./src/com/amazon/paapi5/v1</directory>
19-
</whitelist>
20-
</filter>
2+
<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">
3+
<coverage processUncoveredFiles="true">
4+
<include>
5+
<directory suffix=".php">./src/com/amazon/paapi5/v1/api</directory>
6+
<directory suffix=".php">./src/com/amazon/paapi5/v1</directory>
7+
</include>
8+
</coverage>
9+
<testsuites>
10+
<testsuite name="api">
11+
<directory>./test/Api</directory>
12+
</testsuite>
13+
</testsuites>
2114
</phpunit>

src/com/amazon/paapi5/v1/Availability.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
namespace Amazon\ProductAdvertisingAPI\v1\com\amazon\paapi5\v1;
19+
1920
use \Amazon\ProductAdvertisingAPI\v1\ObjectSerializer;
2021

2122
/**
@@ -45,5 +46,3 @@ public static function getAllowableEnumValues()
4546
];
4647
}
4748
}
48-
49-

src/com/amazon/paapi5/v1/BrowseNode.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ public function setSalesRank($salesRank)
401401
*
402402
* @return boolean
403403
*/
404-
public function offsetExists($offset)
404+
public function offsetExists(mixed $offset): bool
405405
{
406406
return isset($this->container[$offset]);
407407
}
@@ -413,7 +413,7 @@ public function offsetExists($offset)
413413
*
414414
* @return mixed
415415
*/
416-
public function offsetGet($offset)
416+
public function offsetGet(mixed $offset): mixed
417417
{
418418
return isset($this->container[$offset]) ? $this->container[$offset] : null;
419419
}
@@ -426,7 +426,7 @@ public function offsetGet($offset)
426426
*
427427
* @return void
428428
*/
429-
public function offsetSet($offset, $value)
429+
public function offsetSet(mixed $offset, mixed $value): void
430430
{
431431
if (is_null($offset)) {
432432
$this->container[] = $value;
@@ -442,7 +442,7 @@ public function offsetSet($offset, $value)
442442
*
443443
* @return void
444444
*/
445-
public function offsetUnset($offset)
445+
public function offsetUnset(mixed $offset): void
446446
{
447447
unset($this->container[$offset]);
448448
}
@@ -464,5 +464,3 @@ public function __toString()
464464
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
465465
}
466466
}
467-
468-

src/com/amazon/paapi5/v1/BrowseNodeAncestor.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ public function setId($id)
311311
*
312312
* @return boolean
313313
*/
314-
public function offsetExists($offset)
314+
public function offsetExists(mixed $offset): bool
315315
{
316316
return isset($this->container[$offset]);
317317
}
@@ -323,7 +323,7 @@ public function offsetExists($offset)
323323
*
324324
* @return mixed
325325
*/
326-
public function offsetGet($offset)
326+
public function offsetGet(mixed $offset): mixed
327327
{
328328
return isset($this->container[$offset]) ? $this->container[$offset] : null;
329329
}
@@ -336,7 +336,7 @@ public function offsetGet($offset)
336336
*
337337
* @return void
338338
*/
339-
public function offsetSet($offset, $value)
339+
public function offsetSet(mixed $offset, mixed $value): void
340340
{
341341
if (is_null($offset)) {
342342
$this->container[] = $value;
@@ -352,7 +352,7 @@ public function offsetSet($offset, $value)
352352
*
353353
* @return void
354354
*/
355-
public function offsetUnset($offset)
355+
public function offsetUnset(mixed $offset): void
356356
{
357357
unset($this->container[$offset]);
358358
}
@@ -374,5 +374,3 @@ public function __toString()
374374
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
375375
}
376376
}
377-
378-

src/com/amazon/paapi5/v1/BrowseNodeChild.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public function setId($id)
281281
*
282282
* @return boolean
283283
*/
284-
public function offsetExists($offset)
284+
public function offsetExists(mixed $offset): bool
285285
{
286286
return isset($this->container[$offset]);
287287
}
@@ -293,7 +293,7 @@ public function offsetExists($offset)
293293
*
294294
* @return mixed
295295
*/
296-
public function offsetGet($offset)
296+
public function offsetGet(mixed $offset): mixed
297297
{
298298
return isset($this->container[$offset]) ? $this->container[$offset] : null;
299299
}
@@ -306,7 +306,7 @@ public function offsetGet($offset)
306306
*
307307
* @return void
308308
*/
309-
public function offsetSet($offset, $value)
309+
public function offsetSet(mixed $offset, mixed $value): void
310310
{
311311
if (is_null($offset)) {
312312
$this->container[] = $value;
@@ -322,7 +322,7 @@ public function offsetSet($offset, $value)
322322
*
323323
* @return void
324324
*/
325-
public function offsetUnset($offset)
325+
public function offsetUnset(mixed $offset): void
326326
{
327327
unset($this->container[$offset]);
328328
}
@@ -344,5 +344,3 @@ public function __toString()
344344
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
345345
}
346346
}
347-
348-

src/com/amazon/paapi5/v1/BrowseNodeInfo.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public function setWebsiteSalesRank($websiteSalesRank)
251251
*
252252
* @return boolean
253253
*/
254-
public function offsetExists($offset)
254+
public function offsetExists(mixed $offset): bool
255255
{
256256
return isset($this->container[$offset]);
257257
}
@@ -263,7 +263,7 @@ public function offsetExists($offset)
263263
*
264264
* @return mixed
265265
*/
266-
public function offsetGet($offset)
266+
public function offsetGet(mixed $offset): mixed
267267
{
268268
return isset($this->container[$offset]) ? $this->container[$offset] : null;
269269
}
@@ -276,7 +276,7 @@ public function offsetGet($offset)
276276
*
277277
* @return void
278278
*/
279-
public function offsetSet($offset, $value)
279+
public function offsetSet(mixed $offset, mixed $value): void
280280
{
281281
if (is_null($offset)) {
282282
$this->container[] = $value;
@@ -292,7 +292,7 @@ public function offsetSet($offset, $value)
292292
*
293293
* @return void
294294
*/
295-
public function offsetUnset($offset)
295+
public function offsetUnset(mixed $offset): void
296296
{
297297
unset($this->container[$offset]);
298298
}
@@ -314,5 +314,3 @@ public function __toString()
314314
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
315315
}
316316
}
317-
318-

src/com/amazon/paapi5/v1/BrowseNodesResult.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public function setBrowseNodes($browseNodes)
221221
*
222222
* @return boolean
223223
*/
224-
public function offsetExists($offset)
224+
public function offsetExists(mixed $offset): bool
225225
{
226226
return isset($this->container[$offset]);
227227
}
@@ -233,7 +233,7 @@ public function offsetExists($offset)
233233
*
234234
* @return mixed
235235
*/
236-
public function offsetGet($offset)
236+
public function offsetGet(mixed $offset): mixed
237237
{
238238
return isset($this->container[$offset]) ? $this->container[$offset] : null;
239239
}
@@ -246,7 +246,7 @@ public function offsetGet($offset)
246246
*
247247
* @return void
248248
*/
249-
public function offsetSet($offset, $value)
249+
public function offsetSet(mixed $offset, mixed $value): void
250250
{
251251
if (is_null($offset)) {
252252
$this->container[] = $value;
@@ -262,7 +262,7 @@ public function offsetSet($offset, $value)
262262
*
263263
* @return void
264264
*/
265-
public function offsetUnset($offset)
265+
public function offsetUnset(mixed $offset): void
266266
{
267267
unset($this->container[$offset]);
268268
}
@@ -284,5 +284,3 @@ public function __toString()
284284
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
285285
}
286286
}
287-
288-

src/com/amazon/paapi5/v1/ByLineInfo.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public function setManufacturer($manufacturer)
281281
*
282282
* @return boolean
283283
*/
284-
public function offsetExists($offset)
284+
public function offsetExists(mixed $offset): bool
285285
{
286286
return isset($this->container[$offset]);
287287
}
@@ -293,7 +293,7 @@ public function offsetExists($offset)
293293
*
294294
* @return mixed
295295
*/
296-
public function offsetGet($offset)
296+
public function offsetGet(mixed $offset): mixed
297297
{
298298
return isset($this->container[$offset]) ? $this->container[$offset] : null;
299299
}
@@ -306,7 +306,7 @@ public function offsetGet($offset)
306306
*
307307
* @return void
308308
*/
309-
public function offsetSet($offset, $value)
309+
public function offsetSet(mixed $offset, mixed $value): void
310310
{
311311
if (is_null($offset)) {
312312
$this->container[] = $value;
@@ -322,7 +322,7 @@ public function offsetSet($offset, $value)
322322
*
323323
* @return void
324324
*/
325-
public function offsetUnset($offset)
325+
public function offsetUnset(mixed $offset): void
326326
{
327327
unset($this->container[$offset]);
328328
}
@@ -344,5 +344,3 @@ public function __toString()
344344
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
345345
}
346346
}
347-
348-

0 commit comments

Comments
 (0)