From bfca327f4de29ccaaad7e4b4ab5b0d36a4ff3479 Mon Sep 17 00:00:00 2001 From: Redjan Ymeraj Date: Fri, 3 Apr 2026 16:58:08 +0200 Subject: [PATCH 1/2] Github CI, PHPStan --- .github/workflows/ci.yml | 74 +++++++++++++++++++++++++++ .phpunit.result.cache | 2 +- DependencyInjection/Configuration.php | 2 +- NotificationFactory.php | 4 ++ composer.json | 1 + phpstan.neon | 6 +++ 6 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 phpstan.neon diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0264778 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,74 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + tests: + name: Tests (PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - php: '7.4' + symfony: '5.4.*' + phpunit: '9.5.*' + - php: '8.1' + symfony: '5.4.*' + - php: '8.1' + symfony: '6.4.*' + - php: '8.2' + symfony: '6.4.*' + - php: '8.2' + symfony: '7.2.*' + - php: '8.3' + symfony: '7.2.*' + + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: Lock Symfony version + run: | + composer require --no-update \ + symfony/config:"${{ matrix.symfony }}" \ + symfony/dependency-injection:"${{ matrix.symfony }}" \ + symfony/http-kernel:"${{ matrix.symfony }}" \ + symfony/yaml:"${{ matrix.symfony }}" + + - name: Lock PHPUnit version + if: matrix.phpunit + run: composer require --dev --no-update phpunit/phpunit:"${{ matrix.phpunit }}" + + - name: Install dependencies + run: composer update --prefer-dist --no-progress + + - name: Run tests + run: vendor/bin/phpunit + + phpstan: + name: PHPStan + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + coverage: none + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + - name: Run PHPStan + run: vendor/bin/phpstan analyse diff --git a/.phpunit.result.cache b/.phpunit.result.cache index ac82fc9..6931883 100644 --- a/.phpunit.result.cache +++ b/.phpunit.result.cache @@ -1 +1 @@ -{"version":2,"defects":{"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testLoadRegistersServicesAndParameters":8,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testClientServiceIsPublic":8,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testNotificationFactoryServiceIsPublic":8},"times":{"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\ConfigurationTest::testValidConfiguration":0.004,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\ConfigurationTest::testServiceAccountFileIsRequired":0,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\ConfigurationTest::testServiceAccountFileCannotBeEmpty":0,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testLoadRegistersServicesAndParameters":0.007,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testClientServiceIsPublic":0,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testNotificationFactoryServiceIsPublic":0,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testCreateDeviceNotification":0,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testCreateDeviceNotificationWithMinimalArgs":0,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testCreateTopicNotification":0,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testCreateTopicNotificationWithMinimalArgs":0,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testTopicNotificationSerializesWithTopicKey":0.001,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testDeviceNotificationSerializesWithTokenKey":0,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testAutowiringAliases":0}} \ No newline at end of file +{"version":2,"defects":{"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testLoadRegistersServicesAndParameters":8,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testClientServiceIsPublic":8,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testNotificationFactoryServiceIsPublic":8},"times":{"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\ConfigurationTest::testValidConfiguration":0.006,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\ConfigurationTest::testServiceAccountFileIsRequired":0,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\ConfigurationTest::testServiceAccountFileCannotBeEmpty":0,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testLoadRegistersServicesAndParameters":0.014,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testClientServiceIsPublic":0,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testNotificationFactoryServiceIsPublic":0,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testCreateDeviceNotification":0,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testCreateDeviceNotificationWithMinimalArgs":0,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testCreateTopicNotification":0,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testCreateTopicNotificationWithMinimalArgs":0,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testTopicNotificationSerializesWithTopicKey":0.001,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testDeviceNotificationSerializesWithTokenKey":0,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testAutowiringAliases":0}} \ No newline at end of file diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 6cf36bf..5f260dc 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -18,7 +18,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('redjan_ym_fcm'); - $rootNode = method_exists(TreeBuilder::class, 'getRootNode') ? $treeBuilder->getRootNode() : $treeBuilder->root('redjan_ym_fcm'); + $rootNode = $treeBuilder->getRootNode(); $rootNode ->children() diff --git a/NotificationFactory.php b/NotificationFactory.php index 94831fc..8f3fdd9 100644 --- a/NotificationFactory.php +++ b/NotificationFactory.php @@ -10,6 +10,8 @@ class NotificationFactory { /** * Create a notification targeted at a specific device token. + * + * @param array $data */ public function createDeviceNotification(string $token, string $title, ?string $body = null, array $data = []): Notification { @@ -18,6 +20,8 @@ public function createDeviceNotification(string $token, string $title, ?string $ /** * Create a notification targeted at a topic. + * + * @param array $data */ public function createTopicNotification(string $topic, string $title, ?string $body = null, array $data = []): Notification { diff --git a/composer.json b/composer.json index b11a9bf..0d30d66 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "redjanym/php-firebase-cloud-messaging": "^2.1" }, "require-dev": { + "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^9.5 || ^10.0", "symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0", "symfony/config": "^5.4 || ^6.0 || ^7.0", diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..94fa794 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,6 @@ +parameters: + level: 6 + paths: + - DependencyInjection + - NotificationFactory.php + - RedjanYmFCMBundle.php From 187d8bffb3e53047de63f11ba24278018e76e693 Mon Sep 17 00:00:00 2001 From: Redjan Ymeraj Date: Fri, 3 Apr 2026 22:05:09 +0200 Subject: [PATCH 2/2] Fix phpunit versions --- .github/workflows/ci.yml | 2 +- .phpunit.result.cache | 2 +- Makefile | 7 +++++++ composer.json | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 Makefile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0264778..3673c10 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: include: - php: '7.4' symfony: '5.4.*' - phpunit: '9.5.*' + phpunit: '^9.6' - php: '8.1' symfony: '5.4.*' - php: '8.1' diff --git a/.phpunit.result.cache b/.phpunit.result.cache index 6931883..a602b27 100644 --- a/.phpunit.result.cache +++ b/.phpunit.result.cache @@ -1 +1 @@ -{"version":2,"defects":{"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testLoadRegistersServicesAndParameters":8,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testClientServiceIsPublic":8,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testNotificationFactoryServiceIsPublic":8},"times":{"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\ConfigurationTest::testValidConfiguration":0.006,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\ConfigurationTest::testServiceAccountFileIsRequired":0,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\ConfigurationTest::testServiceAccountFileCannotBeEmpty":0,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testLoadRegistersServicesAndParameters":0.014,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testClientServiceIsPublic":0,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testNotificationFactoryServiceIsPublic":0,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testCreateDeviceNotification":0,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testCreateDeviceNotificationWithMinimalArgs":0,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testCreateTopicNotification":0,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testCreateTopicNotificationWithMinimalArgs":0,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testTopicNotificationSerializesWithTopicKey":0.001,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testDeviceNotificationSerializesWithTokenKey":0,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testAutowiringAliases":0}} \ No newline at end of file +{"version":2,"defects":{"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testLoadRegistersServicesAndParameters":8,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testClientServiceIsPublic":8,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testNotificationFactoryServiceIsPublic":8},"times":{"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\ConfigurationTest::testValidConfiguration":0.007,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\ConfigurationTest::testServiceAccountFileIsRequired":0.001,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\ConfigurationTest::testServiceAccountFileCannotBeEmpty":0,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testLoadRegistersServicesAndParameters":0.012,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testClientServiceIsPublic":0,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testNotificationFactoryServiceIsPublic":0,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testCreateDeviceNotification":0.001,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testCreateDeviceNotificationWithMinimalArgs":0,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testCreateTopicNotification":0,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testCreateTopicNotificationWithMinimalArgs":0,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testTopicNotificationSerializesWithTopicKey":0.001,"RedjanYm\\FCMBundle\\Tests\\NotificationFactoryTest::testDeviceNotificationSerializesWithTokenKey":0,"RedjanYm\\FCMBundle\\Tests\\DependencyInjection\\RedjanYmFCMExtensionTest::testAutowiringAliases":0}} \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2f389a2 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +.PHONY: test phpstan + +test: + vendor/bin/phpunit + +phpstan: + vendor/bin/phpstan analyse diff --git a/composer.json b/composer.json index 0d30d66..b91d269 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "require-dev": { "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^9.5 || ^10.0", + "phpunit/phpunit": "^9.6 || ^10.0", "symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0", "symfony/config": "^5.4 || ^6.0 || ^7.0", "symfony/http-kernel": "^5.4 || ^6.0 || ^7.0",