File tree Expand file tree Collapse file tree 8 files changed +24
-29
lines changed
Expand file tree Collapse file tree 8 files changed +24
-29
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 99
1010A 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
Original file line number Diff line number Diff line change 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 ,
Original file line number Diff line number Diff line change 44
55namespace Kerox \Fcm \Api ;
66
7- use Doctrine \Common \Annotations \AnnotationReader ;
87use Fig \Http \Message \RequestMethodInterface ;
98use Http \Discovery \Psr18Client ;
109use Kerox \Fcm \Fcm ;
1110use Kerox \Fcm \Model \Message ;
1211use Psr \Http \Message \ResponseInterface ;
1312use Symfony \Component \Serializer \Encoder \JsonEncoder ;
1413use Symfony \Component \Serializer \Mapping \Factory \ClassMetadataFactory ;
15- use Symfony \Component \Serializer \Mapping \Loader \AnnotationLoader ;
14+ use Symfony \Component \Serializer \Mapping \Loader \AttributeLoader ;
1615use Symfony \Component \Serializer \NameConverter \CamelCaseToSnakeCaseNameConverter ;
1716use Symfony \Component \Serializer \NameConverter \MetadataAwareNameConverter ;
1817use 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 (
Original file line number Diff line number Diff line change 1414
1515 private Psr18Client $ client ;
1616
17- /**
18- * Fcm constructor.
19- */
2017 public function __construct (
2118 private string $ oauthToken ,
2219 private string $ projectId ,
Original file line number Diff line number Diff line change 1212 */
1313final 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}
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 44
55namespace Kerox \Fcm \Tests \Model ;
66
7- use Doctrine \Common \Annotations \AnnotationReader ;
87use Kerox \Fcm \Enum \AndroidMessagePriority ;
98use Kerox \Fcm \Enum \Direction ;
109use Kerox \Fcm \Enum \NotificationPriority ;
3231use PHPUnit \Framework \TestCase ;
3332use Symfony \Component \Serializer \Encoder \JsonEncoder ;
3433use Symfony \Component \Serializer \Mapping \Factory \ClassMetadataFactory ;
35- use Symfony \Component \Serializer \Mapping \Loader \AnnotationLoader ;
34+ use Symfony \Component \Serializer \Mapping \Loader \AttributeLoader ;
3635use Symfony \Component \Serializer \NameConverter \CamelCaseToSnakeCaseNameConverter ;
3736use Symfony \Component \Serializer \NameConverter \MetadataAwareNameConverter ;
3837use 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 (
You can’t perform that action at this time.
0 commit comments