Skip to content

Commit b3a0a08

Browse files
authored
Feature/php 8 refactor 2 (#343)
* Bump dependencies for composer for phpstan, php versions. * PHP8.0 Constructor promotion refactor * Update release matrix * We're not ready for 8.2, with that amount of deprecation warnings and dynamic properties. 8.2 hasn't been released yet though * copyright bump * Refactor switch to match * Class on object refactor * Mixed typehints * Stringable fixes * With 7.4 support dropped, we can now used typed properties to reduce docblock bloat * Remove Secrets, fix iteration issue with null/array checks * Fix deprecations on number insight to bring it up to modern API resource injection * Pull unserialize out of the application client * Pull out client aware from Account * Big chunk of work to refactor numbers * Pulling teeth, trying to get arguments and null defaults in order. * Fixed more implementation around Available numbers * Fixed number client bootstrapping filter interface * Hacking away to get casting query variables working * Re-bump off 7.4 in pipeline, bad merge * Fix import * Dead code * Fix 8.2 requirement where dynamic properties are forced deprecated
1 parent 9f2ec03 commit b3a0a08

File tree

260 files changed

+619
-1254
lines changed

Some content is hidden

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

260 files changed

+619
-1254
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
php: [ '7.4', '8.0', '8.1', '8.2' ]
11+
php: [ '8.0', '8.1', '8.2' ]
12+
1213
name: PHP ${{ matrix.php }} Test
1314

1415
steps:

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313
],
1414
"require": {
15-
"php": "~7.4 || ~8.0 || ~8.1",
15+
"php": "~8.0 || ~8.1 || ~8.2",
1616
"ext-json": "*",
1717
"ext-mbstring": "*",
1818
"laminas/laminas-diactoros": "^2.4",
@@ -24,16 +24,17 @@
2424
"psr/log": "^1.1|^2.0|^3.0"
2525
},
2626
"require-dev": {
27-
"php": "~7.4 || ~8.0 || ~8.1",
27+
"php": "~8.0 || ~8.1 || ~8.2",
2828
"guzzlehttp/guzzle": ">=6",
2929
"helmich/phpunit-json-assert": "^3.3",
3030
"php-http/mock-client": "^1.4",
31-
"phpstan/phpstan": "^0.12",
3231
"phpunit/phpunit": "^8.5|^9.4",
3332
"roave/security-advisories": "dev-latest",
3433
"squizlabs/php_codesniffer": "^3.5",
3534
"softcreatr/jsonpath": "^0.7 || ^0.8",
36-
"phpspec/prophecy-phpunit": "^2.0"
35+
"phpspec/prophecy-phpunit": "^2.0",
36+
"phpstan/phpstan": "^1.9",
37+
"rector/rector": "^0.14.8"
3738
},
3839
"config": {
3940
"optimize-autoloader": true,

rector.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
6+
use Rector\Config\RectorConfig;
7+
use Rector\Set\ValueObject\LevelSetList;
8+
9+
return static function (RectorConfig $rectorConfig): void {
10+
$rectorConfig->paths([
11+
__DIR__ . '/src',
12+
__DIR__ . '/test',
13+
]);
14+
15+
// register a single rule
16+
$rectorConfig->rule(\Rector\Php74\Rector\Property\TypedPropertyRector::class);
17+
18+
// define sets of rules
19+
// $rectorConfig->sets([
20+
// LevelSetList::UP_TO_PHP_80
21+
// ]);
22+
};

src/Account/Balance.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Vonage Client Library for PHP
55
*
6-
* @copyright Copyright (c) 2016-2020 Vonage, Inc. (http://vonage.com)
6+
* @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com)
77
* @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0
88
*/
99

src/Account/Client.php

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Vonage Client Library for PHP
55
*
6-
* @copyright Copyright (c) 2016-2020 Vonage, Inc. (http://vonage.com)
6+
* @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com)
77
* @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0
88
*/
99

@@ -14,42 +14,26 @@
1414
use Psr\Http\Client\ClientExceptionInterface;
1515
use Vonage\Client\APIClient;
1616
use Vonage\Client\APIResource;
17-
use Vonage\Client\ClientAwareInterface;
18-
use Vonage\Client\ClientAwareTrait;
1917
use Vonage\Client\Exception as ClientException;
2018
use Vonage\Client\Exception\Request as ClientRequestException;
21-
use Vonage\Client\Exception\Validation as ClientValidationException;
2219
use Vonage\Entity\Filter\KeyValueFilter;
23-
use Vonage\InvalidResponseException;
2420

25-
use function array_key_exists;
2621
use function count;
2722
use function is_null;
2823
use function json_decode;
2924

3025
/**
3126
* @todo Unify the exception handling to avoid duplicated code and logic (ie: getPrefixPricing())
3227
*/
33-
class Client implements ClientAwareInterface, APIClient
28+
class Client implements APIClient
3429
{
35-
/**
36-
* @deprecated This object will be dropping support for ClientAwareInterface in the future
37-
*/
38-
use ClientAwareTrait;
39-
40-
/**
41-
* @var APIResource|null
42-
*/
43-
protected ?APIResource $accountAPI;
44-
45-
public function __construct(?APIResource $accountAPI = null)
30+
public function __construct(protected ?APIResource $accountAPI = null)
4631
{
47-
$this->accountAPI = $accountAPI;
4832
}
4933

5034
public function getAPIResource(): APIResource
5135
{
52-
return $this->accountAPI;
36+
return clone $this->accountAPI;
5337
}
5438

5539
/**
@@ -128,13 +112,13 @@ protected function makePricingRequest($country, $pricingType): array
128112
$api = $this->getAPIResource();
129113
$api->setBaseUri('/account/get-pricing/outbound/' . $pricingType);
130114
$results = $api->search(new KeyValueFilter(['country' => $country]));
131-
$data = $results->getPageData();
115+
$pageData = $results->getPageData();
132116

133-
if (is_null($data)) {
117+
if (is_null($pageData)) {
134118
throw new ClientException\Server('No results found');
135119
}
136120

137-
return $data;
121+
return $pageData;
138122
}
139123

140124
/**
@@ -164,7 +148,6 @@ public function getBalance(): Balance
164148
public function topUp($trx): void
165149
{
166150
$api = $this->getAPIResource();
167-
// @TODO why is this re-setting the base URL
168151
$api->setBaseUri('/account/top-up');
169152
$api->submit(['trx' => $trx]);
170153
}

src/Account/ClientFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Vonage Client Library for PHP
55
*
6-
* @copyright Copyright (c) 2016-2020 Vonage, Inc. (http://vonage.com)
6+
* @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com)
77
* @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0
88
*/
99

src/Account/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Vonage Client Library for PHP
55
*
6-
* @copyright Copyright (c) 2016-2020 Vonage, Inc. (http://vonage.com)
6+
* @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com)
77
* @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0
88
*/
99

src/Account/PrefixPrice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Vonage Client Library for PHP
55
*
6-
* @copyright Copyright (c) 2016-2020 Vonage, Inc. (http://vonage.com)
6+
* @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com)
77
* @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0
88
*/
99

src/Account/Price.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Vonage Client Library for PHP
55
*
6-
* @copyright Copyright (c) 2016-2020 Vonage, Inc. (http://vonage.com)
6+
* @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com)
77
* @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0
88
*/
99

src/Account/SmsPrice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Vonage Client Library for PHP
55
*
6-
* @copyright Copyright (c) 2016-2020 Vonage, Inc. (http://vonage.com)
6+
* @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com)
77
* @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0
88
*/
99

0 commit comments

Comments
 (0)