From ecb7ce466a2b3537ee5a75f393a25005a08f73d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gamez?= Date: Tue, 12 Jul 2022 11:54:05 +0200 Subject: [PATCH] Fix AndroidConfig's TTL not allowing `null` --- CHANGELOG.md | 6 ++++-- src/Firebase/Messaging/AndroidConfig.php | 4 ++-- tests/Unit/Messaging/AndroidConfigTest.php | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0298952..7f42bc7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,14 +5,16 @@ ### Fixed * The `WebPushConfig` class is now more lenient with TTL values, and urgencies are checked if they are valid - ([#713](https://github.com/kreait/firebase-php/issues/716) + ([#716](https://github.com/kreait/firebase-php/issues/716)) +* The `AndroidConfig` didn't allow the TTL to be `null`) + ([#719](https://github.com/kreait/firebase-php/issues/719)) ## [6.6.0] - 2022-07-07 ### Fixed * The `AndroidConfig` class is now more lenient with TTL values - ([#713](https://github.com/kreait/firebase-php/issues/713) + ([#713](https://github.com/kreait/firebase-php/issues/713)) ### Added diff --git a/src/Firebase/Messaging/AndroidConfig.php b/src/Firebase/Messaging/AndroidConfig.php index 238e1f1d..718ffa89 100644 --- a/src/Firebase/Messaging/AndroidConfig.php +++ b/src/Firebase/Messaging/AndroidConfig.php @@ -61,7 +61,7 @@ * @phpstan-type AndroidConfigShape array{ * collapse_key?: non-empty-string, * priority?: self::MESSAGE_PRIORITY_*, - * ttl?: positive-int|non-empty-string, + * ttl?: positive-int|non-empty-string|null, * restricted_package_name?: non-empty-string, * data?: array, * notification?: AndroidNotificationShape, @@ -108,7 +108,7 @@ public static function new(): self */ public static function fromArray(array $config): self { - if (array_key_exists('ttl', $config)) { + if (array_key_exists('ttl', $config) && $config['ttl'] !== null) { $config['ttl'] = self::ensureValidTtl($config['ttl']); } diff --git a/tests/Unit/Messaging/AndroidConfigTest.php b/tests/Unit/Messaging/AndroidConfigTest.php index 800f29c3..f620be40 100644 --- a/tests/Unit/Messaging/AndroidConfigTest.php +++ b/tests/Unit/Messaging/AndroidConfigTest.php @@ -106,7 +106,7 @@ public function validDataProvider(): array } /** - * @return array> + * @return array> */ public function validTtlValues(): array { @@ -117,6 +117,7 @@ public function validTtlValues(): array 'zero' => [0], 'zero string' => ['0'], 'zero string with suffix' => ['0s'], + 'null (#719)' => [null], ]; }