10000 Merge branch 'release/1.1.0' · sunaoka/push-notifications-php@95512f4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 95512f4

Browse files
committed
Merge branch 'release/1.1.0'
2 parents df7052f + a1ff834 commit 95512f4

30 files changed

+404
-121
lines changed

.github/workflows/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
issues: write
1212
pull-requests: write
1313
steps:
14-
- uses: actions/stale@v7
14+
- uses: actions/stale@v9
1515
with:
1616
days-before-issue-stale: 30
1717
days-before-issue-close: 14

.github/workflows/test.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ on:
99
jobs:
1010
test:
1111
runs-on: ${{ matrix.os }}
12+
13+
env:
14+
latest_php: 8.4
15+
1216
strategy:
1317
fail-fast: false
1418
matrix:
1519
os: [ ubuntu-latest ]
1620
php: [
1721
'5.5', '5.6',
1822
'7.0', '7.1', '7.2', '7.3', '7.4',
19-
'8.0', '8.1', '8.2', '8.3'
23+
'8.0', '8.1', '8.2', '8.3', '8.4'
2024
]
2125

2226
name: PHP ${{ matrix.php }}
@@ -31,18 +35,22 @@ jobs:
3135
uses: actions/checkout@v4
3236

3337
- name: Install dependencies
34-
run: composer install --no-ansi --prefer-dist --no-progress --no-interaction
38+
uses: nick-fields/retry@v3
39+
with:
40+
timeout_seconds: 30
41+
max_attempts: 3
42+
command: composer install --no-ansi --prefer-dist --no-progress --no-interaction
3543

3644
- name: Migrate phpunit XML configuration
37-
continue-on-error: true
38-
run: vendor/bin/phpunit --migrate-configuration
45+
run: vendor/bin/phpunit --migrate-configuration || true
3946

4047
- name: Run test suite
4148
run: vendor/bin/phpunit --coverage-clover=coverage.xml
4249

4350
- name: Upload coverage to Codecov
44-
uses: codecov/codecov-action@v4
51+
uses: codecov/codecov-action@v5
4552
with:
4653
token: ${{ secrets.CODECOV_TOKEN }}
4754
files: ./coverage.xml
4855
fail_ci_if_error: false
56+
if: matrix.php == env.latest_php

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
# Release Notes
22

3-
## [Unreleased](https://github.com/sunaoka/push-notifications-php/compare/1.0.5...develop)
3+
## [Unreleased](https://github.com/sunaoka/push-notifications-php/compare/1.1.0...develop)
4+
5+
## [v1.1.0 (2024-12-13)](https://github.com/sunaoka/push-notifications-php/compare/1.0.6...1.1.0)
6+
7+
### Added
8+
9+
- Support PHP 8.4
10+
11+
### Changed
12+
13+
- Types are specified in the array.
14+
15+
## [v1.0.6 (2024-04-19)](https://github.com/sunaoka/push-notifications-php/compare/1.0.5...1.0.6)
416

517
### Changed
618

719
- Support PHPUnit 11.x
820
- Deprecated FCM HTTP legacy APIs
921
- Because the FCM HTTP legacy APIs was deprecated on June 20, 2023, and will be removed in June 2024.
22+
- Support for retrieving FCM error messages.
1023

1124
## [v1.0.5 (2023-02-08)](https://github.com/sunaoka/push-notifications-php/compare/1.0.4...1.0.5)
1225

phpstan.neon

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
1+
includes:
2+
- phar://phpstan.phar/conf/bleedingEdge.neon
3+
14
parameters:
25

36
paths:
47
- src
8+
- tests
59

6-
level: 9
7-
8-
checkMissingIterableValueType: false
10+
level: 10
911

1012
ignoreErrors:
11-
-
12-
message: '!Property Sunaoka\\PushNotifications\\Drivers\\FCM\\V1::\$httpClient!'
13-
path: src/Drivers/FCM/V1.php
14-
-
15-
message: '!Parameter #1 \$errors of class!'
16-
path: src/Drivers/DriverOption.php
17-
-
18-
message: '!Else branch is unreachable because previous condition is always true!'
19-
path: src/Drivers/Driver.php
20-
-
21-
message: "!Offset 'class' does not exist on array{function: string, line\\?: int, file\\?: string, class\\?: class-string, type\\?: '->'\\|'::', args\\?: array, object\\?: object}!"
22-
path: src/Exceptions/OptionTypeError.php
13+
- identifier: function.alreadyNarrowedType
14+
path: tests/Assert.php

src/Drivers/APNs/Certificate.php

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

33
namespace Sunaoka\PushNotifications\Drivers\APNs;
44

5-
use Exception;
65
use GuzzleHttp;
76
use Sunaoka\PushNotifications\Drivers\Driver;
87
use Sunaoka\PushNotifications\Drivers\Feedback;
@@ -40,7 +39,8 @@ class Certificate extends Driver
4039
*/
4140
public function __construct($options)
4241
{
43-
if (!$options instanceof Certificate\Option) {
42+
// @phpstan-ignore instanceof.alwaysTrue
43+
if (! $options instanceof Certificate\Option) {
4444
throw new OptionTypeError(Certificate\Option::class, $options);
4545
}
4646

@@ -90,12 +90,12 @@ private function _send($device)
9090

9191
return;
9292

93-
} catch (Exception $e) {
93+
} catch (\Exception $e) {
9494
$error = $this->parseErrorResponse($e);
9595
}
9696

9797
if (isset($error['contents'])) {
98-
/** @var array $json */
98+
/** @var array{reason: string} $json */
9999
$json = json_decode($error['contents'], true);
100100
$this->feedback->addFailure($device, $json['reason']);
101101
} else {

src/Drivers/APNs/Token.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
namespace Sunaoka\PushNotifications\Drivers\APNs;
44

5-
use Exception;
65
use GuzzleHttp;
7-
use RuntimeException;
86
use Sunaoka\PushNotifications\Drivers\Driver;
97
use Sunaoka\PushNotifications\Drivers\Feedback;
108
use Sunaoka\PushNotifications\Exceptions\OptionTypeError;
@@ -41,7 +39,8 @@ class Token extends Driver
4139
*/
4240
public function __construct($options)
4341
{
44-
if (!$options instanceof Token\Option) {
42+
// @phpstan-ignore instanceof.alwaysTrue
43+
if (! $options instanceof Token\Option) {
4544
throw new OptionTypeError(Token\Option::class, $options);
4645
}
4746

@@ -92,12 +91,12 @@ private function _send($device)
9291

9392
return;
9493

95-
} catch (Exception $e) {
94+
} catch (\Exception $e) {
9695
$error = $this->parseErrorResponse($e);
9796
}
9897

9998
if (isset($error['contents'])) {
100-
/** @var array $json */
99+
/** @var array{reason: string} $json */
101 F438 100
$json = json_decode($error['contents'], true);
102101
$this->feedback->addFailure($device, $json['reason']);
103102
} else {
@@ -120,7 +119,7 @@ private function bearerToken($authKey, $keyId, $teamId)
120119

121120
$key = openssl_pkey_get_private($authKey);
122121
if ($key === false) {
123-
throw new RuntimeException((string) openssl_error_string()); // @codeCoverageIgnore
122+
throw new \RuntimeException((string) openssl_error_string()); // @codeCoverageIgnore
124123
}
125124

126125
$segments = [];
@@ -129,9 +128,10 @@ private function bearerToken($authKey, $keyId, $teamId)
129128

130129
$success = openssl_sign(implode('.', $segments), $signature, $key, 'sha256');
131130
if ($success === false) {
132-
throw new RuntimeException((string) openssl_error_string()); // @codeCoverageIgnore
131+
throw new \RuntimeException((string) openssl_error_string()); // @codeCoverageIgnore
133132
}
134133

134+
/** @var string $signature */
135135
$segments[] = $this->encodeB64URLSafe($signature);
136136

137137
return 'bearer ' . implode('.', $segments);

src/Drivers/Driver.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Sunaoka\PushNotifications\Drivers;
44

5-
use Exception;
65
use GuzzleHttp;
76
use GuzzleHttp\Exception\ClientException;
87
use GuzzleHttp\Exception\ServerException;
@@ -20,7 +19,7 @@ abstract class Driver implements DriverInterface
2019
protected $endpointProduction = '';
2120

2221
/**
23-
* @var array
22+
* @var string[]
2423
*/
2524
protected $devices;
2625

@@ -48,7 +47,7 @@ public function getOptions()
4847
}
4948

5049
/**
51-
* @param array $devices
50+
* @param string[] $devices
5251
*
5352
* @return self
5453
*/
@@ -92,7 +91,7 @@ public function setHttpHandler($httpHandler)
9291
}
9392

9493
/**
95-
* @param array $config
94+
* @param array<string, mixed> $config
9695
*
9796
* @return GuzzleHttp\Client
9897
*/
@@ -114,7 +113,7 @@ protected function getEndpoint($replace = '')
114113
}
115114

116115
/**
117-
* @param Exception $e
116+
* @param \Exception $e
118117
*
119118
* @return array{message: string, contents: ?string}
120119
*/
@@ -124,6 +123,7 @@ protected function parseErrorResponse($e)
124123

125124
if ($e instanceof ClientException || $e instanceof ServerException) {
126125
$response = $e->getResponse();
126+
// @phpstan-ignore notIdentical.alwaysTrue
127127
if ($response !== null) {
128128
$message = $response->getReasonPhrase();
129129
$contents = $response->getBody()->getContents();
@@ -136,7 +136,7 @@ protected function parseErrorResponse($e)
136136

137137
return [
138138
'message' => $message,
139-
'contents' => !empty($contents) ? $contents : null,
139+
'contents' => ! empty($contents) ? $contents : null,
140140
];
141141
}
142142
}

src/Drivers/DriverInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function __construct($options);
1515
public function getOptions();
1616

1717
/**
18-
* @param array $devices
18+
* @param string[] $devices
1919
*
2020
* @return self
2121
*/

src/Drivers/DriverOption.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@
88
abstract class DriverOption implements DriverOptionInterface
99
{
1010
/**
11-
* @var array
11+
* @var array<string, mixed>
1212
*/
1313
public $payload = [];
1414

1515
/**
1616
* Guzzle Request Options
1717
*
18-
* <https://docs.guzzlephp.org/en/stable/request-options.html>
19-
*
20-
* @var array
18+
* @var array<string, mixed>
19+
* @link https://docs.guzzlephp.org/en/stable/request-options.html
2120
*/
2221
public $httpOptions = [];
2322

@@ -33,9 +32,6 @@ abstract class DriverOption implements DriverOptionInterface
3332
'payload' => ['required'],
3433
];
3534

36-
/**
37-
* @inheritDoc
38-
*/
3935
public function __construct($options = [])
4036
{
4137
foreach ($options as $key => $value) {
@@ -45,14 +41,12 @@ public function __construct($options = [])
4541
}
4642
}
4743

48-
/**
49-
* @inheritDoc
50-
*/
5144
public function validate()
5245
{
53-
$validator = new Validator((array)$this);
46+
$validator = new Validator((array) $this);
5447
$validator->mapFieldsRules(array_merge($this->defaultValidationRules, $this->validationRules));
55-
if (!$validator->validate()) {
48+
if (! $validator->validate()) {
49+
// @phpstan-ignore argument.type
5650
throw new ValidationException($validator->errors());
5751
}
5852

src/Drivers/DriverOptionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
interface DriverOptionInterface
88
{
99
/**
10-
* @param array $options
10+
* @param array<string, mixed> $options
1111
*/
1212
public function __construct($options = []);
1313

0 commit comments

Comments
 (0)
0