Skip to content

Commit f7cdc63

Browse files
Wrong typing of the Grant Token endpoint (#108)
* Wrong typing of the Grant Token endpoint * linter fixes * fix errors and bump pubnub.yml * Add organization prefix to gh actions * fix typo in pubnub.yaml and bump php in test matrix * PubNub SDK 7.0.2 release. --------- Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com>
1 parent 41bb532 commit f7cdc63

File tree

9 files changed

+80
-86
lines changed

9 files changed

+80
-86
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
max-parallel: 1
2020
fail-fast: true
2121
matrix:
22-
php: [8.0, 8.1, 8.2]
22+
php: [8.1, 8.2, 8.3]
2323
env:
2424
PUBLISH_KEY: ${{ secrets.SDK_PUB_KEY }}
2525
SUBSCRIBE_KEY: ${{ secrets.SDK_SUB_KEY }}

.pubnub.yml

Lines changed: 46 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
name: php
2-
version: 7.0.1
2+
version: 7.0.2
33
schema: 1
44
scm: github.com/pubnub/php
55
changelog:
6+
- date: 2024-10-22
7+
version: 7.0.2
8+
changes:
9+
- type: bug
10+
text: "Fixed wrong type annotation for grant token response value."
11+
- type: improvement
12+
text: "Updated compatibility list."
613
- date: 2024-07-10
714
version: 7.0.1
815
changes:
@@ -319,25 +326,21 @@ sdks:
319326
supported-operating-systems:
320327
macOS:
321328
runtime-version:
322-
- PHP 5.6
323-
- PHP 7.0
324-
- PHP 7.1
325-
- PHP 7.2
326-
- PHP 7.3
329+
- PHP 8.1
330+
- PHP 8.2
331+
- PHP 8.3
327332
minimum-os-version:
328333
- Mac OS X 10.8
329334
maximum-os-version:
330-
- macOS 11.2.3
335+
- macOS 15.0.1
331336
target-architecture:
332337
- arm64
333338
- x86-64
334339
Windows:
335340
runtime-version:
336-
- PHP 5.6
337-
- PHP 7.0
338-
- PHP 7.1
339-
- PHP 7.2
340-
- PHP 7.3
341+
- PHP 8.1
342+
- PHP 8.2
343+
- PHP 8.3
341344
minimum-os-version:
342345
- Windows 7 Professional
343346
- Windows 7 Enterprise
@@ -350,15 +353,13 @@ sdks:
350353
- x86-64
351354
Linux:
352355
runtime-version:
353-
- PHP 5.6
354-
- PHP 7.0
355-
- PHP 7.1
356-
- PHP 7.2
357-
- PHP 7.3
356+
- PHP 8.1
357+
- PHP 8.2
358+
- PHP 8.3
358359
minimum-os-version:
359-
- Ubuntu 16.04 LTS
360+
- Ubuntu 20.04 LTS
360361
maximum-os-version:
361-
- Ubuntu 18.04 LTS
362+
- Ubuntu 24.04.1 LTS
362363
target-architecture:
363364
- x86
364365
- x86-64
@@ -387,25 +388,21 @@ sdks:
387388
supported-operating-systems:
388389
macOS:
389390
runtime-version:
390-
- PHP 5.6
391-
- PHP 7.0
392-
- PHP 7.1
393-
- PHP 7.2
394-
- PHP 7.3
391+
- PHP 8.1
392+
- PHP 8.2
393+
- PHP 8.3
395394
minimum-os-version:
396395
- Mac OS X 10.8
397396
maximum-os-version:
398-
- macOS 11.2.3
397+
- macOS 15.0.1
399398
target-architecture:
400399
- arm64
401400
- x86-64
402401
Windows:
403402
runtime-version:
404-
- PHP 5.6
405-
- PHP 7.0
406-
- PHP 7.1
407-
- PHP 7.2
408-
- PHP 7.3
403+
- PHP 8.1
404+
- PHP 8.2
405+
- PHP 8.3
409406
minimum-os-version:
410407
- Windows 7 Professional
411408
- Windows 7 Enterprise
@@ -418,22 +415,20 @@ sdks:
418415
- x86-64
419416
Linux:
420417
runtime-version:
421-
- PHP 5.6
422-
- PHP 7.0
423-
- PHP 7.1
424-
- PHP 7.2
425-
- PHP 7.3
418+
- PHP 8.1
419+
- PHP 8.2
420+
- PHP 8.3
426421
minimum-os-version:
427-
- Ubuntu 16.04 LTS
422+
- Ubuntu 20.04 LTS
428423
maximum-os-version:
429-
- Ubuntu 18.04 LTS
424+
- Ubuntu 24.04.1 LTS
430425
target-architecture:
431426
- x86
432427
- x86-64
433428
- distribution-type: library
434429
distribution-repository: GitHub release
435-
package-name: php-7.0.1.zip
436-
location: https://github.com/pubnub/php/releases/tag/7.0.1
430+
package-name: php-7.0.2.zip
431+
location: https://github.com/pubnub/php/releases/tag/7.0.2
437432
requires:
438433
- name: rmccue/requests
439434
min-version: 1.0.0
@@ -455,25 +450,21 @@ sdks:
455450
supported-operating-systems:
456451
macOS:
457452
runtime-version:
458-
- PHP 5.6
459-
- PHP 7.0
460-
- PHP 7.1
461-
- PHP 7.2
462-
- PHP 7.3
453+
- PHP 8.1
454+
- PHP 8.2
455+
- PHP 8.3
463456
minimum-os-version:
464457
- Mac OS X 10.8
465458
maximum-os-version:
466-
- macOS 11.2.3
459+
- macOS 15.0.1
467460
target-architecture:
468461
- arm64
469462
- x86-64
470463
Windows:
471464
runtime-version:
472-
- PHP 5.6
473-
- PHP 7.0
474-
- PHP 7.1
475-
- PHP 7.2
476-
- PHP 7.3
465+
- PHP 8.1
466+
- PHP 8.2
467+
- PHP 8.3
477468
minimum-os-version:
478469
- Windows 7 Professional
479470
- Windows 7 Enterprise
@@ -486,15 +477,13 @@ sdks:
486477
- x86-64
487478
Linux:
488479
runtime-version:
489-
- PHP 5.6
490-
- PHP 7.0
491-
- PHP 7.1
492-
- PHP 7.2
493-
- PHP 7.3
480+
- PHP 8.1
481+
- PHP 8.2
482+
- PHP 8.3
494483
minimum-os-version:
495-
- Ubuntu 16.04 LTS
484+
- Ubuntu 20.04 LTS
496485
maximum-os-version:
497-
- Ubuntu 18.04 LTS
486+
- Ubuntu 24.04.1 LTS
498487
target-architecture:
499488
- x86
500489
- x86-64

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 7.0.2
2+
October 22 2024
3+
4+
#### Fixed
5+
- Fixed wrong type annotation for grant token response value.
6+
7+
#### Modified
8+
- Updated compatibility list.
9+
110
## 7.0.1
211
July 10 2024
312

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ You will need the publish and subscribe keys to authenticate your app. Get your
4141
{
4242
"require": {
4343
<!-- include the latest version from the badge at the top -->
44-
"pubnub/pubnub": "7.0.1"
44+
"pubnub/pubnub": "7.0.2"
4545
}
4646
}
4747
```

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"keywords": ["api", "real-time", "realtime", "real time", "ajax", "push"],
66
"homepage": "http://www.pubnub.com/",
77
"license": "proprietary",
8-
"version": "7.0.1",
8+
"version": "7.0.2",
99
"authors": [
1010
{
1111
"name": "PubNub",

examples/GrantToken.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,37 @@
22

33
require_once __DIR__ . '/../vendor/autoload.php';
44

5-
use PubNub\Models\Access\Permissions;
65
use PubNub\Models\Consumer\AccessManager\PNAccessManagerTokenResult;
76

8-
97
$pnconfig = new \PubNub\PNConfiguration();
10-
$pnconfig->setPublishKey('my-publish-key');
11-
$pnconfig->setSubscribeKey('my-subscribe-key');
12-
$pnconfig->setSecretKey('my-secret-key');
8+
$pnconfig->setPublishKey(getenv("PUBLISH_PAM_KEY"));
9+
$pnconfig->setSubscribeKey(getenv("SUBSCRIBE_PAM_KEY"));
10+
$pnconfig->setSecretKey(getenv("SECRET_PAM_KEY"));
11+
$pnconfig->setUuid('example-uuid');
1312

1413
$pubnub = new \PubNub\PubNub($pnconfig);
1514

1615
try {
1716
$token = $pubnub->grantToken()
1817
->ttl(30)
19-
->authorizedUuid('my-uuid')
18+
->authorizedUuid('example-uuid')
2019
->addChannelResources([
2120
'my-channel' => ['read' => true]
2221
])
2322
->sync();
2423

25-
/** @var PNAccessManagerTokenResult */
26-
$parsedToken = $pubnub->parseToken($token);
27-
$parsedToken->getTtl();
28-
$parsedToken->getChannelResource('my-channel')
29-
->hasRead();
24+
print("Token granted: $token\n");
25+
26+
/** @var PNAccessManagerTokenResult */
27+
$parsedToken = $pubnub->parseToken($token);
28+
29+
$tokensTTL = $parsedToken->getTtl();
30+
$tokensMyChannelRead = $parsedToken->getChannelResource('my-channel')->hasRead();
31+
$tokensMyChannelWrite = $parsedToken->getChannelResource('my-channel')->hasWrite();
32+
33+
print("Token TTL: $tokensTTL\n");
34+
print("Token My Channel Read: " . (int)$tokensMyChannelRead . "\n");
35+
print("Token My Channel Write: " . (int)$tokensMyChannelWrite . "\n");
3036
} catch (\PubNub\Exceptions\PubNubServerException $e) {
3137
var_dump($e->getBody());
3238
}
33-
34-
var_dump(
35-
$pubnub->parseToken($token)->toArray()
36-
); die;

phpstan-baseline.neon

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,11 +460,6 @@ parameters:
460460
count: 1
461461
path: src/PubNub/Endpoints/Access/GrantToken.php
462462

463-
-
464-
message: "#^PHPDoc tag @return has invalid value \\(\\: PNAccessManagerGrantResult\\)\\: Unexpected token \"\\:\", expected type at offset 47$#"
465-
count: 1
466-
path: src/PubNub/Endpoints/Access/GrantToken.php
467-
468463
-
469464
message: "#^Property PubNub\\\\Endpoints\\\\Access\\\\GrantToken\\:\\:\\$channels has no type specified\\.$#"
470465
count: 1

src/PubNub/Endpoints/Access/GrantToken.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use PubNub\Endpoints\Endpoint;
66
use PubNub\Exceptions\PubNubValidationException;
7-
use PubNub\Models\Consumer\AccessManager\PNAccessManagerGrantResult;
87
use PubNub\PubNubUtil;
98
use PubNub\Enums\PNHttpMethod;
109
use PubNub\Enums\PNOperationType;
@@ -237,18 +236,18 @@ public function buildPath()
237236
}
238237

239238
/**
240-
* @return PNAccessManagerGrantResult
239+
* @return string
241240
*/
242-
public function sync(): PNAccessManagerGrantResult
241+
public function sync(): string
243242
{
244243
return parent::sync();
245244
}
246245

247246
/**
248247
* @param string $token
249-
* @return : PNAccessManagerGrantResult
248+
* @return string
250249
*/
251-
public function createResponse($response): PNAccessManagerGrantResult
250+
public function createResponse($response): string
252251
{
253252
return $response['data']['token'];
254253
}

src/PubNub/PubNub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757

5858
class PubNub implements LoggerAwareInterface
5959
{
60-
protected const SDK_VERSION = "7.0.1";
60+
protected const SDK_VERSION = "7.0.2";
6161
protected const SDK_NAME = "PubNub-PHP";
6262

6363
public static $MAX_SEQUENCE = 65535;

0 commit comments

Comments
 (0)