Skip to content

Commit 7d66b85

Browse files
authored
Removal of major deprecations (#301) (#304)
* Removal of major deprecations (#301) * Removed call module, depreciated in favour of Voice module * Remove user module. * Modify Keypair to allow tests to fetch the input key, test basic creation of JWT * Drop support for 7.2 and 7.3 * Add php core return type will change annotations for PHP8.1 compatibility. These will be removed anyway later due to deprecations. * Depreciated methods removal for talk * Marked Application and talk deprecations * Removed callback and message objects marked for deletion * Removed Filter and finally the IterableServiceShimTrait.php to let Iterable API collections handle that rather than service layer * Feature/further removals (#305) * Depreciated methods removal for talk * Marked Application and talk deprecations * Removed callback and message objects marked for deletion * bump container, min required PHP74 which is the same for library anyway * migrate phpunit schema * Feature/array access deprecations (#307) * Array access removals * Almost all array access removed * Remove array access tests * Final test cleanup * Minor readme tweaks
1 parent ee2eec3 commit 7d66b85

File tree

122 files changed

+245
-7935
lines changed

Some content is hidden

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

122 files changed

+245
-7935
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
### Changed
88

99
* Maintainer and Contribution documents changed to reflect current ownership
10-
* All test cases now extend off a the new `VonageTestCase` class that implements the `ProphesizeTrait`
10+
* All test cases now extend off the new `VonageTestCase` class that implements the `ProphesizeTrait`
1111

1212
# 2.9.3
1313

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Client Library for PHP
88

99
<img src="https://developer.nexmo.com/assets/images/Vonage_Nexmo.svg" height="48px" alt="Nexmo is now known as Vonage" />
1010

11-
*This library requires a minimum PHP version of 7.2*
11+
*This library requires a minimum PHP version of 7.4*
1212

1313
This is the PHP client library for use Vonage's API. To use this, you'll need a Vonage account. Sign up [for free at
1414
nexmo.com][signup].
@@ -30,6 +30,10 @@ To install the PHP client library to your project, we recommend using [Composer]
3030
composer require vonage/client
3131
```
3232

33+
> Note that this actually points to a wrapper library that includes an HTTP client -and- this core library. You can
34+
> install this library directly from Composer if you wish, with the ability to choose the HTTP client your project
35+
> uses.
36+
3337
> You don't need to clone this repository to use this library in your own projects. Use Composer to install it from Packagist.
3438
3539
If you're new to Composer, here are some resources that you may find useful:
@@ -111,7 +115,7 @@ The [send example][send_example] also has full working examples.
111115

112116
### Receiving a Message
113117

114-
Inbound messages are [sent to your application as a webhook][doc_inbound], and the client library provides a way to
118+
Inbound messages are [sent to your application as a webhook][doc_inbound]. The Client library provides a way to
115119
create an inbound message object from a webhook:
116120

117121
```php
@@ -274,7 +278,7 @@ $outboundCall = new \Vonage\Voice\OutboundCall(
274278
);
275279
$ncco = new NCCO();
276280

277-
//ADD ACTIONS TO THE NCCO OBJECT HERE
281+
// ADD ACTIONS TO THE NCCO OBJECT HERE
278282

279283
$outboundCall->setNCCO($ncco);
280284

@@ -423,7 +427,7 @@ foreach($client->search($filter) as $call){
423427

424428
### Creating an Application
425429

426-
Application are configuration containers. You can create one using a simple array structure:
430+
Application are configuration containers. You can create one using an array structure:
427431

428432
```php
429433
$application = new \Vonage\Application\Application();
@@ -476,7 +480,7 @@ $client->applications()->create($application);
476480
You can also pass the client an application object:
477481

478482
```php
479-
$a = new Vonage\Application\Application;
483+
$a = new Vonage\Application\Application();
480484

481485
$a->setName('PHP Client Example');
482486
$a->getVoiceConfig()->setWebhook('answer_url', 'https://example.com/answer', 'GET');

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
}
1313
],
1414
"require": {
15-
"php": ">=7.2",
15+
"php": "~7.4 || ~8.0 || ~8.1",
1616
"ext-json": "*",
1717
"ext-mbstring": "*",
1818
"laminas/laminas-diactoros": "^2.4",
1919
"lcobucci/jwt": "^3.4|^4.0",
2020
"composer/package-versions-deprecated": "^1.11",
21-
"psr/container": "^1.0",
21+
"psr/container": "^2.0",
2222
"psr/http-client-implementation": "^1.0",
2323
"vonage/nexmo-bridge": "^0.1.0",
2424
"psr/log": "^1.1|^2.0"
2525
},
2626
"require-dev": {
27-
"php": ">=7.4",
27+
"php": "~7.4 || ~8.0 || ~8.1",
2828
"guzzlehttp/guzzle": ">=6",
2929
"helmich/phpunit-json-assert": "^3.3",
3030
"php-http/mock-client": "^1.4",
@@ -53,7 +53,8 @@
5353
"scripts": {
5454
"cs-check": "phpcs",
5555
"cs-fix": "phpcbf",
56-
"test": "phpunit"
56+
"test": "phpunit",
57+
"phpstan": "phpstan analyse -l 2 src"
5758
},
5859
"support": {
5960
"email": "[email protected]",

phpunit.xml.dist

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true">
3-
<testsuites>
4-
<testsuite name="default">
5-
<directory>test</directory>
6-
</testsuite>
7-
</testsuites>
8-
9-
<filter>
10-
<whitelist processUncoveredFilesFromWhitelist="true">
11-
<directory suffix=".php">src</directory>
12-
</whitelist>
13-
</filter>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true">
3+
<coverage processUncoveredFiles="true">
4+
<include>
5+
<directory suffix=".php">src</directory>
6+
</include>
7+
</coverage>
8+
<testsuites>
9+
<testsuite name="default">
10+
<directory>test</directory>
11+
</testsuite>
12+
</testsuites>
1413
</phpunit>

phpunit.xml.dist.bak

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true">
3+
<testsuites>
4+
<testsuite name="default">
5+
<directory>test</directory>
6+
</testsuite>
7+
</testsuites>
8+
9+
<filter>
10+
<whitelist processUncoveredFilesFromWhitelist="true">
11+
<directory suffix=".php">src</directory>
12+
</whitelist>
13+
</filter>
14+
</phpunit>

src/Account/Balance.php

Lines changed: 1 addition & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,16 @@
1111

1212
namespace Vonage\Account;
1313

14-
use ArrayAccess;
15-
use JsonSerializable;
16-
use Vonage\Client\Exception\Exception as ClientException;
1714
use Vonage\Entity\Hydrator\ArrayHydrateInterface;
18-
use Vonage\Entity\JsonSerializableInterface;
19-
use Vonage\Entity\JsonUnserializableInterface;
2015

21-
use function get_class;
22-
use function trigger_error;
23-
24-
/**
25-
* This class will no longer be accessible via array keys past v2
26-
*
27-
* @todo Have the JSON unserialize/serialize keys match with $this->data keys
28-
*/
2916
class Balance implements
30-
JsonSerializable,
31-
JsonSerializableInterface,
32-
JsonUnserializableInterface,
33-
ArrayAccess,
3417
ArrayHydrateInterface
3518
{
3619
/**
3720
* @var array
3821
*/
39-
protected $data;
22+
protected array $data;
4023

41-
/**
42-
* @todo Have these take null values, since we offer an unserialize option to populate
43-
*/
4424
public function __construct($balance, $autoReload)
4525
{
4626
$this->data['balance'] = $balance;
@@ -57,57 +37,6 @@ public function getAutoReload()
5737
return $this->data['auto_reload'];
5838
}
5939

60-
public function jsonUnserialize(array $json): void
61-
{
62-
trigger_error(
63-
get_class($this) . "::jsonUnserialize is deprecated, please fromArray() instead",
64-
E_USER_DEPRECATED
65-
);
66-
67-
$this->fromArray($json);
68-
}
69-
70-
public function jsonSerialize(): array
71-
{
72-
return $this->data;
73-
}
74-
75-
public function offsetExists($offset): bool
76-
{
77-
trigger_error(
78-
"Array access for " . get_class($this) . " is deprecated, please use getter methods",
79-
E_USER_DEPRECATED
80-
);
81-
82-
return isset($this->data[$offset]);
83-
}
84-
85-
public function offsetGet($offset)
86-
{
87-
trigger_error(
88-
"Array access for " . get_class($this) . " is deprecated, please use getter methods",
89-
E_USER_DEPRECATED
90-
);
91-
92-
return $this->data[$offset];
93-
}
94-
95-
/**
96-
* @throws ClientException
97-
*/
98-
public function offsetSet($offset, $value): void
99-
{
100-
throw new ClientException('Balance is read only');
101-
}
102-
103-
/**
104-
* @throws ClientException
105-
*/
106-
public function offsetUnset($offset): void
107-
{
108-
throw new ClientException('Balance is read only');
109-
}
110-
11140
public function fromArray(array $data): void
11241
{
11342
$this->data = [
@@ -120,21 +49,4 @@ public function toArray(): array
12049
{
12150
return $this->data;
12251
}
123-
124-
/**
125-
* @noinspection MagicMethodsValidityInspection
126-
*/
127-
public function __get($key): ?array
128-
{
129-
if ($key === 'data') {
130-
trigger_error(
131-
"Direct access to " . get_class($this) . "::data is deprecated, please use getter to toArray() methods",
132-
E_USER_DEPRECATED
133-
);
134-
135-
return $this->data;
136-
}
137-
138-
return null;
139-
}
14052
}

src/Account/Config.php

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,11 @@
1111

1212
namespace Vonage\Account;
1313

14-
use ArrayAccess;
15-
use JsonSerializable;
16-
use Vonage\Client\Exception\Exception as ClientException;
1714
use Vonage\Entity\Hydrator\ArrayHydrateInterface;
18-
use Vonage\Entity\JsonSerializableInterface;
19-
use Vonage\Entity\JsonUnserializableInterface;
2015

21-
use function get_class;
2216
use function is_null;
23-
use function trigger_error;
2417

2518
class Config implements
26-
JsonSerializable,
27-
JsonSerializableInterface,
28-
JsonUnserializableInterface,
29-
ArrayAccess,
3019
ArrayHydrateInterface
3120
{
3221
/**
@@ -101,16 +90,6 @@ public function getMaxCallsPerSecond()
10190
return $this->data['max_calls_per_second'];
10291
}
10392

104-
public function jsonUnserialize(array $json): void
105-
{
106-
trigger_error(
107-
get_class($this) . "::jsonUnserialize is deprecated, please fromArray() instead",
108-
E_USER_DEPRECATED
109-
);
110-
111-
$this->fromArray($json);
112-
}
113-
11493
public function fromArray(array $data): void
11594
{
11695
$this->data = [
@@ -122,66 +101,8 @@ public function fromArray(array $data): void
122101
];
123102
}
124103

125-
public function jsonSerialize(): array
126-
{
127-
return $this->toArray();
128-
}
129-
130104
public function toArray(): array
131105
{
132106
return $this->data;
133107
}
134-
135-
public function offsetExists($offset): bool
136-
{
137-
trigger_error(
138-
"Array access for " . get_class($this) . " is deprecated, please use getter methods",
139-
E_USER_DEPRECATED
140-
);
141-
142-
return isset($this->data[$offset]);
143-
}
144-
145-
public function offsetGet($offset)
146-
{
147-
trigger_error(
148-
"Array access for " . get_class($this) . " is deprecated, please use getter methods",
149-
E_USER_DEPRECATED
150-
);
151-
152-
return $this->data[$offset];
153-
}
154-
155-
/**
156-
* @throws ClientException
157-
*/
158-
public function offsetSet($offset, $value): void
159-
{
160-
throw new ClientException('Balance is read only');
161-
}
162-
163-
/**
164-
* @throws ClientException
165-
*/
166-
public function offsetUnset($offset): void
167-
{
168-
throw new ClientException('Balance is read only');
169-
}
170-
171-
/**
172-
* @noinspection MagicMethodsValidityInspection
173-
*/
174-
public function __get($key): ?array
175-
{
176-
if ($key === 'data') {
177-
trigger_error(
178-
"Direct access to " . get_class($this) . "::data is deprecated, please use getter to toArray() methods",
179-
E_USER_DEPRECATED
180-
);
181-
182-
return $this->data;
183-
}
184-
185-
return null;
186-
}
187108
}

0 commit comments

Comments
 (0)