Skip to content

Commit 92dace6

Browse files
Dropped support for PHP 7.2 (#342)
1 parent 23a78b8 commit 92dace6

18 files changed

+26
-255
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ cache:
2727

2828
jobs:
2929
include:
30-
- php: 7.2
3130
- php: 7.3
3231
- php: 7.4
3332
- php: nightly

README.md

+2-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ As it is standardized, you don't have to worry about what server type it relies
1010

1111
## Requirements
1212

13-
PHP 7.2+ and the following extensions:
13+
PHP 7.3+ and the following extensions:
1414
* gmp (optional but better for performance)
1515
* mbstring
1616
* curl
@@ -322,7 +322,7 @@ Internally, WebPush uses the [WebToken](https://github.com/web-token) framework
322322
### How do I scale?
323323
Here are some ideas:
324324

325-
1. Upgrade to PHP 7.2
325+
1. Upgrade to PHP 7.3
326326
2. Make sure MultiCurl is available on your server
327327
3. Find the right balance for your needs between security and performance (see above)
328328
4. Find the right batch size (set it in `defaultOptions` or as parameter to `flush()`)
@@ -345,11 +345,6 @@ Make sure to require Composer's [autoloader](https://getcomposer.org/doc/01-basi
345345
require __DIR__ . '/path/to/vendor/autoload.php';
346346
```
347347

348-
### I must use PHP 5.4 or 5.5. What can I do?
349-
You won't be able to send any payload, so you'll only be able to use `sendOneNotification($subscription)` or `queueNotification($subscription)`.
350-
Install the library with `composer` using `--ignore-platform-reqs`.
351-
The workaround for getting the payload is to fetch it in the service worker ([example](https://github.com/Minishlink/physbook/blob/2ed8b9a8a217446c9747e9191a50d6312651125d/web/service-worker.js#L75)).
352-
353348
### I lost my VAPID keys!
354349
See [issue #58](https://github.com/web-push-libs/web-push-php/issues/58).
355350

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"test:syntax": "./vendor/bin/php-cs-fixer fix ./src --dry-run --stop-on-violation --using-cache=no"
1919
},
2020
"require": {
21-
"php": ">=7.2",
21+
"php": ">=7.3",
2222
"ext-curl": "*",
2323
"ext-json": "*",
2424
"ext-mbstring": "*",

src/Encryption.php

+1-43
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ class Encryption
2626
public const MAX_COMPATIBILITY_PAYLOAD_LENGTH = 3052;
2727

2828
/**
29-
* @param string $payload
30-
* @param int $maxLengthToPad
31-
* @param string $contentEncoding
3229
* @return string padded payload (plaintext)
3330
* @throws \ErrorException
3431
*/
@@ -50,8 +47,6 @@ public static function padPayload(string $payload, int $maxLengthToPad, string $
5047
* @param string $payload With padding
5148
* @param string $userPublicKey Base 64 encoded (MIME or URL-safe)
5249
* @param string $userAuthToken Base 64 encoded (MIME or URL-safe)
53-
* @param string $contentEncoding
54-
* @return array
5550
*
5651
* @throws \ErrorException
5752
*/
@@ -68,14 +63,6 @@ public static function encrypt(string $payload, string $userPublicKey, string $u
6863
}
6964

7065
/**
71-
* @param string $payload
72-
* @param string $userPublicKey
73-
* @param string $userAuthToken
74-
* @param string $contentEncoding
75-
* @param array $localKeyObject
76-
* @param string $salt
77-
* @return array
78-
*
7966
* @throws \ErrorException
8067
*/
8168
public static function deterministicEncrypt(string $payload, string $userPublicKey, string $userAuthToken, string $contentEncoding, array $localKeyObject, string $salt): array
@@ -90,7 +77,7 @@ public static function deterministicEncrypt(string $payload, string $userPublicK
9077
$localPublicKey = hex2bin(Utils::serializePublicKeyFromJWK($localJwk));
9178
} else {
9279
/** @var PrivateKey $localPrivateKeyObject */
93-
list($localPublicKeyObject, $localPrivateKeyObject) = $localKeyObject;
80+
[$localPublicKeyObject, $localPrivateKeyObject] = $localKeyObject;
9481
$localPublicKey = hex2bin(Utils::serializePublicKey($localPublicKeyObject));
9582
$localJwk = new JWK([
9683
'kty' => 'EC',
@@ -178,8 +165,6 @@ public static function getContentCodingHeader(string $salt, string $localPublicK
178165
* @param string $ikm Input keying material
179166
* @param string $info Application-specific context
180167
* @param int $length The length (in bytes) of the required output key
181-
*
182-
* @return string
183168
*/
184169
private static function hkdf(string $salt, string $ikm, string $info, int $length): string
185170
{
@@ -199,8 +184,6 @@ private static function hkdf(string $salt, string $ikm, string $info, int $lengt
199184
* @param string $clientPublicKey The client's public key
200185
* @param string $serverPublicKey Our public key
201186
*
202-
* @return null|string
203-
*
204187
* @throws \ErrorException
205188
*/
206189
private static function createContext(string $clientPublicKey, string $serverPublicKey, string $contentEncoding): ?string
@@ -230,8 +213,6 @@ private static function createContext(string $clientPublicKey, string $serverPub
230213
*
231214
* @param string $type The type of the info record
232215
* @param string|null $context The context for the record
233-
* @param string $contentEncoding
234-
* @return string
235216
*
236217
* @throws \ErrorException
237218
*/
@@ -254,9 +235,6 @@ private static function createInfo(string $type, ?string $context, string $conte
254235
throw new \ErrorException('This content encoding is not supported.');
255236
}
256237

257-
/**
258-
* @return array
259-
*/
260238
private static function createLocalKeyObject(): array
261239
{
262240
try {
@@ -266,9 +244,6 @@ private static function createLocalKeyObject(): array
266244
}
267245
}
268246

269-
/**
270-
* @return array
271-
*/
272247
private static function createLocalKeyObjectUsingPurePhpMethod(): array
273248
{
274249
$curve = NistCurve::curve256();
@@ -298,9 +273,6 @@ private static function createLocalKeyObjectUsingPurePhpMethod(): array
298273
];
299274
}
300275

301-
/**
302-
* @return array
303-
*/
304276
private static function createLocalKeyObjectUsingOpenSSL(): array
305277
{
306278
$keyResource = openssl_pkey_new([
@@ -333,12 +305,6 @@ private static function createLocalKeyObjectUsingOpenSSL(): array
333305
}
334306

335307
/**
336-
* @param string $userAuthToken
337-
* @param string $userPublicKey
338-
* @param string $localPublicKey
339-
* @param string $sharedSecret
340-
* @param string $contentEncoding
341-
* @return string
342308
* @throws \ErrorException
343309
*/
344310
private static function getIKM(string $userAuthToken, string $userPublicKey, string $localPublicKey, string $sharedSecret, string $contentEncoding): string
@@ -396,21 +362,13 @@ private static function calculateAgreementKey(JWK $private_key, JWK $public_key)
396362
}
397363
}
398364

399-
/**
400-
* @param string $value
401-
* @return BigInteger
402-
*/
403365
private static function convertBase64ToBigInteger(string $value): BigInteger
404366
{
405367
$value = unpack('H*', Base64Url::decode($value));
406368

407369
return BigInteger::fromBase($value[1], 16);
408370
}
409371

410-
/**
411-
* @param string $value
412-
* @return \GMP
413-
*/
414372
private static function convertBase64ToGMP(string $value): \GMP
415373
{
416374
$value = unpack('H*', Base64Url::decode($value));

src/MessageSentReport.php

+1-52
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515
class MessageSentReport implements \JsonSerializable
1616
{
17-
1817
/**
1918
* @var boolean
2019
*/
@@ -36,10 +35,7 @@ class MessageSentReport implements \JsonSerializable
3635
protected $reason;
3736

3837
/**
39-
* @param RequestInterface $request
40-
* @param ResponseInterface $response
41-
* @param bool $success
42-
* @param string $reason
38+
* @param string $reason
4339
*/
4440
public function __construct(RequestInterface $request, ?ResponseInterface $response = null, bool $success = true, $reason = 'OK')
4541
{
@@ -49,74 +45,44 @@ public function __construct(RequestInterface $request, ?ResponseInterface $respo
4945
$this->reason = $reason;
5046
}
5147

52-
/**
53-
* @return bool
54-
*/
5548
public function isSuccess(): bool
5649
{
5750
return $this->success;
5851
}
5952

60-
/**
61-
* @param bool $success
62-
*
63-
* @return MessageSentReport
64-
*/
6553
public function setSuccess(bool $success): MessageSentReport
6654
{
6755
$this->success = $success;
6856
return $this;
6957
}
7058

71-
/**
72-
* @return RequestInterface
73-
*/
7459
public function getRequest(): RequestInterface
7560
{
7661
return $this->request;
7762
}
7863

79-
/**
80-
* @param RequestInterface $request
81-
*
82-
* @return MessageSentReport
83-
*/
8464
public function setRequest(RequestInterface $request): MessageSentReport
8565
{
8666
$this->request = $request;
8767
return $this;
8868
}
8969

90-
/**
91-
* @return ResponseInterface | null
92-
*/
9370
public function getResponse(): ?ResponseInterface
9471
{
9572
return $this->response;
9673
}
9774

98-
/**
99-
* @param ResponseInterface $response
100-
*
101-
* @return MessageSentReport
102-
*/
10375
public function setResponse(ResponseInterface $response): MessageSentReport
10476
{
10577
$this->response = $response;
10678
return $this;
10779
}
10880

109-
/**
110-
* @return string
111-
*/
11281
public function getEndpoint(): string
11382
{
11483
return $this->request->getUri()->__toString();
11584
}
11685

117-
/**
118-
* @return bool
119-
*/
12086
public function isSubscriptionExpired(): bool
12187
{
12288
if (!$this->response) {
@@ -126,36 +92,22 @@ public function isSubscriptionExpired(): bool
12692
return \in_array($this->response->getStatusCode(), [404, 410], true);
12793
}
12894

129-
/**
130-
* @return string
131-
*/
13295
public function getReason(): string
13396
{
13497
return $this->reason;
13598
}
13699

137-
/**
138-
* @param string $reason
139-
*
140-
* @return MessageSentReport
141-
*/
142100
public function setReason(string $reason): MessageSentReport
143101
{
144102
$this->reason = $reason;
145103
return $this;
146104
}
147105

148-
/**
149-
* @return string
150-
*/
151106
public function getRequestPayload(): string
152107
{
153108
return $this->request->getBody()->getContents();
154109
}
155110

156-
/**
157-
* @return string | null
158-
*/
159111
public function getResponseContent(): ?string
160112
{
161113
if (!$this->response) {
@@ -165,9 +117,6 @@ public function getResponseContent(): ?string
165117
return $this->response->getBody()->getContents();
166118
}
167119

168-
/**
169-
* @return array
170-
*/
171120
public function jsonSerialize(): array
172121
{
173122
return [

src/Notification.php

-24
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ class Notification
2727
/** @var array Auth details : VAPID */
2828
private $auth;
2929

30-
/**
31-
* Notification constructor.
32-
*
33-
* @param SubscriptionInterface $subscription
34-
* @param null|string $payload
35-
* @param array $options
36-
* @param array $auth
37-
*/
3830
public function __construct(SubscriptionInterface $subscription, ?string $payload, array $options, array $auth)
3931
{
4032
$this->subscription = $subscription;
@@ -43,27 +35,16 @@ public function __construct(SubscriptionInterface $subscription, ?string $payloa
4335
$this->auth = $auth;
4436
}
4537

46-
/**
47-
* @return SubscriptionInterface
48-
*/
4938
public function getSubscription(): SubscriptionInterface
5039
{
5140
return $this->subscription;
5241
}
5342

54-
/**
55-
* @return null|string
56-
*/
5743
public function getPayload(): ?string
5844
{
5945
return $this->payload;
6046
}
6147

62-
/**
63-
* @param array $defaultOptions
64-
*
65-
* @return array
66-
*/
6748
public function getOptions(array $defaultOptions = []): array
6849
{
6950
$options = $this->options;
@@ -74,11 +55,6 @@ public function getOptions(array $defaultOptions = []): array
7455
return $options;
7556
}
7657

77-
/**
78-
* @param array $defaultAuth
79-
*
80-
* @return array
81-
*/
8258
public function getAuth(array $defaultAuth): array
8359
{
8460
return count($this->auth) > 0 ? $this->auth : $defaultAuth;

0 commit comments

Comments
 (0)