Skip to content

Commit 54495ea

Browse files
authored
Merge pull request #25 from ker0x/readme
📝 Add note about changed in v3.0
2 parents 9552d89 + 65c97c6 commit 54495ea

File tree

8 files changed

+24
-29
lines changed

8 files changed

+24
-29
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v4
1414

1515
- name: php-setup
1616
uses: shivammathur/setup-php@v2

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99

1010
A PHP library to send push notification with [Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging/)
1111

12-
## Warning
13-
14-
Version `3.x` of this library is a full rewrite using [PSR-18 HTTP Client](https://www.php-fig.org/psr/psr-18/) interface,
15-
which means that **no** HTTP Client, like [Guzzle](https://github.com/guzzle/guzzle) or [httplug](https://github.com/php-http/httplug),
16-
are provided within. If you already have one in your project, the package will **automatically discover it** and use it.
17-
Otherwise You will need to require one separately.
12+
> [!NOTE]
13+
> Version `3.x` of this library is a full rewrite using [PSR-18 HTTP Client](https://www.php-fig.org/psr/psr-18/) interface,
14+
> which means that **no** HTTP Client, like [Guzzle](https://github.com/guzzle/guzzle) or [httplug](https://github.com/php-http/httplug),
15+
> are provided within. If you already have one in your project, the package will **automatically discover it** and use it.
16+
> Otherwise You will need to require one separately.
1817
1918
## Installation
2019

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@
2525
"psr/http-client": "^1.0",
2626
"psr/http-client-implementation": "*",
2727
"psr/http-factory-implementation": "*",
28-
"symfony/property-access": "^6.2",
29-
"symfony/serializer": "^6.2"
28+
"symfony/property-access": "^6.4 || ^7.0",
29+
"symfony/serializer": "^6.4 || ^7.0"
3030
},
3131
"require-dev": {
3232
"friendsofphp/php-cs-fixer": "^3.16",
3333
"nyholm/psr7": "^1.8",
3434
"phpstan/phpstan": "^1.10",
3535
"phpunit/phpunit": "^10.1",
3636
"rector/rector": "^0.16.0",
37-
"symfony/http-client": "^6.2"
37+
"symfony/http-client": "^7.0"
3838
},
3939
"config": {
4040
"optimize-autoloader": true,

src/Api/Send.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44

55
namespace Kerox\Fcm\Api;
66

7-
use Doctrine\Common\Annotations\AnnotationReader;
87
use Fig\Http\Message\RequestMethodInterface;
98
use Http\Discovery\Psr18Client;
109
use Kerox\Fcm\Fcm;
1110
use Kerox\Fcm\Model\Message;
1211
use Psr\Http\Message\ResponseInterface;
1312
use Symfony\Component\Serializer\Encoder\JsonEncoder;
1413
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
15-
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
14+
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
1615
use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter;
1716
use Symfony\Component\Serializer\NameConverter\MetadataAwareNameConverter;
1817
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
@@ -30,7 +29,7 @@ public function __construct(
3029
private string $projectId,
3130
private Psr18Client $client
3231
) {
33-
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
32+
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
3433
$metadataAwareNameConverter = new MetadataAwareNameConverter($classMetadataFactory, new CamelCaseToSnakeCaseNameConverter());
3534

3635
$this->serializer = new Serializer(

src/Fcm.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

1515
private Psr18Client $client;
1616

17-
/**
18-
* Fcm constructor.
19-
*/
2017
public function __construct(
2118
private string $oauthToken,
2219
private string $projectId,

src/Model/Config/ApnsConfig.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,24 @@
1212
*/
1313
final readonly class ApnsConfig
1414
{
15-
public object $payload;
15+
public ?object $payload;
1616

1717
/**
1818
* @param array<string, string> $headers
1919
*/
2020
public function __construct(
21-
?ApnsNotification $notification = null,
21+
ApnsNotification $notification = null,
2222
public array $headers = [],
2323
public ?ApnsFcmOptions $fcmOptions = null,
2424
) {
25-
if (null !== $notification) {
26-
$this->payload = new class($notification) {
25+
$this->payload = null !== $notification
26+
? new class($notification) {
2727
public function __construct(
2828
public ApnsNotification $aps
2929
) {
3030
}
31-
};
32-
}
31+
}
32+
: null
33+
;
3334
}
3435
}

src/Model/Message.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
/**
1717
* @see https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#resource:-message
1818
*/
19-
final readonly class Message
19+
final class Message
2020
{
2121
public Notification $notification;
22-
public ?string $token;
23-
public ?string $topic;
24-
public ?string $condition;
22+
public ?string $token = null;
23+
public ?string $topic = null;
24+
public ?string $condition = null;
2525

2626
/**
2727
* @param array<string, string> $data

tests/Model/MessageTest.php

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

55
namespace Kerox\Fcm\Tests\Model;
66

7-
use Doctrine\Common\Annotations\AnnotationReader;
87
use Kerox\Fcm\Enum\AndroidMessagePriority;
98
use Kerox\Fcm\Enum\Direction;
109
use Kerox\Fcm\Enum\NotificationPriority;
@@ -32,7 +31,7 @@
3231
use PHPUnit\Framework\TestCase;
3332
use Symfony\Component\Serializer\Encoder\JsonEncoder;
3433
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
35-
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
34+
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
3635
use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter;
3736
use Symfony\Component\Serializer\NameConverter\MetadataAwareNameConverter;
3837
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
@@ -46,7 +45,7 @@ final class MessageTest extends TestCase
4645

4746
protected function setUp(): void
4847
{
49-
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
48+
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
5049
$metadataAwareNameConverter = new MetadataAwareNameConverter($classMetadataFactory, new CamelCaseToSnakeCaseNameConverter());
5150

5251
$this->serializer = new Serializer(

0 commit comments

Comments
 (0)