diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3673c10 --- /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.6' + - 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..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.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.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/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/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/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..b91d269 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,8 @@ "redjanym/php-firebase-cloud-messaging": "^2.1" }, "require-dev": { - "phpunit/phpunit": "^9.5 || ^10.0", + "phpstan/phpstan": "^1.10", + "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", 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