Skip to content

Commit

Permalink
Fix AndroidConfig's TTL not allowing null
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegamez committed Jul 12, 2022
1 parent d477a6f commit ecb7ce4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/Firebase/Messaging/AndroidConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<non-empty-string, non-empty-string>,
* notification?: AndroidNotificationShape,
Expand Down Expand Up @@ -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']);
}

Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Messaging/AndroidConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function validDataProvider(): array
}

/**
* @return array<string, list<int|string>>
* @return array<string, list<int|string|null>>
*/
public function validTtlValues(): array
{
Expand All @@ -117,6 +117,7 @@ public function validTtlValues(): array
'zero' => [0],
'zero string' => ['0'],
'zero string with suffix' => ['0s'],
'null (#719)' => [null],
];
}

Expand Down

0 comments on commit ecb7ce4

Please sign in to comment.