diff --git a/.github/workflows/backward-compatibility.yml b/.github/workflows/backward-compatibility.yml new file mode 100644 index 000000000..f1b7596d7 --- /dev/null +++ b/.github/workflows/backward-compatibility.yml @@ -0,0 +1,41 @@ +name: Backward Compatibility Check + +on: + pull_request: + branches: ['7.x'] + paths: + - 'src/**' + - 'composer.json' + - '.github/workflows/backward-compatibility.yml' + push: + branches: ['7.x'] + paths: + - 'src/**' + - 'composer.json' + - '.github/workflows/backward-compatibility.yml' + workflow_dispatch: + +permissions: + contents: read + +jobs: + bc-checks: + name: Backward Compatibility Check + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.3 + extensions: grpc + + - name: Install roave/backward-compatibility-check + run: composer require --dev roave/backward-compatibility-check + + - name: Check for BC breaks + run: vendor/bin/roave-backward-compatibility-check --format=github-actions diff --git a/.github/workflows/dependabot-auto-approve.yml b/.github/workflows/dependabot-auto-approve.yml deleted file mode 100644 index 90671b2d9..000000000 --- a/.github/workflows/dependabot-auto-approve.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Dependabot auto-approve -on: pull_request - -permissions: - pull-requests: write - -jobs: - dependabot: - runs-on: ubuntu-latest - if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'kreait/firebase-php' - steps: - - name: Dependabot metadata - id: metadata - uses: dependabot/fetch-metadata@v2.4.0 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - name: Approve a PR - run: gh pr review --approve "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GH_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index a4197750c..ac0e09b37 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -9,7 +9,7 @@ on: - 'README.md' - 'lychee.toml' push: - branches: ['7.x'] + branches: ['8.x'] paths: - 'docs/**' - '.github/workflows/docs.yml' @@ -27,7 +27,6 @@ jobs: links: name: Check Links runs-on: ubuntu-latest - if: github.actor != 'dependabot[bot]' steps: - name: Checkout repository diff --git a/.github/workflows/emulator-tests.yml b/.github/workflows/emulator-tests.yml index 41a8b7acd..5e6ed5e27 100644 --- a/.github/workflows/emulator-tests.yml +++ b/.github/workflows/emulator-tests.yml @@ -8,7 +8,7 @@ on: - 'tests/**' - 'phpstan.neon.dist' push: - branches: ['7.x'] + branches: ['8.x'] paths: - 'src/**' - 'tests/**' @@ -24,12 +24,11 @@ jobs: emulator-tests: name: Emulator Tests runs-on: ubuntu-latest - if: github.actor != 'dependabot[bot]' env: php-version: '8.4' extensions: ctype, dom, grpc, json, mbstring, openssl, xml, zip, zlib - key: cache-emulators-7x-83-v1 + key: cache-emulators-8x steps: - name: Checkout code diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 7de5f5ad1..6b8d68e61 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -8,7 +8,7 @@ on: - 'tests/**' - 'phpstan.neon.dist' push: - branches: ['7.x'] + branches: ['8.x'] paths: - 'src/**' - 'tests/**' @@ -24,12 +24,11 @@ jobs: integration-tests: name: Integration Tests runs-on: ubuntu-latest - if: github.actor != 'dependabot[bot]' env: php-version: '8.4' extensions: ctype, dom, grpc, json, mbstring, openssl, xml, zip, zlib - key: cache-integration-7x-83-v1 + key: cache-integration-8x steps: - name: Checkout code diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index ab61c1194..31e01de41 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -9,7 +9,7 @@ on: - 'composer.json' - 'phpstan.neon.dist' push: - branches: ['7.x'] + branches: ['8.x'] paths: - 'src/**' - 'tests/**' @@ -25,23 +25,18 @@ jobs: phpstan: name: "PHPStan (PHP ${{ matrix.php }})" runs-on: ubuntu-latest - if: github.actor != 'dependabot[bot]' strategy: fail-fast: false matrix: php: - - "8.1" - - "8.2" - "8.3" - "8.4" - include: - - php: "8.5" - composer-options: "--ignore-platform-reqs" + - "8.5" env: extensions: ctype, dom, grpc, json, mbstring, openssl, xml, zip, zlib - key: cache-static-analysis-7x-${{ matrix.php }}-v1 + key: cache-static-analysis-8x-${{ matrix.php }} steps: - name: Checkout code diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c0afe3c15..fa8346bf6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,7 +9,7 @@ on: - 'composer.json' - 'phpstan.neon.dist' push: - branches: ['7.x'] + branches: ['8.x'] paths: - 'src/**' - 'tests/**' @@ -25,27 +25,21 @@ jobs: tests: name: "PHP ${{ matrix.php }}, ${{ matrix.dependencies }} deps" runs-on: ubuntu-latest - if: github.actor != 'dependabot[bot]' strategy: fail-fast: false matrix: php: - - "8.1" - - "8.2" - "8.3" - "8.4" + - "8.5" dependencies: - "lowest" - "highest" - include: - - php: "8.5" - composer-options: "--ignore-platform-reqs" - dependencies: "highest" env: extensions: ctype, dom, grpc, json, mbstring, openssl, xml, zip, zlib - key: cache-unit-7x-${{ matrix.php }}-v1 + key: cache-unit-8x-${{ matrix.php }} steps: - name: Checkout code @@ -93,25 +87,3 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} flags: unit - - bc-checks: - name: Backward Compatibility Check - runs-on: ubuntu-latest - if: github.actor != 'dependabot[bot]' - - steps: - - uses: actions/checkout@v6 - with: - fetch-depth: 0 - - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.2 - extensions: grpc - - - name: Install roave/backward-compatibility-check. - run: composer require --dev roave/backward-compatibility-check - - - name: Check for BC breaks - run: vendor/bin/roave-backward-compatibility-check --format=github-actions diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 42b36b07b..e10f0dabb 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -9,6 +9,7 @@ ->setRiskyAllowed(true) ->setRules([ '@PER-CS3x0:risky' => true, + '@PHPUnit9x1Migration:risky' => true, 'class_attributes_separation' => true, 'class_definition' => [ 'single_line' => true, diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cbe0e59d..ffd3c18e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,463 +5,17 @@ If it saves you or your team time, please consider [sponsoring its development]( ## [Unreleased] -### Changed +### Breaking changes -* `Factory::withHttpLogger()` and `Factory::withHttpDebugLogger()` have been deprecated. If you're using these methods, - you can use `HttpClientOptions` instead. - ([Documentation](https://firebase-php.readthedocs.io/en/latest/setup.html#logging)) +* The SDK supports only actively supported PHP versions. As a result, support for PHP < 8.3 has been dropped; + supported versions are 8.3, 8.4, and 8.5. +* [Firebase Dynamic Links was shut down on August 25th, 2025](https://firebase.google.com/support/dynamic-links-faq) + and has been removed from the SDK. +* Deprecated classes, methods and class constants have been removed. +* Type declarations have been simplified to reduce runtime overhead (e.g., `Stringable|string` to `string`). -### Deprecated methods +See **[UPGRADE-8.0](UPGRADE-8.0.md) for more details on the changes between 7.x and 8.0.** -* `Kreait\Firebase\Factory::withHttpLogger()` -* `Kreait\Firebase\Factory::withHttpDebugLogger()` -* `Kreait\Firebase\Http\Middleware::log()` +## 7.x Changelog -## [7.24.0] - 2025-11-27 - -### Changed - -* Realtime Database references are now validated by the API instead of locally. Validation rules can change at any time, - and the SDK can only adapt to changes in the API. While local checks could prevent obviously invalid paths, they’d - also require an SDK update whenever Firebase loosens a rule. Developers can be trusted not to use invalid paths 😅. -* Removed the `#[SensitiveParameter]` attribute again, because it's supported by PHP 8.1 itself, but not in combination - with Valinor. - ([#1034](https://github.com/kreait/firebase-php/pull/1034)) - -## [7.23.0] - 2025-10-13 - -* Require `cuyz/valinor:^2.2.1` for better mapping. - -## [7.22.0] - 2025-09-21 - -### Added - -* Added support for PHP 8.5 - -### Changed - -* The project now features a custom logo (I came up with it myself, and took the wise decision to not look up if there's something similar already) -* Refined README for improved clarity, removed outdated documentation sections, and streamlined project support messaging with a more positive call to action -* Documentation now uses the modern Furo theme, providing a cleaner and more pleasant reading experience - -## [7.21.2] - 2025-08-15 - -### Fixed - -* Re-added the `#[SensitiveParameter]` attribute because, while it's not supported in PHP 8.1, it can still be used - if placed in a standalone line above the variable or property. -* Re-added support for JSON files with any file extension -* With the introduction of Valinor, Service Account credentials were required to have more fields than necessary to - work with the SDK, although it only needs the client email, private key, and project ID. - -## [7.21.1] - 2025-07-24 - -### Fixed - -* Removed the `#[SensitiveParameter]` attribute because it's not supported in PHP 8.1. - -## [7.21.0] - 2025-07-23 - -### Changed - -* This release introduces [Valinor](https://valinor.cuyz.io/) for type-safe object mapping. The first application is - mapping a given service account file, JSON, or array to the newly added internal `ServiceAccount` class, with more - to follow in future releases. - -## [7.20.0] - 2025-07-18 - -### Added - -* You can now get a user by their federated identity provider (e.g. Google, Facebook, etc.) UID with - `Kreait\Firebase\Auth::getUserByProviderUid()`. ([#1000](https://github.com/kreait/firebase-php/pull/1000)) - Since this method couldn't be added to the `Kreait\Firebase\Contract\Auth` interface without causing a breaking - change, a new transitional interface/contract named `Kreait\Firebase\Contract\Transitional\FederatedUserFetcher` - was added. This interface will be removed in the next major version of the SDK. - There are several ways to check if you can use the `getUserByProviderUid()` method: - ```php - use Kreait\Firebase\Contract\Transitional\FederatedUserFetcher; - use Kreait\Firebase\Factory; - - $auth = (new Factory())->createAuth(); - // The return type is Kreait\Firebase\Contract\Auth, which doesn't have the method - - if (method_exists($auth, 'getUserByProviderUid')) { - $user = $auth->getUserByProviderUid('google.com', 'google-uid'); - } - - if ($auth instanceof \Kreait\Firebase\Auth) { // This is the implementation, not the interface - $user = $auth->getUserByProviderUid('google.com', 'google-uid'); - } - - if ($auth instanceof FederatedUserFetcher) { - $user = $auth->getUserByProviderUid('google.com', 'google-uid'); - } - ``` -* The new method `Kreait\Firebase\Factory::withDefaultCache()` allows you to set a default cache - implementation for the SDK. This is useful if you want to use one cache implementation for all components - that support caching. - ([Documentation](https://firebase-php.readthedocs.io/en/latest/setup.html#caching)) - -### Deprecated - -* `Kreait\Firebase\Factory::getDebugInfo` - -## [7.19.0] - 2025-06-14 - -### Added - -* You can now save on method call by passing a custom Firestore database name to - `Kreait\Firebase\Factory::createFirestore($databaseName)` instead of having to chain - ``::withFirestoreDatabase($databaseName)->createFirestore()`` -* It is now possible to set [live activity tokens](https://firebase.google.com/docs/cloud-messaging/customize-messages/live-activity?hl=en) - in Apns configs. -* `Kreait\Firebase\Http\HttpClientOptions::withGuzzleMiddleware()` and - `Kreait\Firebase\Http\HttpClientOptions::withGuzzleMiddlewares()` now accept callable strings, in addition - to callables. ([#1004](https://github.com/kreait/firebase-php/pull/1004)) - -### Deprecated - -* `Kreait\Firebase\Factory::withFirestoreDatabase()` - -## [7.18.0] - 2025-03-08 - -### Added - -* It is now possible to configure multi factor authentication for a user. - -## [7.17.0] - 2025-02-22 - -### Added - -* FCM Error responses with status code `502` are now caught and converted to `ServerUnavailable` exceptions. - -## [7.16.1] - 2025-01-20 - -### Fixed - -* It wasn't possible to upgrade the SDK to a newer version because it required a `lcobucci/jwt` release that doesn't - support PHP 8.1 anymore. This was fixed by changing the version requirement from `^5.4.2` to `^5.3`. - -## [7.16.0] - 2024-11-17 - -### Added - -* It is now possible to override the Guzzle HTTP handler by using the `HttpClientOptions::withGuzzleHandler()` method. - ([#956](https://github.com/kreait/firebase-php/pull/956)) - -### Changed - -* The Messaging component doesn't rely on the `CloudMessage` class for message handling anymore. If you provide a - message as an array and it has an error, the Firebase API will report it. You can still use the `CloudMessage` - class as a message builder -* Deprecated the `CloudMessage::withTarget()` method, use the new `toToken()`, `toTopic()` or `toCondition()` methods instead - -### Deprecated - -* `Kreait\Firebase\Messaging\CloudMessage::withTarget()` -* `Kreait\Firebase\Messaging\CloudMessage::withChangedTarget()` -* `Kreait\Firebase\Messaging\CloudMessage::target()` -* `Kreait\Firebase\Messaging\CloudMessage::hasTarget()` - -## [7.15.0] - 2024-09-11 - -### Added - -* Added support for [rollout parameter values](https://firebase.google.com/docs/reference/remote-config/rest/v1/RemoteConfig#RolloutValue) - in Remote Config Templates. - ([#923](https://github.com/kreait/firebase-php/pull/923)), ([#927](https://github.com/kreait/firebase-php/pull/927)) - * Please note that it's not (yet?) possible to create rollouts programmatically via the Firebase API. This means that - you have to manually create a rollout in the Firebase console to be able to reference it in the Remote Config - template. Rollout IDs are named `rollout_`, and you can find the ID in the URL after clicking on a rollout in the list. - -## [7.14.0] - 2024-08-21 - -### Added - -* Added support for PHP 8.4. - * Please note: While the SDK supports PHP 8.4, not all dependencies support it. If you want to use the SDK with - PHP 8.4, you probably will need to ignore platform requirements when working with Composer, by setting the - [appropriate environment variables](https://getcomposer.org/doc/03-cli.md#composer-ignore-platform-req-or-composer-ignore-platform-reqs) - or [`composer` CLI options]() when running `composer install/update/require`. - -### Deprecated - -* Firebase Dynamic Links is deprecated and should not be used in new projects. The service will shut down on - August 25, 2025. The component will remain in the SDK until then, but as the Firebase service is deprecated, - this component is also deprecated. - ([Dynamic Links Deprecation FAQ](https://firebase.google.com/support/dynamic-links-faq)) - -## [7.13.1] - 2024-07-02 - -### Fixed - -* Requests to the FCM APIs will not use HTTP/2 if the environment doesn't support them - ([#888](https://github.com/kreait/firebase-php/pull/888), [#908](https://github.com/kreait/firebase-php/pull/908)) - -## [7.13.0] - 2024-06-23 - -### Changed - -* Service Account auto-discovery was done on instantiation of the Factory, causing it to fail when credentials weren't - ready yet. It will now be done the first time a component is to be instantiated. - -## [7.12.0] - 2024-05-26 - -### Fixed - -* Fix `WebPushNotification` Shape - ([#895](https://github.com/kreait/firebase-php/pull/895)) -* Catch `Throwable` and let the exception converter handle details - ([#896](https://github.com/kreait/firebase-php/pull/896)) - -## [7.11.0] - 2024-05-16 - -### Added - -* It is now possible to get a Remote Config template by its version number. - ([#890](https://github.com/kreait/firebase-php/pull/890)) - -## [7.10.0] - 2024-04-25 - -### Changed - -* FCM Messages are now sent asynchronously using HTTP connection pooling with HTTP/2. This should improve performance - when sending messages to many devices. - ([#874](https://github.com/kreait/firebase-php/pull/874)) - -## [7.9.1] - 2023-12-04 - -### Changed - -* Re-enabled the use of `psr/http-message` v1.0 - ([#850](https://github.com/kreait/firebase-php/issues/850)) - -## [7.9.0] - 2023-11-30 - -### Added - -* Added support for PHP 8.3 - -## [7.8.0] - 2023-11-25 - -### Added - -* Added `Kreait\Firebase\Factory::withFirestoreClientConfig()` to support setting additional options when - creating the Firestore component. - ([Documentation](https://firebase-php.readthedocs.io/en/latest/cloud-firestore.html#add-firestore-configuration-options)) -* Added `Kreait\Firebase\Factory::withFirestoreDatabase()` to specify the database used when creating the Firestore - component. - ([Documentation](https://firebase-php.readthedocs.io/en/latest/cloud-firestore.html#use-another-firestore-database)) - -## [7.7.0] - 2023-11-25 - -### Changed - -* Required transitive dependencies directly ([#842](https://github.com/kreait/firebase-php/issues/842)) -```json5 -{ - "require": { - // ... - "ext-filter": "*", - "guzzlehttp/promises": "^2.0", - "guzzlehttp/psr7": "^2.6", - "psr/clock": "^1.0", - "psr/http-client": "^1.0", - "psr/http-factory": "^1.0", - "psr/http-message": "^2.0", - } -} -``` - - -## [7.6.0] - 2023-09-07 - -### Added - -* The `Kreait\Firebase\Exception\Messaging\NotFound` exception now exposes the token that hasn't been found - with the `token()` method. - ([#825](https://github.com/kreait/firebase-php/issues/825)) - -## [7.5.2] - 2023-06-29 - -### Added - -* Added FCM error handling to the documentation - -## [7.5.1] - 2023-06-29 - -### Fixed - -* The cached KeySet used by the AppCheck component didn't use the same Guzzle Config Options as the other clients - ([#812](https://github.com/kreait/firebase-php/issues/812)) - -## [7.5.0] - 2023-06-27 - -### Changed - -* Replaced calls to deprecated FCM batch endpoints with asynchronous requests - to the HTTP V1 API - ([#804](https://github.com/kreait/firebase-php/pull/804)/[#805](https://github.com/kreait/firebase-php/pull/805)) -* Removed message limit when sending multiple FCM messages - * The message limit was needed when using the FCM batch endpoints because they used multipart requests and responses. - The limit prevented these messages to become too large. Since we're now using asynchronous calls to send one - request per message, this limitation is not needed anymore. -* Simplified convoluted Dynamic Link operations - ([#810](https://github.com/kreait/firebase-php/pull/810)) - -### Removed - -* Removed obsolete internal classes - * `Kreait\Firebase\Http\HasSubRequests` - * `Kreait\Firebase\Http\HasSubResponses` - * `Kreait\Firebase\Http\Requests` - * `Kreait\Firebase\Http\RequestWithSubRequests` - * `Kreait\Firebase\Http\Responses` - * `Kreait\Firebase\Http\ResponseWithSubResponses` - * `Kreait\Firebase\Http\WrappedPsr7Response` - * `Kreait\Firebase\Http\WrappedPsr7Request` - * `Kreait\Firebase\Messaging\Http\Request\MessageRequest` - * `Kreait\Firebase\Messaging\Http\Request\SendMessage` - * `Kreait\Firebase\Messaging\Http\Request\SendMessageToTokens` - * `Kreait\Firebase\Messaging\Http\Request\SendMessages` - -* Removed obsolete internal methods - * `Kreait\Firebase\Http\Middleware::responseWithSubResponses()` - -* Removed obsolete Composer dependency `riverline/multipart-parser` - -## [7.4.0] - 2023-06-18 - -### Added - -* Added support for [Parameter Value Types](https://firebase.google.com/docs/reference/remote-config/rest/v1/RemoteConfig#parametervaluetype) - when getting and setting a RemoteConfig template. - ([Documentation](https://firebase-php.readthedocs.io/en/latest/remote-config.html#parameter-value-types)) - -### Deprecated - -* `Kreait\Firebase\RemoteConfig\ExplicitValue` is deprecated -* `Kreait\Firebase\RemoteConfig\DefaultValue` should be regarded as deprecated, it is kept to not create a breaking changes - -## [7.3.1] - 2023-06-10 - -### Changed - -* Removed direct dependency to `psr/http-message` - -## [7.3.0] - 2023-06-03 - -### Added - -* It is now possible to add config options and middlewares to the Guzzle HTTP Client performing the HTTP Requests - to the Firebase APIs through the `HttpClientOptions` class. - ([Documentation](https://firebase-php.readthedocs.io/en/latest/setup.html#http-client-options)) - -## [7.2.1] - 2023-04-04 - -### Fixed - -* Fixed a user's MFA information not being correctly parsed - ([#783](https://github.com/kreait/firebase-php/pull/783)) - -## [7.2.0] - 2023-03-24 - -### Added - -* Added support for the Firebase Auth Emulator when using `lcobucci/jwt` 5.* - -## [7.1.0] - 2023-03-01 - -### Added - -* Added support for `lcobucci/jwt` 5.* - -## [7.0.3] - 2023-02-13 - -### Fixed - -* Restored support for using a JSON string in the `GOOGLE_APPLICATION_CREDENTIALS` environment variable. - ([#767](https://github.com/kreait/firebase-php/pull/767)) - -## [7.0.2] - 2023-01-27 - -### Fixed - -* Cloud Messaging: The APNS `content-available` payload field was not set correctly when a message contained - message data at the root level, but not at the APNS config level. - ([#762](https://github.com/kreait/firebase-php/pull/762)) - -## [7.0.1] - 2023-01-24 - -### Fixed - -* When trying to work with unknown FCM tokens, errors returned from the Messaging REST API were not passed to - the `NotFound` exception, which prevented the inspection of further details. - ([#760](https://github.com/kreait/firebase-php/pull/760)) - -## [7.0.0] - 2022-12-20 - -The most notable change is that you need PHP 8.1/8.2 to use the new version. The language migration of -the SDK introduces breaking changes concerning the strictness of parameter types almost everywhere in -the SDK - however, this should not affect your project in most cases (unless you have used internal classes -directly or by extension). - -This release adds many more PHPDoc annotations to support the usage of Static Analysis Tools like PHPStan -and Psalm and moves away from doing runtime checks. It is strongly recommended to use a Static Analysis -Tool and ensure that input values are validated before handing them over to the SDK. - -### Added features - -* Added support for verifying Firebase App Check Tokens. ([#747](https://github.com/kreait/firebase-php/pull/747)) - -### Notable changes - -* The ability to disable credentials auto-discovery has been removed. If you don't want a service account to be - auto-discovered, provide it by using the `withServiceAccount()` method of the Factory or by setting the - `GOOGLE_APPLICATION_CREDENTIALS` environment variable. Depending on the environment in which the SDK is running, - credentials could be auto-discovered otherwise, for example on GCP or GCE. - -See **[UPGRADE-7.0](UPGRADE-7.0.md) for more details on the changes between 6.x and 7.0.** - -## 6.x Changelog - -https://github.com/kreait/firebase-php/blob/6.9.6/CHANGELOG.md - -[Unreleased]: https://github.com/kreait/firebase-php/compare/7.24.0...7.x -[7.24.0]: https://github.com/kreait/firebase-php/compare/7.23.0...7.24.0 -[7.23.0]: https://github.com/kreait/firebase-php/compare/7.22.0...7.23.0 -[7.22.0]: https://github.com/kreait/firebase-php/compare/7.21.2...7.22.0 -[7.21.2]: https://github.com/kreait/firebase-php/compare/7.21.1...7.21.2 -[7.21.1]: https://github.com/kreait/firebase-php/compare/7.21.0...7.21.1 -[7.21.0]: https://github.com/kreait/firebase-php/compare/7.20.0...7.21.0 -[7.20.0]: https://github.com/kreait/firebase-php/compare/7.19.0...7.20.0 -[7.19.0]: https://github.com/kreait/firebase-php/compare/7.18.0...7.19.0 -[7.18.0]: https://github.com/kreait/firebase-php/compare/7.17.0...7.18.0 -[7.17.0]: https://github.com/kreait/firebase-php/compare/7.16.1...7.17.0 -[7.16.1]: https://github.com/kreait/firebase-php/compare/7.16.0...7.16.1 -[7.16.0]: https://github.com/kreait/firebase-php/compare/7.15.0...7.16.0 -[7.15.0]: https://github.com/kreait/firebase-php/compare/7.14.0...7.15.0 -[7.14.0]: https://github.com/kreait/firebase-php/compare/7.13.1...7.14.0 -[7.13.1]: https://github.com/kreait/firebase-php/compare/7.13.0...7.13.1 -[7.13.0]: https://github.com/kreait/firebase-php/compare/7.12.0...7.13.0 -[7.12.0]: https://github.com/kreait/firebase-php/compare/7.11.0...7.12.0 -[7.11.0]: https://github.com/kreait/firebase-php/compare/7.10.0...7.11.0 -[7.10.0]: https://github.com/kreait/firebase-php/compare/7.9.1...7.10.0 -[7.9.1]: https://github.com/kreait/firebase-php/compare/7.9.0...7.9.1 -[7.9.0]: https://github.com/kreait/firebase-php/compare/7.8.0...7.9.0 -[7.8.0]: https://github.com/kreait/firebase-php/compare/7.7.0...7.8.0 -[7.7.0]: https://github.com/kreait/firebase-php/compare/7.6.0...7.7.0 -[7.6.0]: https://github.com/kreait/firebase-php/compare/7.5.2...7.6.0 -[7.5.2]: https://github.com/kreait/firebase-php/compare/7.5.1...7.5.2 -[7.5.1]: https://github.com/kreait/firebase-php/compare/7.5.0...7.5.1 -[7.5.0]: https://github.com/kreait/firebase-php/compare/7.3.1...7.5.0 -[7.4.0]: https://github.com/kreait/firebase-php/compare/7.3.1...7.4.0 -[7.3.1]: https://github.com/kreait/firebase-php/compare/7.3.0...7.3.1 -[7.3.0]: https://github.com/kreait/firebase-php/compare/7.2.1...7.3.0 -[7.2.1]: https://github.com/kreait/firebase-php/compare/7.2.0...7.2.1 -[7.2.0]: https://github.com/kreait/firebase-php/compare/7.1.0...7.2.0 -[7.1.0]: https://github.com/kreait/firebase-php/compare/7.0.3...7.1.0 -[7.0.3]: https://github.com/kreait/firebase-php/compare/7.0.2...7.0.3 -[7.0.2]: https://github.com/kreait/firebase-php/compare/7.0.1...7.0.2 -[7.0.1]: https://github.com/kreait/firebase-php/compare/7.0.0...7.0.1 -[7.0.0]: https://github.com/kreait/firebase-php/releases/tag/7.0.0 +https://github.com/kreait/firebase-php/blob/7.24.0/CHANGELOG.md diff --git a/README.md b/README.md index fb26d9bb6..25abdca80 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Composer is a dependency management tool for PHP that allows you to declare the your project needs and installs them into your project. ```bash -composer require "kreait/firebase-php:^7.0" +composer require "kreait/firebase-php:^8.0" ``` Please continue to the [Setup section](docs/setup.rst) to learn more about connecting your application to Firebase. diff --git a/UPGRADE-7.0.md b/UPGRADE-7.0.md deleted file mode 100644 index 38969ab9d..000000000 --- a/UPGRADE-7.0.md +++ /dev/null @@ -1,338 +0,0 @@ -# Upgrade from 6.x to 7.0 - -## Introduction - -This is a major release, but its aim is to provide as much backward compatibility as possible to ease upgrades -from 6.x to 7.0. - -The minimum required PHP version has been changed from `^7.4` to `~8.1.0 || ~8.2.0`, the two PHP versions that -are [actively supported since 2022-11-26](https://www.php.net/supported-versions.php). - -If you're using version 6.x of the SDK as documented, an upgrade to 7.x should hopefully be as simple as updating the -version constraint in your project's `composer.json` file. - -"As documented" means: - -* When injecting SDK dependencies in your project's controllers and services, you use the interfaces in the - `Kreait\Firebase\Contract` namespace, not the (internal) implementations. -* You're not using classes marked as `@internal` -* You don't have created your own implementations based on the Interfaces in the `Kreait\Firebase\Contract` namespace. - * Updating your custom implementations will take some work but should™ be straightforward. - -## Notable changes - -* The ability to disable credentials auto-discovery has been removed. If you don't want a service account to be - auto-discovered, provide it by using the `withServiceAccount()` method of the Factory or by setting the - `GOOGLE_APPLICATION_CREDENTIALS` environment variable. Depending on the environment in which the SDK is running, - credentials could be auto-discovered otherwise, for example on GCP or GCE. -* Classes, Methods and Constants marked as `@deprecated` have been removed. -* Classes, Methods and Constants marked as `@internal` have been removed or refactored. -* `@param` annotations in PHPDoc blocks have been moved to typed parameters, for example: - ```php - /** - * @param scalar $value - */ - public function method($value); - ``` - would change to - ```php - public function method(bool|string|int|float $value); - ``` -* Methods that accepted strings and objects with a `__toString()` method have been replaced with `Stringable|string`, - for example: - ```php - /** - * @param Uid|string $uid - */ - public function method($uid); - ``` - have been changed to - ```php - public function method(Stringable|string $value); - ``` - -## Complete list of breaking changes - -The following list has been generated with [roave/backward-compatibility-check](https://github.com/Roave/BackwardCompatibilityCheck). - -### Removals - -``` -[BC] CHANGED: Class Kreait\Firebase\Auth\UserInfo became final -[BC] CHANGED: Class Kreait\Firebase\Auth\UserMetaData became final -[BC] CHANGED: Class Kreait\Firebase\Auth\UserRecord became final -[BC] CHANGED: Kreait\Firebase\Auth\CreateActionLink was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\CreateActionLink\GuzzleApiClientHandler was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\CreateActionLink\Handler was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\CreateSessionCookie was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\CreateSessionCookie\GuzzleApiClientHandler was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\CreateSessionCookie\Handler was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\DeleteUsersRequest was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\DeleteUsersResult::fromRequestAndResponse() was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\SendActionLink was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\SendActionLink\GuzzleApiClientHandler was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\SendActionLink\Handler was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\SignIn was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\SignInAnonymously was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\SignInWithCustomToken was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\SignInWithEmailAndOobCode was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\SignInWithEmailAndPassword was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\SignInWithIdpCredentials was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\SignInWithRefreshToken was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\TenantAwareAuthResourceUrlBuilder was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\UserInfo::fromResponseData() was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\UserMetaData::fromResponseData() was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Auth\UserRecord::fromResponseData() was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Database\Query\Filter was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Database\Query\Filter\EndAt was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Database\Query\Filter\EndBefore was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Database\Query\Filter\EqualTo was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Database\Query\Filter\LimitToFirst was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Database\Query\Filter\LimitToLast was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Database\Query\Filter\Shallow was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Database\Query\Filter\StartAfter was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Database\Query\Filter\StartAt was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Database\Query\Modifier was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Database\Query\ModifierTrait was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Database\Query\Sorter was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Database\Query\Sorter\OrderByChild was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Database\Query\Sorter\OrderByKey was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Database\Query\Sorter\OrderByValue was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Database\Reference\Validator was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Database\UrlBuilder was marked "@internal" -[BC] CHANGED: Kreait\Firebase\DynamicLink\CreateDynamicLink\ApiRequest was marked "@internal" -[BC] CHANGED: Kreait\Firebase\DynamicLink\CreateDynamicLink\GuzzleApiClientHandler was marked "@internal" -[BC] CHANGED: Kreait\Firebase\DynamicLink\CreateDynamicLink\Handler was marked "@internal" -[BC] CHANGED: Kreait\Firebase\DynamicLink\GetStatisticsForDynamicLink\ApiRequest was marked "@internal" -[BC] CHANGED: Kreait\Firebase\DynamicLink\GetStatisticsForDynamicLink\GuzzleApiClientHandler was marked "@internal" -[BC] CHANGED: Kreait\Firebase\DynamicLink\GetStatisticsForDynamicLink\Handler was marked "@internal" -[BC] CHANGED: Kreait\Firebase\DynamicLink\ShortenLongDynamicLink\ApiRequest was marked "@internal" -[BC] CHANGED: Kreait\Firebase\DynamicLink\ShortenLongDynamicLink\GuzzleApiClientHandler was marked "@internal" -[BC] CHANGED: Kreait\Firebase\DynamicLink\ShortenLongDynamicLink\Handler was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Exception\HasErrors was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Messaging\Processor\SetApnsContentAvailableIfNeeded was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Messaging\Processor\SetApnsPushTypeIfNeeded was marked "@internal" -[BC] CHANGED: Kreait\Firebase\Messaging\RegistrationTokens#__construct() was marked "@internal" -[BC] CHANGED: Property Kreait\Firebase\Auth\UserRecord#$customClaims changed default value from array () to NULL -[BC] CHANGED: Property Kreait\Firebase\Auth\UserRecord#$disabled changed default value from false to NULL -[BC] CHANGED: Property Kreait\Firebase\Auth\UserRecord#$emailVerified changed default value from false to NULL -[BC] CHANGED: Property Kreait\Firebase\Auth\UserRecord#$providerData changed default value from array () to NULL -[BC] CHANGED: Property Kreait\Firebase\Auth\UserRecord#$uid changed default value from '' to NULL -[BC] CHANGED: The number of required arguments for Kreait\Firebase\Auth\UserRecord#__construct() increased from 0 to 15 -[BC] CHANGED: The parameter $actionOrParametersOrUrl of Kreait\Firebase\Contract\DynamicLinks#createDynamicLink() changed from no type to Stringable|string|Kreait\Firebase\DynamicLink\CreateDynamicLink|array -[BC] CHANGED: The parameter $actionOrParametersOrUrl of Kreait\Firebase\Contract\DynamicLinks#createDynamicLink() changed from no type to a non-contravariant Stringable|string|Kreait\Firebase\DynamicLink\CreateDynamicLink|array -[BC] CHANGED: The parameter $clearTextPassword of Kreait\Firebase\Contract\Auth#signInWithEmailAndPassword() changed from no type to Stringable|string -[BC] CHANGED: The parameter $clearTextPassword of Kreait\Firebase\Contract\Auth#signInWithEmailAndPassword() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $clearTextPassword of Kreait\Firebase\Request\EditUserTrait#withClearTextPassword() changed from no type to Stringable|string -[BC] CHANGED: The parameter $clearTextPassword of Kreait\Firebase\Request\EditUserTrait#withClearTextPassword() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $clearTextPassword of Kreait\Firebase\Request\EditUserTrait#withClearTextPassword() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $clearTextPassword of Kreait\Firebase\Request\EditUserTrait#withClearTextPassword() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $data of Kreait\Firebase\DynamicLink\CreateDynamicLink#withAnalyticsInfo() changed from no type to a non-contravariant Kreait\Firebase\DynamicLink\AnalyticsInfo|array -[BC] CHANGED: The parameter $data of Kreait\Firebase\DynamicLink\CreateDynamicLink#withAndroidInfo() changed from no type to a non-contravariant Kreait\Firebase\DynamicLink\AndroidInfo|array -[BC] CHANGED: The parameter $data of Kreait\Firebase\DynamicLink\CreateDynamicLink#withIOSInfo() changed from no type to a non-contravariant Kreait\Firebase\DynamicLink\IOSInfo|array -[BC] CHANGED: The parameter $data of Kreait\Firebase\DynamicLink\CreateDynamicLink#withNavigationInfo() changed from no type to a non-contravariant Kreait\Firebase\DynamicLink\NavigationInfo|array -[BC] CHANGED: The parameter $data of Kreait\Firebase\DynamicLink\CreateDynamicLink#withSocialMetaTagInfo() changed from no type to a non-contravariant Kreait\Firebase\DynamicLink\SocialMetaTagInfo|array -[BC] CHANGED: The parameter $data of Kreait\Firebase\Messaging\CloudMessage#withData() changed from no type to a non-contravariant Kreait\Firebase\Messaging\MessageData|array -[BC] CHANGED: The parameter $dynamicLinkDomain of Kreait\Firebase\DynamicLink\CreateDynamicLink#withDynamicLinkDomain() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $dynamicLinkOrAction of Kreait\Firebase\Contract\DynamicLinks#getStatistics() changed from no type to Stringable|string|Kreait\Firebase\DynamicLink\GetStatisticsForDynamicLink -[BC] CHANGED: The parameter $dynamicLinkOrAction of Kreait\Firebase\Contract\DynamicLinks#getStatistics() changed from no type to a non-contravariant Stringable|string|Kreait\Firebase\DynamicLink\GetStatisticsForDynamicLink -[BC] CHANGED: The parameter $email of Kreait\Firebase\Auth\CreateActionLink::new() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#createUserWithEmailAndPassword() changed from no type to Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#createUserWithEmailAndPassword() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#getEmailActionLink() changed from no type to Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#getEmailActionLink() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#getEmailVerificationLink() changed from no type to Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#getEmailVerificationLink() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#getPasswordResetLink() changed from no type to Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#getPasswordResetLink() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#getSignInWithEmailLink() changed from no type to Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#getSignInWithEmailLink() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#getUserByEmail() changed from no type to Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#getUserByEmail() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#sendEmailActionLink() changed from no type to Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#sendEmailActionLink() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#sendEmailVerificationLink() changed from no type to Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#sendEmailVerificationLink() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#sendPasswordResetLink() changed from no type to Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#sendPasswordResetLink() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#sendSignInWithEmailLink() changed from no type to Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#sendSignInWithEmailLink() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#signInWithEmailAndOobCode() changed from no type to Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#signInWithEmailAndOobCode() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#signInWithEmailAndPassword() changed from no type to Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#signInWithEmailAndPassword() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withEmail() changed from no type to Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withEmail() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withEmail() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withEmail() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withUnverifiedEmail() changed from no type to Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withUnverifiedEmail() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withUnverifiedEmail() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withUnverifiedEmail() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withVerifiedEmail() changed from no type to Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withVerifiedEmail() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withVerifiedEmail() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withVerifiedEmail() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $idToken of Kreait\Firebase\Contract\Auth#createSessionCookie() changed from no type to Lcobucci\JWT\Token|string -[BC] CHANGED: The parameter $idToken of Kreait\Firebase\Contract\Auth#createSessionCookie() changed from no type to a non-contravariant Lcobucci\JWT\Token|string -[BC] CHANGED: The parameter $idToken of Kreait\Firebase\Contract\Auth#signInWithIdpIdToken() changed from no type to Lcobucci\JWT\Token|string -[BC] CHANGED: The parameter $idToken of Kreait\Firebase\Contract\Auth#signInWithIdpIdToken() changed from no type to a non-contravariant Lcobucci\JWT\Token|string -[BC] CHANGED: The parameter $idToken of Kreait\Firebase\Contract\Auth#verifyIdToken() changed from no type to Lcobucci\JWT\Token|string -[BC] CHANGED: The parameter $idToken of Kreait\Firebase\Contract\Auth#verifyIdToken() changed from no type to a non-contravariant Lcobucci\JWT\Token|string -[BC] CHANGED: The parameter $link of Kreait\Firebase\DynamicLink\GetStatisticsForDynamicLink::forLink() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $longDynamicLinkOrAction of Kreait\Firebase\Contract\DynamicLinks#shortenLongDynamicLink() changed from no type to Stringable|string|Kreait\Firebase\DynamicLink\ShortenLongDynamicLink|array -[BC] CHANGED: The parameter $longDynamicLinkOrAction of Kreait\Firebase\Contract\DynamicLinks#shortenLongDynamicLink() changed from no type to a non-contravariant Stringable|string|Kreait\Firebase\DynamicLink\ShortenLongDynamicLink|array -[BC] CHANGED: The parameter $message of Kreait\Firebase\Contract\Messaging#send() changed from no type to Kreait\Firebase\Messaging\Message|array -[BC] CHANGED: The parameter $message of Kreait\Firebase\Contract\Messaging#send() changed from no type to a non-contravariant Kreait\Firebase\Messaging\Message|array -[BC] CHANGED: The parameter $message of Kreait\Firebase\Contract\Messaging#sendMulticast() changed from no type to Kreait\Firebase\Messaging\Message|array -[BC] CHANGED: The parameter $message of Kreait\Firebase\Contract\Messaging#sendMulticast() changed from no type to a non-contravariant Kreait\Firebase\Messaging\Message|array -[BC] CHANGED: The parameter $message of Kreait\Firebase\Contract\Messaging#validate() changed from no type to Kreait\Firebase\Messaging\Message|array -[BC] CHANGED: The parameter $message of Kreait\Firebase\Contract\Messaging#validate() changed from no type to a non-contravariant Kreait\Firebase\Messaging\Message|array -[BC] CHANGED: The parameter $messages of Kreait\Firebase\Contract\Messaging#sendAll() changed from no type to a non-contravariant array|Kreait\Firebase\Messaging\Messages -[BC] CHANGED: The parameter $messages of Kreait\Firebase\Contract\Messaging#sendAll() changed from no type to array|Kreait\Firebase\Messaging\Messages -[BC] CHANGED: The parameter $newEmail of Kreait\Firebase\Contract\Auth#changeUserEmail() changed from no type to Stringable|string -[BC] CHANGED: The parameter $newEmail of Kreait\Firebase\Contract\Auth#changeUserEmail() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $newPassword of Kreait\Firebase\Contract\Auth#changeUserPassword() changed from no type to Stringable|string -[BC] CHANGED: The parameter $newPassword of Kreait\Firebase\Contract\Auth#changeUserPassword() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $newPassword of Kreait\Firebase\Contract\Auth#confirmPasswordReset() changed from no type to Stringable|string -[BC] CHANGED: The parameter $newPassword of Kreait\Firebase\Contract\Auth#confirmPasswordReset() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $notification of Kreait\Firebase\Messaging\CloudMessage#withNotification() changed from no type to a non-contravariant Kreait\Firebase\Messaging\Notification|array -[BC] CHANGED: The parameter $password of Kreait\Firebase\Contract\Auth#createUserWithEmailAndPassword() changed from no type to Stringable|string -[BC] CHANGED: The parameter $password of Kreait\Firebase\Contract\Auth#createUserWithEmailAndPassword() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $phoneNumber of Kreait\Firebase\Contract\Auth#getUserByPhoneNumber() changed from no type to Stringable|string -[BC] CHANGED: The parameter $phoneNumber of Kreait\Firebase\Contract\Auth#getUserByPhoneNumber() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $properties of Kreait\Firebase\Contract\Auth#createUser() changed from no type to a non-contravariant array|Kreait\Firebase\Request\CreateUser -[BC] CHANGED: The parameter $properties of Kreait\Firebase\Contract\Auth#createUser() changed from no type to array|Kreait\Firebase\Request\CreateUser -[BC] CHANGED: The parameter $properties of Kreait\Firebase\Contract\Auth#updateUser() changed from no type to a non-contravariant array|Kreait\Firebase\Request\UpdateUser -[BC] CHANGED: The parameter $properties of Kreait\Firebase\Contract\Auth#updateUser() changed from no type to array|Kreait\Firebase\Request\UpdateUser -[BC] CHANGED: The parameter $provider of Kreait\Firebase\Contract\Auth#signInWithIdpAccessToken() changed from no type to Stringable|string -[BC] CHANGED: The parameter $provider of Kreait\Firebase\Contract\Auth#signInWithIdpAccessToken() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $provider of Kreait\Firebase\Contract\Auth#signInWithIdpIdToken() changed from no type to Stringable|string -[BC] CHANGED: The parameter $provider of Kreait\Firebase\Contract\Auth#signInWithIdpIdToken() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $provider of Kreait\Firebase\Contract\Auth#unlinkProvider() changed from no type to a non-contravariant array|Stringable|string -[BC] CHANGED: The parameter $provider of Kreait\Firebase\Contract\Auth#unlinkProvider() changed from no type to array|Stringable|string -[BC] CHANGED: The parameter $query of Kreait\Firebase\Contract\Auth#queryUsers() changed from no type to Kreait\Firebase\Auth\UserQuery|array -[BC] CHANGED: The parameter $query of Kreait\Firebase\Contract\Auth#queryUsers() changed from no type to a non-contravariant Kreait\Firebase\Auth\UserQuery|array -[BC] CHANGED: The parameter $registrationToken of Kreait\Firebase\Contract\Messaging#getAppInstance() changed from no type to Kreait\Firebase\Messaging\RegistrationToken|string -[BC] CHANGED: The parameter $registrationToken of Kreait\Firebase\Contract\Messaging#getAppInstance() changed from no type to a non-contravariant Kreait\Firebase\Messaging\RegistrationToken|string -[BC] CHANGED: The parameter $registrationTokenOrTokens of Kreait\Firebase\Contract\Messaging#subscribeToTopic() changed from no type to Kreait\Firebase\Messaging\RegistrationTokens|Kreait\Firebase\Messaging\RegistrationToken|array|string -[BC] CHANGED: The parameter $registrationTokenOrTokens of Kreait\Firebase\Contract\Messaging#subscribeToTopic() changed from no type to a non-contravariant Kreait\Firebase\Messaging\RegistrationTokens|Kreait\Firebase\Messaging\RegistrationToken|array|string -[BC] CHANGED: The parameter $registrationTokenOrTokens of Kreait\Firebase\Contract\Messaging#subscribeToTopics() changed from no type to Kreait\Firebase\Messaging\RegistrationTokens|Kreait\Firebase\Messaging\RegistrationToken|array|string -[BC] CHANGED: The parameter $registrationTokenOrTokens of Kreait\Firebase\Contract\Messaging#subscribeToTopics() changed from no type to a non-contravariant Kreait\Firebase\Messaging\RegistrationTokens|Kreait\Firebase\Messaging\RegistrationToken|array|string -[BC] CHANGED: The parameter $registrationTokenOrTokens of Kreait\Firebase\Contract\Messaging#unsubscribeFromAllTopics() changed from no type to Kreait\Firebase\Messaging\RegistrationTokens|Kreait\Firebase\Messaging\RegistrationToken|array|string -[BC] CHANGED: The parameter $registrationTokenOrTokens of Kreait\Firebase\Contract\Messaging#unsubscribeFromAllTopics() changed from no type to a non-contravariant Kreait\Firebase\Messaging\RegistrationTokens|Kreait\Firebase\Messaging\RegistrationToken|array|string -[BC] CHANGED: The parameter $registrationTokenOrTokens of Kreait\Firebase\Contract\Messaging#unsubscribeFromTopic() changed from no type to Kreait\Firebase\Messaging\RegistrationTokens|Kreait\Firebase\Messaging\RegistrationToken|array|string -[BC] CHANGED: The parameter $registrationTokenOrTokens of Kreait\Firebase\Contract\Messaging#unsubscribeFromTopic() changed from no type to a non-contravariant Kreait\Firebase\Messaging\RegistrationTokens|Kreait\Firebase\Messaging\RegistrationToken|array|string -[BC] CHANGED: The parameter $registrationTokenOrTokens of Kreait\Firebase\Contract\Messaging#unsubscribeFromTopics() changed from no type to Kreait\Firebase\Messaging\RegistrationTokens|Kreait\Firebase\Messaging\RegistrationToken|array|string -[BC] CHANGED: The parameter $registrationTokenOrTokens of Kreait\Firebase\Contract\Messaging#unsubscribeFromTopics() changed from no type to a non-contravariant Kreait\Firebase\Messaging\RegistrationTokens|Kreait\Firebase\Messaging\RegistrationToken|array|string -[BC] CHANGED: The parameter $registrationTokenOrTokens of Kreait\Firebase\Contract\Messaging#validateRegistrationTokens() changed from no type to Kreait\Firebase\Messaging\RegistrationTokens|Kreait\Firebase\Messaging\RegistrationToken|array|string -[BC] CHANGED: The parameter $registrationTokenOrTokens of Kreait\Firebase\Contract\Messaging#validateRegistrationTokens() changed from no type to a non-contravariant Kreait\Firebase\Messaging\RegistrationTokens|Kreait\Firebase\Messaging\RegistrationToken|array|string -[BC] CHANGED: The parameter $registrationTokens of Kreait\Firebase\Contract\Messaging#sendMulticast() changed from no type to Kreait\Firebase\Messaging\RegistrationTokens|Kreait\Firebase\Messaging\RegistrationToken|array|string -[BC] CHANGED: The parameter $registrationTokens of Kreait\Firebase\Contract\Messaging#sendMulticast() changed from no type to a non-contravariant Kreait\Firebase\Messaging\RegistrationTokens|Kreait\Firebase\Messaging\RegistrationToken|array|string -[BC] CHANGED: The parameter $token of Kreait\Firebase\Contract\Auth#signInWithCustomToken() changed from no type to Lcobucci\JWT\Token|string -[BC] CHANGED: The parameter $token of Kreait\Firebase\Contract\Auth#signInWithCustomToken() changed from no type to a non-contravariant Lcobucci\JWT\Token|string -[BC] CHANGED: The parameter $topic of Kreait\Firebase\Contract\Messaging#subscribeToTopic() changed from no type to a non-contravariant string|Kreait\Firebase\Messaging\Topic -[BC] CHANGED: The parameter $topic of Kreait\Firebase\Contract\Messaging#subscribeToTopic() changed from no type to string|Kreait\Firebase\Messaging\Topic -[BC] CHANGED: The parameter $topic of Kreait\Firebase\Contract\Messaging#unsubscribeFromTopic() changed from no type to a non-contravariant string|Kreait\Firebase\Messaging\Topic -[BC] CHANGED: The parameter $topic of Kreait\Firebase\Contract\Messaging#unsubscribeFromTopic() changed from no type to string|Kreait\Firebase\Messaging\Topic -[BC] CHANGED: The parameter $topic of Kreait\Firebase\Messaging\AppInstance#isSubscribedToTopic() changed from no type to a non-contravariant Kreait\Firebase\Messaging\Topic|string -[BC] CHANGED: The parameter $ttl of Kreait\Firebase\Contract\Auth#createCustomToken() changed from no type to a non-contravariant int|DateInterval|string -[BC] CHANGED: The parameter $ttl of Kreait\Firebase\Contract\Auth#createCustomToken() changed from no type to int|DateInterval|string -[BC] CHANGED: The parameter $ttl of Kreait\Firebase\Contract\Auth#createSessionCookie() changed from no type to DateInterval|int -[BC] CHANGED: The parameter $ttl of Kreait\Firebase\Contract\Auth#createSessionCookie() changed from no type to a non-contravariant DateInterval|int -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#changeUserEmail() changed from no type to Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#changeUserEmail() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#changeUserPassword() changed from no type to Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#changeUserPassword() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#createCustomToken() changed from no type to Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#createCustomToken() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#deleteUser() changed from no type to Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#deleteUser() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#disableUser() changed from no type to Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#disableUser() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#enableUser() changed from no type to Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#enableUser() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#getUser() changed from no type to Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#getUser() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#revokeRefreshTokens() changed from no type to Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#revokeRefreshTokens() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#setCustomUserClaims() changed from no type to Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#setCustomUserClaims() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#unlinkProvider() changed from no type to Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#unlinkProvider() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#updateUser() changed from no type to Stringable|string -[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#updateUser() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $uri of Kreait\Firebase\Factory#withDatabaseUri() changed from no type to a non-contravariant Psr\Http\Message\UriInterface|string -[BC] CHANGED: The parameter $url of Kreait\Firebase\Contract\DynamicLinks#createShortLink() changed from no type to Stringable|string|Kreait\Firebase\DynamicLink\CreateDynamicLink|array -[BC] CHANGED: The parameter $url of Kreait\Firebase\Contract\DynamicLinks#createShortLink() changed from no type to a non-contravariant Stringable|string|Kreait\Firebase\DynamicLink\CreateDynamicLink|array -[BC] CHANGED: The parameter $url of Kreait\Firebase\Contract\DynamicLinks#createUnguessableLink() changed from no type to Stringable|string|Kreait\Firebase\DynamicLink\CreateDynamicLink|array -[BC] CHANGED: The parameter $url of Kreait\Firebase\Contract\DynamicLinks#createUnguessableLink() changed from no type to a non-contravariant Stringable|string|Kreait\Firebase\DynamicLink\CreateDynamicLink|array -[BC] CHANGED: The parameter $url of Kreait\Firebase\DynamicLink\CreateDynamicLink::forUrl() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $url of Kreait\Firebase\DynamicLink\ShortenLongDynamicLink::forLongDynamicLink() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $url of Kreait\Firebase\Request\EditUserTrait#withPhotoUrl() changed from no type to Stringable|string -[BC] CHANGED: The parameter $url of Kreait\Firebase\Request\EditUserTrait#withPhotoUrl() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $url of Kreait\Firebase\Request\EditUserTrait#withPhotoUrl() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $url of Kreait\Firebase\Request\EditUserTrait#withPhotoUrl() changed from no type to a non-contravariant Stringable|string -[BC] CHANGED: The parameter $user of Kreait\Firebase\Contract\Auth#signInAsUser() changed from no type to Kreait\Firebase\Auth\UserRecord|Stringable|string -[BC] CHANGED: The parameter $user of Kreait\Firebase\Contract\Auth#signInAsUser() changed from no type to a non-contravariant Kreait\Firebase\Auth\UserRecord|Stringable|string -[BC] CHANGED: The parameter $value of Kreait\Firebase\Database\Query\Filter\EndAt#__construct() changed from no type to a non-contravariant bool|float|int|string -[BC] CHANGED: The parameter $value of Kreait\Firebase\Database\Query\Filter\EndBefore#__construct() changed from no type to a non-contravariant int|float|string|bool -[BC] CHANGED: The parameter $value of Kreait\Firebase\Database\Query\Filter\EqualTo#__construct() changed from no type to a non-contravariant bool|float|int|string -[BC] CHANGED: The parameter $value of Kreait\Firebase\Database\Query\Filter\StartAfter#__construct() changed from no type to a non-contravariant int|float|string|bool -[BC] CHANGED: The parameter $value of Kreait\Firebase\Database\Query\Filter\StartAt#__construct() changed from no type to a non-contravariant int|float|string|bool -[BC] CHANGED: The parameter $value of Kreait\Firebase\Database\Query\ModifierTrait#appendQueryParam() changed from no type to mixed -[BC] CHANGED: The parameter $value of Kreait\Firebase\Database\Reference#endAt() changed from no type to a non-contravariant bool|string|int|float -[BC] CHANGED: The parameter $value of Kreait\Firebase\Database\Reference#endAt() changed from no type to bool|string|int|float -[BC] CHANGED: The parameter $value of Kreait\Firebase\Database\Reference#endBefore() changed from no type to a non-contravariant bool|string|int|float -[BC] CHANGED: The parameter $value of Kreait\Firebase\Database\Reference#endBefore() changed from no type to bool|string|int|float -[BC] CHANGED: The parameter $value of Kreait\Firebase\Database\Reference#equalTo() changed from no type to a non-contravariant bool|string|int|float -[BC] CHANGED: The parameter $value of Kreait\Firebase\Database\Reference#equalTo() changed from no type to bool|string|int|float -[BC] CHANGED: The parameter $value of Kreait\Firebase\Database\Reference#set() changed from no type to mixed -[BC] CHANGED: The parameter $value of Kreait\Firebase\Database\Reference#startAfter() changed from no type to a non-contravariant bool|string|int|float -[BC] CHANGED: The parameter $value of Kreait\Firebase\Database\Reference#startAfter() changed from no type to bool|string|int|float -[BC] CHANGED: The parameter $value of Kreait\Firebase\Database\Reference#startAt() changed from no type to a non-contravariant bool|string|int|float -[BC] CHANGED: The parameter $value of Kreait\Firebase\Database\Reference#startAt() changed from no type to bool|string|int|float -[BC] CHANGED: The parameter $value of Kreait\Firebase\Database\Transaction#set() changed from no type to mixed -[BC] CHANGED: The parameter $value of Kreait\Firebase\Factory#withServiceAccount() changed from no type to a non-contravariant string|array -[BC] CHANGED: The parameter $versionNumber of Kreait\Firebase\Contract\RemoteConfig#getVersion() changed from no type to Kreait\Firebase\RemoteConfig\VersionNumber|int|string -[BC] CHANGED: The parameter $versionNumber of Kreait\Firebase\Contract\RemoteConfig#getVersion() changed from no type to a non-contravariant Kreait\Firebase\RemoteConfig\VersionNumber|int|string -[BC] CHANGED: The parameter $versionNumber of Kreait\Firebase\Contract\RemoteConfig#rollbackToVersion() changed from no type to Kreait\Firebase\RemoteConfig\VersionNumber|int|string -[BC] CHANGED: The parameter $versionNumber of Kreait\Firebase\Contract\RemoteConfig#rollbackToVersion() changed from no type to a non-contravariant Kreait\Firebase\RemoteConfig\VersionNumber|int|string -[BC] CHANGED: The return type of Kreait\Firebase\Contract\Database#runTransaction() changed from no type to mixed -[BC] CHANGED: The return type of Kreait\Firebase\Database\Query#getValue() changed from no type to mixed -[BC] CHANGED: The return type of Kreait\Firebase\Database\Query\Modifier#modifyValue() changed from no type to mixed -[BC] CHANGED: The return type of Kreait\Firebase\Database\Query\Modifier#modifyValue() changed from no type to mixed -[BC] CHANGED: The return type of Kreait\Firebase\Database\Query\Modifier#modifyValue() changed from no type to mixed -[BC] CHANGED: The return type of Kreait\Firebase\Database\Query\ModifierTrait#modifyValue() changed from no type to mixed -[BC] CHANGED: The return type of Kreait\Firebase\Database\Reference#getValue() changed from no type to mixed -[BC] CHANGED: The return type of Kreait\Firebase\Database\Snapshot#getValue() changed from no type to mixed -[BC] CHANGED: The return type of Kreait\Firebase\DynamicLink#previewUri() changed from Psr\Http\Message\UriInterface to the non-covariant Psr\Http\Message\UriInterface|null -[BC] CHANGED: Type of property Kreait\Firebase\Auth\UserInfo#$providerId changed from string|null to string -[BC] CHANGED: Type of property Kreait\Firebase\Auth\UserInfo#$uid changed from string|null to string -[BC] CHANGED: Type of property Kreait\Firebase\Auth\UserMetaData#$createdAt changed from DateTimeImmutable|null to DateTimeImmutable -[BC] REMOVED: Class Kreait\Firebase\Auth\CreateActionLink\ApiRequest has been deleted -[BC] REMOVED: Class Kreait\Firebase\Auth\CreateSessionCookie\ApiRequest has been deleted -[BC] REMOVED: Class Kreait\Firebase\Auth\SendActionLink\ApiRequest has been deleted -[BC] REMOVED: Class Kreait\Firebase\Exception\ServiceAccountDiscoveryFailed has been deleted -[BC] REMOVED: Constant Kreait\Firebase\RemoteConfig\DefaultValue::IN_APP_DEFAULT_VALUE was removed -[BC] REMOVED: Method Kreait\Firebase\Auth\DeleteUsersResult::fromRequestAndResponse() was removed -[BC] REMOVED: Method Kreait\Firebase\Auth\UserInfo#jsonSerialize() was removed -[BC] REMOVED: Method Kreait\Firebase\Auth\UserInfo::fromResponseData() was removed -[BC] REMOVED: Method Kreait\Firebase\Auth\UserMetaData#jsonSerialize() was removed -[BC] REMOVED: Method Kreait\Firebase\Auth\UserMetaData::fromResponseData() was removed -[BC] REMOVED: Method Kreait\Firebase\Auth\UserRecord#__get() was removed -[BC] REMOVED: Method Kreait\Firebase\Auth\UserRecord#jsonSerialize() was removed -[BC] REMOVED: Method Kreait\Firebase\Auth\UserRecord::fromResponseData() was removed -[BC] REMOVED: Method Kreait\Firebase\Factory#withClientEmail() was removed -[BC] REMOVED: Method Kreait\Firebase\Factory#withDisabledAutoDiscovery() was removed -[BC] REMOVED: Method Kreait\Firebase\Messaging\AndroidConfig#withHighPriority() was removed -[BC] REMOVED: Method Kreait\Firebase\Messaging\AndroidConfig#withNormalPriority() was removed -[BC] REMOVED: Method Kreait\Firebase\Messaging\AndroidConfig#withPriority() was removed -[BC] REMOVED: Method Kreait\Firebase\Messaging\RegistrationTokens#__construct() was removed -[BC] REMOVED: Method Kreait\Firebase\RemoteConfig\DefaultValue#value() was removed -[BC] REMOVED: Method Kreait\Firebase\RemoteConfig\DefaultValue::none() was removed -[BC] REMOVED: Property Kreait\Firebase\Auth\UserInfo#$screenName was removed -[BC] REMOVED: These ancestors of Kreait\Firebase\Auth\UserInfo have been removed: ["JsonSerializable"] -[BC] REMOVED: These ancestors of Kreait\Firebase\Auth\UserMetaData have been removed: ["JsonSerializable"] -[BC] REMOVED: These ancestors of Kreait\Firebase\Auth\UserRecord have been removed: ["JsonSerializable"] -``` diff --git a/UPGRADE-8.0.md b/UPGRADE-8.0.md new file mode 100644 index 000000000..dd3bcd280 --- /dev/null +++ b/UPGRADE-8.0.md @@ -0,0 +1,175 @@ +# Upgrade from 7.x to 8.0 + +## Introduction + +This is a major release, but its aim is to provide as much backward compatibility as possible to ease upgrades +from 7.x to 8.0. + +## Notable changes + +* The SDK supports only actively supported PHP versions. As a result, support for PHP < 8.3 has been dropped; + supported versions are 8.3, 8.4, and 8.5. +* [Firebase Dynamic Links was shut down on August 25th, 2025](https://firebase.google.com/support/dynamic-links-faq) + and has been removed from the SDK. + +### Type simplifications to reduce runtime overhead + +Several argument types have been simplified to their most common forms to eliminate runtime type conversion overhead. +For example, methods that previously accepted `Stringable|string` now only accept `string`. + +The union types were originally added for convenience, but introduced overhead when processing arguments, requiring +runtime type conversion and validation that could be replaced with static analysis. + +**See the complete list of breaking changes below** to identify any adjustments needed. Most changes should (hopefully) +be trivial (e.g., passing `$user->uid` instead of `$user`). Run your test suite to catch any breaking changes. + +## Complete list of breaking changes + +The following list has been generated with [roave/backward-compatibility-check](https://github.com/Roave/BackwardCompatibilityCheck). + +``` +[BC] CHANGED: Default parameter value for parameter $code of Kreait\Firebase\Exception\Database\TransactionFailed#__construct() changed from 0 to NULL +[BC] CHANGED: Default parameter value for parameter $code of Kreait\Firebase\Exception\Database\UnsupportedQuery#__construct() changed from 0 to NULL +[BC] CHANGED: The number of required arguments for Kreait\Firebase\Exception\Database\UnsupportedQuery#__construct() increased from 1 to 2 +[BC] CHANGED: The parameter $accessToken of Kreait\Firebase\Contract\Auth#signInWithIdpAccessToken() changed from string to Lcobucci\JWT\Token|string +[BC] CHANGED: The parameter $clearTextPassword of Kreait\Firebase\Contract\Auth#signInWithEmailAndPassword() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $clearTextPassword of Kreait\Firebase\Contract\Auth#signInWithEmailAndPassword() changed from Stringable|string to string +[BC] CHANGED: The parameter $clearTextPassword of Kreait\Firebase\Request\EditUserTrait#withClearTextPassword() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $clearTextPassword of Kreait\Firebase\Request\EditUserTrait#withClearTextPassword() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $clearTextPassword of Kreait\Firebase\Request\EditUserTrait#withClearTextPassword() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $clearTextPassword of Kreait\Firebase\Request\EditUserTrait#withClearTextPassword() changed from Stringable|string to string +[BC] CHANGED: The parameter $code of Kreait\Firebase\Exception\Database\TransactionFailed#__construct() changed from int to a non-contravariant Throwable|null +[BC] CHANGED: The parameter $code of Kreait\Firebase\Exception\Database\UnsupportedQuery#__construct() changed from int to a non-contravariant Throwable|null +[BC] CHANGED: The parameter $config of Kreait\Firebase\Messaging\CloudMessage#withAndroidConfig() changed from no type to a non-contravariant Kreait\Firebase\Messaging\AndroidConfig|array +[BC] CHANGED: The parameter $config of Kreait\Firebase\Messaging\CloudMessage#withApnsConfig() changed from no type to a non-contravariant Kreait\Firebase\Messaging\ApnsConfig|array +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#createUserWithEmailAndPassword() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#createUserWithEmailAndPassword() changed from Stringable|string to string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#getEmailActionLink() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#getEmailActionLink() changed from Stringable|string to string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#getEmailVerificationLink() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#getEmailVerificationLink() changed from Stringable|string to string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#getPasswordResetLink() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#getPasswordResetLink() changed from Stringable|string to string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#getSignInWithEmailLink() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#getSignInWithEmailLink() changed from Stringable|string to string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#getUserByEmail() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#getUserByEmail() changed from Stringable|string to string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#sendEmailActionLink() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#sendEmailActionLink() changed from Stringable|string to string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#sendEmailVerificationLink() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#sendEmailVerificationLink() changed from Stringable|string to string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#sendPasswordResetLink() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#sendPasswordResetLink() changed from Stringable|string to string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#sendSignInWithEmailLink() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#sendSignInWithEmailLink() changed from Stringable|string to string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#signInWithEmailAndOobCode() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#signInWithEmailAndOobCode() changed from Stringable|string to string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#signInWithEmailAndPassword() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Contract\Auth#signInWithEmailAndPassword() changed from Stringable|string to string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withEmail() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withEmail() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withEmail() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withEmail() changed from Stringable|string to string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withUnverifiedEmail() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withUnverifiedEmail() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withUnverifiedEmail() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withUnverifiedEmail() changed from Stringable|string to string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withVerifiedEmail() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withVerifiedEmail() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withVerifiedEmail() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $email of Kreait\Firebase\Request\EditUserTrait#withVerifiedEmail() changed from Stringable|string to string +[BC] CHANGED: The parameter $newEmail of Kreait\Firebase\Contract\Auth#changeUserEmail() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $newEmail of Kreait\Firebase\Contract\Auth#changeUserEmail() changed from Stringable|string to string +[BC] CHANGED: The parameter $newPassword of Kreait\Firebase\Contract\Auth#changeUserPassword() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $newPassword of Kreait\Firebase\Contract\Auth#changeUserPassword() changed from Stringable|string to string +[BC] CHANGED: The parameter $newPassword of Kreait\Firebase\Contract\Auth#confirmPasswordReset() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $newPassword of Kreait\Firebase\Contract\Auth#confirmPasswordReset() changed from Stringable|string to string +[BC] CHANGED: The parameter $password of Kreait\Firebase\Contract\Auth#createUserWithEmailAndPassword() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $password of Kreait\Firebase\Contract\Auth#createUserWithEmailAndPassword() changed from Stringable|string to string +[BC] CHANGED: The parameter $phoneNumber of Kreait\Firebase\Contract\Auth#getUserByPhoneNumber() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $phoneNumber of Kreait\Firebase\Contract\Auth#getUserByPhoneNumber() changed from Stringable|string to string +[BC] CHANGED: The parameter $phoneNumber of Kreait\Firebase\Request\EditUserTrait#withPhoneNumber() changed from no type to a non-contravariant string|null +[BC] CHANGED: The parameter $phoneNumber of Kreait\Firebase\Request\EditUserTrait#withPhoneNumber() changed from no type to a non-contravariant string|null +[BC] CHANGED: The parameter $phoneNumber of Kreait\Firebase\Request\EditUserTrait#withPhoneNumber() changed from no type to a non-contravariant string|null +[BC] CHANGED: The parameter $phoneNumber of Kreait\Firebase\Request\EditUserTrait#withPhoneNumber() changed from no type to string|null +[BC] CHANGED: The parameter $provider of Kreait\Firebase\Contract\Auth#signInWithIdpAccessToken() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $provider of Kreait\Firebase\Contract\Auth#signInWithIdpAccessToken() changed from Stringable|string to string +[BC] CHANGED: The parameter $provider of Kreait\Firebase\Contract\Auth#signInWithIdpIdToken() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $provider of Kreait\Firebase\Contract\Auth#signInWithIdpIdToken() changed from Stringable|string to string +[BC] CHANGED: The parameter $provider of Kreait\Firebase\Contract\Auth#unlinkProvider() changed from array|Stringable|string to a non-contravariant array|string +[BC] CHANGED: The parameter $provider of Kreait\Firebase\Contract\Auth#unlinkProvider() changed from array|Stringable|string to array|string +[BC] CHANGED: The parameter $provider of Kreait\Firebase\Request\UpdateUser#withRemovedProvider() changed from no type to a non-contravariant string +[BC] CHANGED: The parameter $providerId of Kreait\Firebase\Contract\Transitional\FederatedUserFetcher#getUserByProviderUid() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $providerId of Kreait\Firebase\Contract\Transitional\FederatedUserFetcher#getUserByProviderUid() changed from Stringable|string to string +[BC] CHANGED: The parameter $providerUid of Kreait\Firebase\Contract\Transitional\FederatedUserFetcher#getUserByProviderUid() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $providerUid of Kreait\Firebase\Contract\Transitional\FederatedUserFetcher#getUserByProviderUid() changed from Stringable|string to string +[BC] CHANGED: The parameter $redirectUrl of Kreait\Firebase\Contract\Auth#signInWithIdpAccessToken() changed from no type to a non-contravariant string|null +[BC] CHANGED: The parameter $redirectUrl of Kreait\Firebase\Contract\Auth#signInWithIdpAccessToken() changed from no type to string|null +[BC] CHANGED: The parameter $redirectUrl of Kreait\Firebase\Contract\Auth#signInWithIdpIdToken() changed from no type to a non-contravariant string|null +[BC] CHANGED: The parameter $redirectUrl of Kreait\Firebase\Contract\Auth#signInWithIdpIdToken() changed from no type to string|null +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#changeUserEmail() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#changeUserEmail() changed from Stringable|string to string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#changeUserPassword() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#changeUserPassword() changed from Stringable|string to string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#createCustomToken() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#createCustomToken() changed from Stringable|string to string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#deleteUser() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#deleteUser() changed from Stringable|string to string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#disableUser() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#disableUser() changed from Stringable|string to string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#enableUser() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#enableUser() changed from Stringable|string to string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#getUser() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#getUser() changed from Stringable|string to string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#revokeRefreshTokens() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#revokeRefreshTokens() changed from Stringable|string to string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#setCustomUserClaims() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#setCustomUserClaims() changed from Stringable|string to string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#unlinkProvider() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#unlinkProvider() changed from Stringable|string to string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#updateUser() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Contract\Auth#updateUser() changed from Stringable|string to string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Request\EditUserTrait#withUid() changed from no type to a non-contravariant string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Request\EditUserTrait#withUid() changed from no type to a non-contravariant string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Request\EditUserTrait#withUid() changed from no type to a non-contravariant string +[BC] CHANGED: The parameter $uid of Kreait\Firebase\Request\EditUserTrait#withUid() changed from no type to string +[BC] CHANGED: The parameter $url of Kreait\Firebase\Request\EditUserTrait#withPhotoUrl() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $url of Kreait\Firebase\Request\EditUserTrait#withPhotoUrl() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $url of Kreait\Firebase\Request\EditUserTrait#withPhotoUrl() changed from Stringable|string to a non-contravariant string +[BC] CHANGED: The parameter $url of Kreait\Firebase\Request\EditUserTrait#withPhotoUrl() changed from Stringable|string to string +[BC] CHANGED: The parameter $user of Kreait\Firebase\Contract\Auth#signInAsUser() changed from Kreait\Firebase\Auth\UserRecord|Stringable|string to Kreait\Firebase\Auth\UserRecord|string +[BC] CHANGED: The parameter $user of Kreait\Firebase\Contract\Auth#signInAsUser() changed from Kreait\Firebase\Auth\UserRecord|Stringable|string to a non-contravariant Kreait\Firebase\Auth\UserRecord|string +[BC] CHANGED: The parameter $value of Kreait\Firebase\Messaging\ApnsConfig#withDataField() changed from mixed to a non-contravariant string +[BC] CHANGED: The parameter $value of Kreait\Firebase\RemoteConfig\ConditionalValue#withValue() changed from no type to Kreait\Firebase\RemoteConfig\ParameterValue|array|string +[BC] CHANGED: The parameter $value of Kreait\Firebase\RemoteConfig\ConditionalValue#withValue() changed from no type to a non-contravariant Kreait\Firebase\RemoteConfig\ParameterValue|array|string +[BC] CHANGED: The return type of Kreait\Firebase\RemoteConfig\ConditionalValue#value() changed from no type to string|array +[BC] CHANGED: The return type of Kreait\Firebase\RemoteConfig\TagColor#__toString() changed from no type to string +[BC] REMOVED: Class Kreait\Firebase\Contract\DynamicLinks has been deleted +[BC] REMOVED: Class Kreait\Firebase\DynamicLink has been deleted +[BC] REMOVED: Class Kreait\Firebase\DynamicLink\AnalyticsInfo has been deleted +[BC] REMOVED: Class Kreait\Firebase\DynamicLink\AnalyticsInfo\GooglePlayAnalytics has been deleted +[BC] REMOVED: Class Kreait\Firebase\DynamicLink\AnalyticsInfo\ITunesConnectAnalytics has been deleted +[BC] REMOVED: Class Kreait\Firebase\DynamicLink\AndroidInfo has been deleted +[BC] REMOVED: Class Kreait\Firebase\DynamicLink\CreateDynamicLink has been deleted +[BC] REMOVED: Class Kreait\Firebase\DynamicLink\CreateDynamicLink\FailedToCreateDynamicLink has been deleted +[BC] REMOVED: Class Kreait\Firebase\DynamicLink\DynamicLinkStatistics has been deleted +[BC] REMOVED: Class Kreait\Firebase\DynamicLink\EventStatistics has been deleted +[BC] REMOVED: Class Kreait\Firebase\DynamicLink\GetStatisticsForDynamicLink has been deleted +[BC] REMOVED: Class Kreait\Firebase\DynamicLink\GetStatisticsForDynamicLink\FailedToGetStatisticsForDynamicLink has been deleted +[BC] REMOVED: Class Kreait\Firebase\DynamicLink\IOSInfo has been deleted +[BC] REMOVED: Class Kreait\Firebase\DynamicLink\NavigationInfo has been deleted +[BC] REMOVED: Class Kreait\Firebase\DynamicLink\ShortenLongDynamicLink has been deleted +[BC] REMOVED: Class Kreait\Firebase\DynamicLink\ShortenLongDynamicLink\FailedToShortenLongDynamicLink has been deleted +[BC] REMOVED: Class Kreait\Firebase\DynamicLink\SocialMetaTagInfo has been deleted +[BC] REMOVED: Class Kreait\Firebase\RemoteConfig\ExplicitValue has been deleted +[BC] REMOVED: Constant Kreait\Firebase\Contract\Messaging::BATCH_MESSAGE_LIMIT was removed +[BC] REMOVED: Method Kreait\Firebase\Factory#createDynamicLinksService() was removed +[BC] REMOVED: Method Kreait\Firebase\Factory#getDebugInfo() was removed +[BC] REMOVED: Method Kreait\Firebase\Factory#withFirestoreDatabase() was removed +[BC] REMOVED: Method Kreait\Firebase\Factory#withHttpDebugLogger() was removed +[BC] REMOVED: Method Kreait\Firebase\Factory#withHttpLogger() was removed +[BC] REMOVED: Method Kreait\Firebase\Messaging\CloudMessage#hasTarget() was removed +[BC] REMOVED: Method Kreait\Firebase\Messaging\CloudMessage#target() was removed +[BC] REMOVED: Method Kreait\Firebase\Messaging\CloudMessage#withChangedTarget() was removed +[BC] REMOVED: Method Kreait\Firebase\Messaging\CloudMessage::withTarget() was removed +``` diff --git a/composer.json b/composer.json index 46f9691fc..00aca5470 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ } ], "require": { - "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", + "php": "~8.3.0 || ~8.4.0 || ~8.5.0", "ext-ctype": "*", "ext-filter": "*", "ext-json": "*", @@ -46,21 +46,22 @@ "psr/clock": "^1.0", "psr/http-client": "^1.0.3", "psr/http-factory": "^1.1", - "psr/http-message": "^1.1 || ^2.0", - "psr/log": "^3.0.2" + "psr/http-message": "^1.1 || ^2.0" }, "require-dev": { - "php-cs-fixer/shim": "^3.88.2", - "google/cloud-firestore": "^1.54.2", + "google/cloud-firestore": "^1.54.3", + "php-cs-fixer/shim": "^3.91.2", "phpstan/extension-installer": "^1.4.3", - "phpstan/phpstan": "^2.1.31", + "phpstan/phpstan": "^2.1.32", "phpstan/phpstan-deprecation-rules": "^2.0.3", + "phpstan/phpstan-phpunit": "^2.0.8", "phpstan/phpstan-strict-rules": "^2.0.7", - "phpstan/phpstan-phpunit": "^2.0.7", - "phpunit/phpunit": "^10.5.58", - "rector/rector": "^2.2.2", - "shipmonk/composer-dependency-analyser": "^1.8.3", - "symfony/var-dumper": "^6.4.15 || ^7.3.4", + "phpunit/phpunit": "^12.4.5", + "psr/log": "^3.0.2", + "rector/rector": "^2.2.11", + "rector/type-perfect": "^2.1", + "shipmonk/composer-dependency-analyser": "^1.8.4", + "symfony/var-dumper": "^7.4.0", "vlucas/phpdotenv": "^5.6.2" }, "suggest": { @@ -153,7 +154,8 @@ }, "extra": { "branch-alias": { - "dev-7.x": "7.x-dev" + "dev-7.x": "7.x-dev", + "dev-8.x": "8.x-dev" } } } diff --git a/docs/conf.py b/docs/conf.py index 41a689570..3fd687931 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -4,7 +4,7 @@ project = 'Firebase Admin SDK for PHP' author = 'Jérôme Gamez' copyright = 'Jérôme Gamez' -version = '7.x' +version = '8.x' release = version # This will be used by Furo for version display language = 'en' @@ -42,7 +42,7 @@ html_theme_options = { # GitHub integration "source_repository": "https://github.com/kreait/firebase-php/", - "source_branch": "7.x", + "source_branch": "8.x", "source_directory": "docs/", # Navigation diff --git a/docs/dynamic-links.rst b/docs/dynamic-links.rst deleted file mode 100644 index 9973a7c5b..000000000 --- a/docs/dynamic-links.rst +++ /dev/null @@ -1,263 +0,0 @@ -############# -Dynamic Links -############# - -You can create short Dynamic Links with the Firebase Admin SDK for PHP. Dynamic Links can be - -- a long Dynamic Link -- an array containing Dynamic Link parameters -- an action created with builder methods - -and will return a URL like ``https://example.page.link/wXYZ``. - - -.. note:: - Short Dynamic Links created via the REST API or this SDK do not show up in the Firebase console. Such Dynamic Links - are intended for user-to-user sharing. For marketing use cases, continue to create your links directly through the - `Dynamic Links page `_ of the Firebase console. - -Before you start, please read about Dynamic Links in the official documentation: - -- `Dynamic Links Product Page `_ -- `Create Dynamic Links with the REST API `_ -- `Long Dynamic Links `_ -- `Dynamic Link API Reference `_ - -*************** -Getting started -*************** - -- In the Firebase console, open the - `Dynamic Links `_ section. -- If you have not already accepted the terms of service and set a domain for your Dynamic Links, do so when prompted. -- If you already have a Dynamic Links domain, take note of it. You need to provide a Dynamic Links Domain when you - programmatically create Dynamic Links. - -**************************************** -Initializing the Dynamic Links component -**************************************** - -.. code-block:: php - - $dynamicLinksDomain = 'https://example.page.link'; - $dynamicLinks = $factory->createDynamicLinksService($dynamicLinksDomain); - -********************* -Create a Dynamic Link -********************* - -You can create a Dynamic Link by using one of the methods below. Each method will return an instance of -``Kreait\Firebase\DynamicLink``. - -.. code-block:: php - - use use Kreait\Firebase\DynamicLink\CreateDynamicLink\FailedToCreateDynamicLink; - - $url = 'https://www.example.com/some/path'; - - try { - $link = $dynamicLinks->createUnguessableLink($url); - $link = $dynamicLinks->createDynamicLink($url, CreateDynamicLink::WITH_UNGUESSABLE_SUFFIX); - - $link = $dynamicLinks->createShortLink($url); - $link = $dynamicLinks->createDynamicLink($url, CreateDynamicLink::WITH_SHORT_SUFFIX); - } catch (FailedToCreateDynamicLink $e) { - echo $e->getMessage(); exit; - } - -If ``createDynamicLink()`` is called without a second parameter, the Dynamic Link is created with an unguessable suffix. - -Unguessable suffixes have a length of 17 characters, short suffixes a length of 4 characters. You can learn more about -the length of Dynamic Links in the -`official documentation `_. - -The returned object will be an instance of ``Kreait\Firebase\DynamicLink`` with the following accessors: - -.. code-block:: php - - $link->uri(); // Psr\Http\Message\UriInterface - $link->previewUri(); // Psr\Http\Message\UriInterface - $link->domain(); // string - $link->suffix(); // string - $link->hasWarnings(); // bool - $link->warnings(); // array - - $uriString = (string) $link; - -************************************ -Create a short link from a long link -************************************ - -If you have a `manually constructed link `_, -you can convert it to a short link: - -.. code-block:: php - - use Kreait\Firebase\DynamicLink\ShortenLongDynamicLink\FailedToShortenLongDynamicLink; - - $longLink = 'https://example.page.link?link=https://example.com/some/path'; - - try { - $link = $dynamicLinks->shortenLongDynamicLink($longLink); - $link = $dynamicLinks->shortenLongDynamicLink($longLink, ShortenLongDynamicLink::WITH_UNGUESSABLE_SUFFIX); - $link = $dynamicLinks->shortenLongDynamicLink($longLink, ShortenLongDynamicLink::WITH_SHORT_SUFFIX); - } catch (FailedToShortenLongDynamicLink $e) { - echo $e->getMessage(); exit; - } - -If ``shortenLongDynamicLink()`` is called without a second parameter, the Dynamic Link is created with an unguessable suffix. - -******************* -Get link statistics -******************* - -You can use this REST API to get analytics data for each of your short Dynamic Links, whether created in the console -or programmatically. - -.. note:: - These statistics might not include events that have been logged within the last 36 hours. - -.. code-block:: php - - use Kreait\Firebase\DynamicLink\GetStatisticsForDynamicLink\FailedToGetStatisticsForDynamicLink; - - try { - $stats = $dynamicLinks->getStatistics('https://example.page.link/wXYZ'); - $stats = $dynamicLinks->getStatistics('https://example.page.link/wXYZ', 14); // duration in days - } catch (FailedToGetStatisticsForDynamicLink $e) { - echo $e->getMessage(); exit; - } - -If ``getStatistics()`` is called without a second parameter, stats will include the statistics of the past 7 days. - -The returned object will be an instance of ``Kreait\Firebase\DynamicLink\DynamicLinkStatistics``, which currently -only includes event statistics. You can access the raw returned data with ``$stats->rawData()``. - -Event Statistics ----------------- - -Firebase Dynamic Links tracks the number of times each of your short Dynamic Links have been clicked, as well as the -number of times a click resulted in a redirect, app install, app first-open, or app re-open, including the platform -on which that event occurred. - -Each of the following methods returns a (filtered) instance of ``Kreait\Firebase\DynamicLink\EventStatistics`` which -supports any combination of filters and is countable with ``count()`` or ``->count()`` as shown below: - -.. code-block:: php - - $eventStats = $stats->eventStatistics(); - - $allClicks = $eventStats->clicks(); - $allRedirects = $eventStats->redirects(); - $allAppInstalls = $eventStats->appInstalls(); - $allAppFirstOpens = $eventStats->appFirstOpens(); - $allAppReOpens = $eventStats->appReOpens(); - - $allAndroidEvents = $eventStats->onAndroid(); - $allDesktopEvents = $eventStats->onDesktop(); - $allIOSEvents = $eventStats->onIOS(); - - $clicksOnDesktop = $eventStats->clicks()->onDesktop(); - $appInstallsOnAndroid = $eventStats->onAndroid()->appInstalls(); - $appReOpensOnIOS = $eventStats->appReOpens()->onIOS(); - - $totalAmountOfClicks = count($eventStats->clicks()); - $totalAmountOfAppFirstOpensOnAndroid = $eventStats->appFirstOpens()->onAndroid()->count(); - - $custom = $eventStats->filter(function (array $eventGroup) { - return $eventGroup['platform'] === 'CUSTOM_PLATFORM_THAT_THE_SDK_DOES_NOT_KNOW_YET'; - }); - -************** -Advanced usage -************** - -Using actions -------------- - -You can fully customize the creation of Dynamic Links by building up a ``Kreait\Firebase\DynamicLink\CreateDynamicLink`` -action. The following code shows all available building components: - -.. code-block:: php - - use Kreait\Firebase\DynamicLink\CreateDynamicLink; - - $action = CreateDynamicLink::forUrl($url) - ->withDynamicLinkDomain('https://example.page.link') - ->withUnguessableSuffix() // default - // or - ->withShortSuffix() - ->withAnalyticsInfo( - AnalyticsInfo::new() - ->withGooglePlayAnalyticsInfo( - GooglePlayAnalytics::new() - ->withGclid('gclid') - ->withUtmCampaign('utmCampaign') - ->withUtmContent('utmContent') - ->withUtmMedium('utmMedium') - ->withUtmSource('utmSource') - ->withUtmTerm('utmTerm') - ) - ->withItunesConnectAnalytics( - ITunesConnectAnalytics::new() - ->withAffiliateToken('affiliateToken') - ->withCampaignToken('campaignToken') - ->withMediaType('8') - ->withProviderToken('providerToken') - ) - ) - ->withNavigationInfo( - NavigationInfo::new() - ->withoutForcedRedirect() // default - // or - ->withForcedRedirect() - ) - ->withIOSInfo( - IOSInfo::new() - ->withAppStoreId('appStoreId') - ->withBundleId('bundleId') - ->withCustomScheme('customScheme') - ->withFallbackLink('https://fallback.example.com') - ->withIPadBundleId('iPadBundleId') - ->withIPadFallbackLink('https://ipad-fallback.example.com') - ) - ->withAndroidInfo( - AndroidInfo::new() - ->withFallbackLink('https://fallback.example.com') - ->withPackageName('packageName') - ->withMinPackageVersionCode('minPackageVersionCode') - ) - ->withSocialMetaTagInfo( - SocialMetaTagInfo::new() - ->withDescription('Social Meta Tag description') - ->withTitle('Social Meta Tag title') - ->withImageLink('https://example.com/image.jpg') - ); - - $link = $dynamicLinks->createDynamicLink($action); - -Using parameter arrays ----------------------- - -If you prefer using a parameter array to configure a Dynamic Link, or if this SDK doesn't yet have support for a -given new option, you can pass an array to the ``createDynamicLink()`` method. As the parameters will not be processed -or validated by the SDK, you have to make sure that the parameter structure matches the one described in the -`API Reference Documentation `_ - -.. code-block:: php - - use use Kreait\Firebase\DynamicLink\CreateDynamicLink\FailedToCreateDynamicLink; - - $parameters = [ - 'dynamicLinkInfo' => [ - 'domainUriPrefix' => 'https://example.page.link', - 'link' => 'https://example.com/some/path', - ], - 'suffix' => ['option' => 'SHORT'], - ]; - - try { - $link = $dynamicLinks->createDynamicLink($parameters); - } catch (FailedToCreateDynamicLink $e) { - echo $e->getMessage(); exit; - } diff --git a/docs/index.rst b/docs/index.rst index b174887dc..5a1605800 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -115,7 +115,6 @@ Your use of Firebase is governed by the `Terms of Service for Firebase Services realtime-database authentication user-management - dynamic-links remote-config app-check testing diff --git a/docs/troubleshooting.rst b/docs/troubleshooting.rst index 88e75c44f..f7049a064 100644 --- a/docs/troubleshooting.rst +++ b/docs/troubleshooting.rst @@ -111,7 +111,6 @@ enabled for your project: - Firebase Services: https://console.cloud.google.com/apis/library/firebase.googleapis.com - Cloud Messaging (FCM): https://console.cloud.google.com/apis/library/fcm.googleapis.com - FCM Registration API: https://console.cloud.google.com/apis/library/fcmregistrations.googleapis.com -- Dynamic Links: https://console.cloud.google.com/apis/library/firebasedynamiclinks.googleapis.com - Firestore: https://console.cloud.google.com/apis/library/firestore.googleapis.com - Realtime Database Rules: https://console.cloud.google.com/apis/library/firebaserules.googleapis.com - Remote Config: https://console.cloud.google.com/apis/library/firebaseremoteconfig.googleapis.com diff --git a/docs/user-management.rst b/docs/user-management.rst index 94cd5867f..48d51146d 100644 --- a/docs/user-management.rst +++ b/docs/user-management.rst @@ -523,11 +523,6 @@ the email link. This also provides the user the ability to go back to the app af In addition, you can specify whether to handle the email action link directly from a mobile application when it is installed or from a browser. -For links that are meant to be opened via a mobile app, you’ll need to enable Firebase Dynamic Links and perform some -tasks to detect these links from your mobile app. Refer to the instructions on how to -`configure Firebase Dynamic Links `_ -for email actions. - ========================= =========== =========== Parameter Type Description ========================= =========== =========== @@ -558,7 +553,6 @@ Example: $actionCodeSettings = [ 'continueUrl' => 'https://www.example.com/checkout?cartId=1234', 'handleCodeInApp' => true, - 'dynamicLinkDomain' => 'coolapp.page.link', 'androidPackageName' => 'com.example.android', 'androidMinimumVersion' => '12', 'androidInstallApp' => true, diff --git a/phpstan.neon.dist b/phpstan.neon.dist index bec0913fe..d3ef80c55 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -21,12 +21,30 @@ parameters: identifier: staticMethod.dynamicCall path: tests - checkUninitializedProperties: true + editorUrl: 'phpstorm://open?file=%%file%%&line=%%line%%' + + exceptions: + checkedExceptionRegexes: + - '#^Kreait\\Firebase\\#' + check: + # missingCheckedExceptionInThrows: true + # tooWideThrowType: true + checkBenevolentUnionTypes: true + # checkMissingCallableSignature: true checkTooWideReturnTypesInProtectedAndPublicMethods: true + checkUninitializedProperties: true reportAlwaysTrueInLastCondition: true reportPossiblyNonexistentConstantArrayOffset: true - treatPhpDocTypesAsCertain: false + # reportPossiblyNonexistentGeneralArrayOffset: true + reportAnyTypeWideningInVarTag: true + + type_perfect: + no_mixed_property: true + no_mixed_caller: true + null_over_false: true + narrow_param: false + narrow_return: true includes: - vendor/cuyz/valinor/qa/PHPStan/valinor-phpstan-configuration.php - vendor/phpstan/phpstan/conf/bleedingEdge.neon diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0ff55961f..ab2a348d1 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -19,15 +19,10 @@ - + src/Firebase - - - - src/Firebase/DynamicLink - diff --git a/src/Firebase/AppCheck.php b/src/Firebase/AppCheck.php index e79b3df4a..5ed94859a 100644 --- a/src/Firebase/AppCheck.php +++ b/src/Firebase/AppCheck.php @@ -16,12 +16,12 @@ /** * @internal */ -final class AppCheck implements Contract\AppCheck +final readonly class AppCheck implements Contract\AppCheck { public function __construct( - private readonly ApiClient $client, - private readonly AppCheckTokenGenerator $tokenGenerator, - private readonly AppCheckTokenVerifier $tokenVerifier, + private ApiClient $client, + private AppCheckTokenGenerator $tokenGenerator, + private AppCheckTokenVerifier $tokenVerifier, ) { } diff --git a/src/Firebase/AppCheck/ApiClient.php b/src/Firebase/AppCheck/ApiClient.php index 314c6187b..af8089bd4 100644 --- a/src/Firebase/AppCheck/ApiClient.php +++ b/src/Firebase/AppCheck/ApiClient.php @@ -17,11 +17,11 @@ * * @phpstan-import-type AppCheckTokenShape from AppCheckToken */ -final class ApiClient +final readonly class ApiClient { public function __construct( - private readonly ClientInterface $client, - private readonly AppCheckApiExceptionConverter $errorHandler, + private ClientInterface $client, + private AppCheckApiExceptionConverter $errorHandler, ) { } diff --git a/src/Firebase/AppCheck/AppCheckToken.php b/src/Firebase/AppCheck/AppCheckToken.php index f739c96f7..f3456bcfb 100644 --- a/src/Firebase/AppCheck/AppCheckToken.php +++ b/src/Firebase/AppCheck/AppCheckToken.php @@ -10,11 +10,11 @@ * ttl: string * } */ -final class AppCheckToken +final readonly class AppCheckToken { private function __construct( - public readonly string $token, - public readonly string $ttl, + public string $token, + public string $ttl, ) { } diff --git a/src/Firebase/AppCheck/AppCheckTokenGenerator.php b/src/Firebase/AppCheck/AppCheckTokenGenerator.php index eef566ce0..8e223b2c1 100644 --- a/src/Firebase/AppCheck/AppCheckTokenGenerator.php +++ b/src/Firebase/AppCheck/AppCheckTokenGenerator.php @@ -14,19 +14,19 @@ * * @todo Add #[SensitiveParameter] attribute to the private key once the minimum required PHP version is >=8.2 */ -final class AppCheckTokenGenerator +final readonly class AppCheckTokenGenerator { - private const APP_CHECK_AUDIENCE = 'https://firebaseappcheck.googleapis.com/google.firebase.appcheck.v1.TokenExchangeService'; + private const string APP_CHECK_AUDIENCE = 'https://firebaseappcheck.googleapis.com/google.firebase.appcheck.v1.TokenExchangeService'; - private readonly ClockInterface $clock; + private ClockInterface $clock; /** * @param non-empty-string $clientEmail * @param non-empty-string $privateKey */ public function __construct( - private readonly string $clientEmail, - private readonly string $privateKey, + private string $clientEmail, + private string $privateKey, ?ClockInterface $clock = null, ) { $this->clock = $clock ?? SystemClock::create(); diff --git a/src/Firebase/AppCheck/AppCheckTokenOptions.php b/src/Firebase/AppCheck/AppCheckTokenOptions.php index 6239c8e6d..5a3cc7353 100644 --- a/src/Firebase/AppCheck/AppCheckTokenOptions.php +++ b/src/Firebase/AppCheck/AppCheckTokenOptions.php @@ -11,10 +11,10 @@ * ttl?: int|null, * } */ -final class AppCheckTokenOptions +final readonly class AppCheckTokenOptions { private function __construct( - public readonly ?int $ttl = null, + public ?int $ttl = null, ) { } diff --git a/src/Firebase/AppCheck/AppCheckTokenVerifier.php b/src/Firebase/AppCheck/AppCheckTokenVerifier.php index 37427dde0..aa299f59a 100644 --- a/src/Firebase/AppCheck/AppCheckTokenVerifier.php +++ b/src/Firebase/AppCheck/AppCheckTokenVerifier.php @@ -19,16 +19,16 @@ * * @phpstan-import-type DecodedAppCheckTokenShape from DecodedAppCheckToken */ -final class AppCheckTokenVerifier +final readonly class AppCheckTokenVerifier { - private const APP_CHECK_ISSUER_PREFIX = 'https://firebaseappcheck.googleapis.com/'; + private const string APP_CHECK_ISSUER_PREFIX = 'https://firebaseappcheck.googleapis.com/'; /** * @param non-empty-string $projectId */ public function __construct( - private readonly string $projectId, - private readonly CachedKeySet $keySet, + private string $projectId, + private CachedKeySet $keySet, ) { } @@ -61,9 +61,9 @@ private function decodeJwt(string $token): DecodedAppCheckToken /** @var DecodedAppCheckTokenShape $payload */ $payload = (array) JWT::decode($token, $this->keySet); } catch (LogicException $e) { - throw new InvalidAppCheckToken($e->getMessage(), $e->getCode(), $e); + throw new InvalidAppCheckToken(message: $e->getMessage(), previous: $e); } catch (Throwable $e) { - throw new FailedToVerifyAppCheckToken($e->getMessage(), $e->getCode(), $e); + throw new FailedToVerifyAppCheckToken(message: $e->getMessage(), previous: $e); } return DecodedAppCheckToken::fromArray($payload); diff --git a/src/Firebase/AppCheck/DecodedAppCheckToken.php b/src/Firebase/AppCheck/DecodedAppCheckToken.php index 2081728b8..6890fa311 100644 --- a/src/Firebase/AppCheck/DecodedAppCheckToken.php +++ b/src/Firebase/AppCheck/DecodedAppCheckToken.php @@ -14,7 +14,7 @@ * sub: non-empty-string, * } */ -final class DecodedAppCheckToken +final readonly class DecodedAppCheckToken { /** * @param non-empty-string $app_id @@ -22,12 +22,12 @@ final class DecodedAppCheckToken * @param non-empty-string $sub */ private function __construct( - public readonly string $app_id, - public readonly array $aud, - public readonly int $exp, - public readonly int $iat, - public readonly string $iss, - public readonly string $sub, + public string $app_id, + public array $aud, + public int $exp, + public int $iat, + public string $iss, + public string $sub, ) { } diff --git a/src/Firebase/AppCheck/VerifyAppCheckTokenResponse.php b/src/Firebase/AppCheck/VerifyAppCheckTokenResponse.php index 4d17d3980..6fd2b3f61 100644 --- a/src/Firebase/AppCheck/VerifyAppCheckTokenResponse.php +++ b/src/Firebase/AppCheck/VerifyAppCheckTokenResponse.php @@ -12,14 +12,14 @@ * token: DecodedAppCheckTokenShape, * } */ -final class VerifyAppCheckTokenResponse +final readonly class VerifyAppCheckTokenResponse { /** * @param non-empty-string $appId */ public function __construct( - public readonly string $appId, - public readonly DecodedAppCheckToken $token, + public string $appId, + public DecodedAppCheckToken $token, ) { } } diff --git a/src/Firebase/Auth.php b/src/Firebase/Auth.php index 98c6ecc61..afdcdb255 100644 --- a/src/Firebase/Auth.php +++ b/src/Firebase/Auth.php @@ -46,7 +46,6 @@ use Lcobucci\JWT\UnencryptedToken; use Psr\Clock\ClockInterface; use Psr\Http\Message\ResponseInterface; -use Stringable; use Throwable; use Traversable; @@ -62,21 +61,21 @@ * * @phpstan-import-type UserRecordResponseShape from UserRecord */ -final class Auth implements Contract\Auth, FederatedUserFetcher +final readonly class Auth implements Contract\Auth, FederatedUserFetcher { - private readonly Parser $jwtParser; + private Parser $jwtParser; public function __construct( - private readonly ApiClient $client, - private readonly ?CustomTokenViaGoogleCredentials $tokenGenerator, - private readonly IdTokenVerifier $idTokenVerifier, - private readonly SessionCookieVerifier $sessionCookieVerifier, - private readonly ClockInterface $clock, + private ApiClient $client, + private ?CustomTokenViaGoogleCredentials $tokenGenerator, + private IdTokenVerifier $idTokenVerifier, + private SessionCookieVerifier $sessionCookieVerifier, + private ClockInterface $clock, ) { $this->jwtParser = new Parser(new JoseEncoder()); } - public function getUser(Stringable|string $uid): UserRecord + public function getUser(string $uid): UserRecord { $uid = Uid::fromString($uid)->value; @@ -91,7 +90,7 @@ public function getUser(Stringable|string $uid): UserRecord public function getUsers(array $uids): array { - $uids = array_map(static fn($uid): string => Uid::fromString($uid)->value, $uids); + $uids = array_map(static fn(string $uid): string => Uid::fromString($uid)->value, $uids); $users = array_fill_keys($uids, null); @@ -161,7 +160,7 @@ public function createUser(array|CreateUser $properties): UserRecord return $this->getUserRecordFromResponseAfterUserUpdate($response); } - public function updateUser(Stringable|string $uid, array|UpdateUser $properties): UserRecord + public function updateUser(string $uid, array|UpdateUser $properties): UserRecord { $request = $properties instanceof UpdateUser ? $properties @@ -174,7 +173,7 @@ public function updateUser(Stringable|string $uid, array|UpdateUser $properties) return $this->getUserRecordFromResponseAfterUserUpdate($response); } - public function createUserWithEmailAndPassword(Stringable|string $email, Stringable|string $password): UserRecord + public function createUserWithEmailAndPassword(string $email, string $password): UserRecord { return $this->createUser( CreateUser::new() @@ -183,9 +182,9 @@ public function createUserWithEmailAndPassword(Stringable|string $email, Stringa ); } - public function getUserByEmail(Stringable|string $email): UserRecord + public function getUserByEmail(string $email): UserRecord { - $email = Email::fromString((string) $email)->value; + $email = Email::fromString($email)->value; $response = $this->client->getUserByEmail($email); @@ -198,10 +197,8 @@ public function getUserByEmail(Stringable|string $email): UserRecord return $userRecord; } - public function getUserByPhoneNumber(Stringable|string $phoneNumber): UserRecord + public function getUserByPhoneNumber(string $phoneNumber): UserRecord { - $phoneNumber = (string) $phoneNumber; - $response = $this->client->getUserByPhoneNumber($phoneNumber); $userRecord = self::getFirstUserRecordFromUserListResponse($response); @@ -213,11 +210,8 @@ public function getUserByPhoneNumber(Stringable|string $phoneNumber): UserRecord return $userRecord; } - public function getUserByProviderUid(Stringable|string $providerId, Stringable|string $providerUid): UserRecord + public function getUserByProviderUid(string $providerId, string $providerUid): UserRecord { - $providerId = (string) $providerId; - $providerUid = (string) $providerUid; - $response = $this->client->getUserByProviderUid($providerId, $providerUid); $userRecord = self::getFirstUserRecordFromUserListResponse($response); @@ -234,27 +228,27 @@ public function createAnonymousUser(): UserRecord return $this->createUser(CreateUser::new()); } - public function changeUserPassword(Stringable|string $uid, Stringable|string $newPassword): UserRecord + public function changeUserPassword(string $uid, string $newPassword): UserRecord { return $this->updateUser($uid, UpdateUser::new()->withClearTextPassword($newPassword)); } - public function changeUserEmail(Stringable|string $uid, Stringable|string $newEmail): UserRecord + public function changeUserEmail(string $uid, string $newEmail): UserRecord { return $this->updateUser($uid, UpdateUser::new()->withEmail($newEmail)); } - public function enableUser(Stringable|string $uid): UserRecord + public function enableUser(string $uid): UserRecord { return $this->updateUser($uid, UpdateUser::new()->markAsEnabled()); } - public function disableUser(Stringable|string $uid): UserRecord + public function disableUser(string $uid): UserRecord { return $this->updateUser($uid, UpdateUser::new()->markAsDisabled()); } - public function deleteUser(Stringable|string $uid): void + public function deleteUser(string $uid): void { $uid = Uid::fromString($uid)->value; @@ -277,9 +271,9 @@ public function deleteUsers(iterable $uids, bool $forceDeleteEnabledUsers = fals return DeleteUsersResult::fromRequestAndResponse($request, $response); } - public function getEmailActionLink(string $type, Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): string + public function getEmailActionLink(string $type, string $email, $actionCodeSettings = null, ?string $locale = null): string { - $email = Email::fromString((string) $email)->value; + $email = Email::fromString($email)->value; if ($actionCodeSettings === null) { $actionCodeSettings = ValidatedActionCodeSettings::empty(); @@ -292,9 +286,9 @@ public function getEmailActionLink(string $type, Stringable|string $email, $acti return $this->client->getEmailActionLink($type, $email, $actionCodeSettings, $locale); } - public function sendEmailActionLink(string $type, Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): void + public function sendEmailActionLink(string $type, string $email, $actionCodeSettings = null, ?string $locale = null): void { - $email = Email::fromString((string) $email)->value; + $email = Email::fromString($email)->value; if ($actionCodeSettings === null) { $actionCodeSettings = ValidatedActionCodeSettings::empty(); @@ -312,13 +306,13 @@ public function sendEmailActionLink(string $type, Stringable|string $email, $act try { $user = $this->getUserByEmail($email); } catch (Throwable $e) { - throw new FailedToSendActionLink($e->getMessage(), $e->getCode(), $e); + throw new FailedToSendActionLink(message: $e->getMessage(), previous: $e); } try { $signInResult = $this->signInAsUser($user); } catch (Throwable $e) { - throw new FailedToSendActionLink($e->getMessage(), $e->getCode(), $e); + throw new FailedToSendActionLink(message: $e->getMessage(), previous: $e); } $idToken = $signInResult->idToken(); @@ -330,37 +324,37 @@ public function sendEmailActionLink(string $type, Stringable|string $email, $act $this->client->sendEmailActionLink($type, $email, $actionCodeSettings, $locale, $idToken); } - public function getEmailVerificationLink(Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): string + public function getEmailVerificationLink(string $email, $actionCodeSettings = null, ?string $locale = null): string { return $this->getEmailActionLink('VERIFY_EMAIL', $email, $actionCodeSettings, $locale); } - public function sendEmailVerificationLink(Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): void + public function sendEmailVerificationLink(string $email, $actionCodeSettings = null, ?string $locale = null): void { $this->sendEmailActionLink('VERIFY_EMAIL', $email, $actionCodeSettings, $locale); } - public function getPasswordResetLink(Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): string + public function getPasswordResetLink(string $email, $actionCodeSettings = null, ?string $locale = null): string { return $this->getEmailActionLink('PASSWORD_RESET', $email, $actionCodeSettings, $locale); } - public function sendPasswordResetLink(Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): void + public function sendPasswordResetLink(string $email, $actionCodeSettings = null, ?string $locale = null): void { $this->sendEmailActionLink('PASSWORD_RESET', $email, $actionCodeSettings, $locale); } - public function getSignInWithEmailLink(Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): string + public function getSignInWithEmailLink(string $email, $actionCodeSettings = null, ?string $locale = null): string { return $this->getEmailActionLink('EMAIL_SIGNIN', $email, $actionCodeSettings, $locale); } - public function sendSignInWithEmailLink(Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): void + public function sendSignInWithEmailLink(string $email, $actionCodeSettings = null, ?string $locale = null): void { $this->sendEmailActionLink('EMAIL_SIGNIN', $email, $actionCodeSettings, $locale); } - public function setCustomUserClaims(Stringable|string $uid, ?array $claims): void + public function setCustomUserClaims(string $uid, ?array $claims): void { $uid = Uid::fromString($uid)->value; $claims ??= []; @@ -368,7 +362,7 @@ public function setCustomUserClaims(Stringable|string $uid, ?array $claims): voi $this->client->setCustomUserClaims($uid, $claims); } - public function createCustomToken(Stringable|string $uid, array $claims = [], $ttl = 3600): UnencryptedToken + public function createCustomToken(string $uid, array $claims = [], int|DateInterval|string $ttl = 3600): UnencryptedToken { if ($this->tokenGenerator === null) { throw new AuthError('Custom Token Generation is disabled because the current credentials do not permit it'); @@ -401,7 +395,7 @@ public function parseToken(string $tokenString): UnencryptedToken return $parsedToken; } - public function verifyIdToken($idToken, bool $checkIfRevoked = false, ?int $leewayInSeconds = null): UnencryptedToken + public function verifyIdToken(Token|string $idToken, bool $checkIfRevoked = false, ?int $leewayInSeconds = null): UnencryptedToken { $verifier = $this->idTokenVerifier; @@ -487,7 +481,7 @@ public function verifyPasswordResetCode(string $oobCode): string return $responseData['email']; } - public function confirmPasswordReset(string $oobCode, $newPassword, bool $invalidatePreviousSessions = true): string + public function confirmPasswordReset(string $oobCode, string $newPassword, bool $invalidatePreviousSessions = true): string { $newPassword = ClearTextPassword::fromString($newPassword)->value; @@ -507,33 +501,28 @@ public function confirmPasswordReset(string $oobCode, $newPassword, bool $invali return $email; } - public function revokeRefreshTokens(Stringable|string $uid): void + public function revokeRefreshTokens(string $uid): void { $uid = Uid::fromString($uid)->value; $this->client->revokeRefreshTokens($uid); } - public function unlinkProvider($uid, $provider): UserRecord + public function unlinkProvider(string $uid, array|string $provider): UserRecord { $uid = Uid::fromString($uid)->value; - $provider = array_values( - array_filter( - array_map('strval', (array) $provider), - static fn(string $value): bool => $value !== '', - ), - ); + $provider = array_map(strval(...), (array) $provider); $response = $this->client->unlinkProvider($uid, $provider); return $this->getUserRecordFromResponseAfterUserUpdate($response); } - public function signInAsUser($user, ?array $claims = null): SignInResult + public function signInAsUser(UserRecord|string $user, ?array $claims = null): SignInResult { $claims ??= []; - $uid = $user instanceof UserRecord ? $user->uid : (string) $user; + $uid = $user instanceof UserRecord ? $user->uid : $user; try { $customToken = $this->createCustomToken($uid, $claims); @@ -544,7 +533,7 @@ public function signInAsUser($user, ?array $claims = null): SignInResult return $this->client->handleSignIn(SignInWithCustomToken::fromValue($customToken->toString())); } - public function signInWithCustomToken($token): SignInResult + public function signInWithCustomToken(Token|string $token): SignInResult { $token = $token instanceof Token ? $token->toString() : $token; @@ -558,17 +547,17 @@ public function signInWithRefreshToken(string $refreshToken): SignInResult return $this->client->handleSignIn(SignInWithRefreshToken::fromValue($refreshToken)); } - public function signInWithEmailAndPassword($email, $clearTextPassword): SignInResult + public function signInWithEmailAndPassword(string $email, string $clearTextPassword): SignInResult { - $email = Email::fromString((string) $email)->value; + $email = Email::fromString($email)->value; $clearTextPassword = ClearTextPassword::fromString($clearTextPassword)->value; return $this->client->handleSignIn(SignInWithEmailAndPassword::fromValues($email, $clearTextPassword)); } - public function signInWithEmailAndOobCode($email, string $oobCode): SignInResult + public function signInWithEmailAndOobCode(string $email, string $oobCode): SignInResult { - $email = Email::fromString((string) $email)->value; + $email = Email::fromString($email)->value; return $this->client->handleSignIn(SignInWithEmailAndOobCode::fromValues($email, $oobCode)); } @@ -589,41 +578,33 @@ public function signInAnonymously(): SignInResult throw new FailedToSignIn('Failed to sign in anonymously: No ID token or UID available'); } - public function signInWithIdpAccessToken($provider, string $accessToken, $redirectUrl = null, ?string $oauthTokenSecret = null, ?string $linkingIdToken = null, ?string $rawNonce = null): SignInResult + public function signInWithIdpAccessToken(string $provider, Token|string $accessToken, ?string $redirectUrl = null, ?string $oauthTokenSecret = null, ?string $linkingIdToken = null, ?string $rawNonce = null): SignInResult { - $provider = (string) $provider; - $redirectUrl = trim((string) ($redirectUrl ?? 'http://localhost')); - $linkingIdToken = trim((string) $linkingIdToken); - $oauthTokenSecret = trim((string) $oauthTokenSecret); - $rawNonce = trim((string) $rawNonce); + $accessToken = $accessToken instanceof Token ? $accessToken->toString() : $accessToken; + $redirectUrl = trim($redirectUrl ?? 'http://localhost'); - if ($oauthTokenSecret !== '') { + if ($oauthTokenSecret !== null) { $action = SignInWithIdpCredentials::withAccessTokenAndOauthTokenSecret($provider, $accessToken, $oauthTokenSecret); } else { $action = SignInWithIdpCredentials::withAccessToken($provider, $accessToken); } - if ($linkingIdToken !== '') { + if ($linkingIdToken !== null) { $action = $action->withLinkingIdToken($linkingIdToken); } - if ($rawNonce !== '') { + if ($rawNonce !== null) { $action = $action->withRawNonce($rawNonce); } - if ($redirectUrl !== '') { - $action = $action->withRequestUri($redirectUrl); - } + $action = $action->withRequestUri($redirectUrl); return $this->client->handleSignIn($action); } - public function signInWithIdpIdToken($provider, $idToken, $redirectUrl = null, ?string $linkingIdToken = null, ?string $rawNonce = null): SignInResult + public function signInWithIdpIdToken(string $provider, Token|string $idToken, ?string $redirectUrl = null, ?string $linkingIdToken = null, ?string $rawNonce = null): SignInResult { - $provider = trim((string) $provider); - $redirectUrl = trim((string) ($redirectUrl ?? 'http://localhost')); - $linkingIdToken = trim((string) $linkingIdToken); - $rawNonce = trim((string) $rawNonce); + $redirectUrl = trim(($redirectUrl ?? 'http://localhost')); if ($idToken instanceof Token) { $idToken = $idToken->toString(); @@ -631,22 +612,20 @@ public function signInWithIdpIdToken($provider, $idToken, $redirectUrl = null, ? $action = SignInWithIdpCredentials::withIdToken($provider, $idToken); - if ($rawNonce !== '') { + if ($rawNonce !== null) { $action = $action->withRawNonce($rawNonce); } - if ($linkingIdToken !== '') { + if ($linkingIdToken !== null) { $action = $action->withLinkingIdToken($linkingIdToken); } - if ($redirectUrl !== '') { - $action = $action->withRequestUri($redirectUrl); - } + $action = $action->withRequestUri($redirectUrl); return $this->client->handleSignIn($action); } - public function createSessionCookie($idToken, $ttl): string + public function createSessionCookie(Token|string $idToken, DateInterval|int $ttl): string { if ($idToken instanceof Token) { $idToken = $idToken->toString(); diff --git a/src/Firebase/Auth/ActionCodeSettings/ValidatedActionCodeSettings.php b/src/Firebase/Auth/ActionCodeSettings/ValidatedActionCodeSettings.php index 224ade9e2..59063dba0 100644 --- a/src/Firebase/Auth/ActionCodeSettings/ValidatedActionCodeSettings.php +++ b/src/Firebase/Auth/ActionCodeSettings/ValidatedActionCodeSettings.php @@ -21,8 +21,6 @@ final class ValidatedActionCodeSettings implements ActionCodeSettings private ?bool $canHandleCodeInApp = null; - private ?UriInterface $dynamicLinkDomain = null; - /** * @var non-empty-string|null */ @@ -62,9 +60,7 @@ public static function fromArray(array $settings): self switch (mb_strtolower($key)) { case 'continueurl': case 'url': - $instance->continueUrl = ($value !== null) - ? Utils::uriFor(self::ensureNonEmptyString($value)) - : null; + $instance->continueUrl = Utils::uriFor(self::ensureNonEmptyString($value)); break; @@ -73,13 +69,6 @@ public static function fromArray(array $settings): self break; - case 'dynamiclinkdomain': - $instance->dynamicLinkDomain = ($value !== null) - ? Utils::uriFor(self::ensureNonEmptyString($value)) - : null; - - break; - case 'androidpackagename': $instance->androidPackageName = self::ensureNonEmptyString($value); @@ -114,12 +103,10 @@ public static function fromArray(array $settings): self public function toArray(): array { $continueUrl = $this->continueUrl !== null ? (string) $this->continueUrl : null; - $dynamicLinkDomain = $this->dynamicLinkDomain !== null ? (string) $this->dynamicLinkDomain : null; return array_filter([ 'continueUrl' => $continueUrl, 'canHandleCodeInApp' => $this->canHandleCodeInApp, - 'dynamicLinkDomain' => $dynamicLinkDomain, 'androidPackageName' => $this->androidPackageName, 'androidMinimumVersion' => $this->androidMinimumVersion, 'androidInstallApp' => $this->androidInstallApp, diff --git a/src/Firebase/Auth/ApiClient.php b/src/Firebase/Auth/ApiClient.php index 30b2898e4..ac1dd50fc 100644 --- a/src/Firebase/Auth/ApiClient.php +++ b/src/Firebase/Auth/ApiClient.php @@ -20,7 +20,6 @@ use Kreait\Firebase\Request\UpdateUser; use Psr\Clock\ClockInterface; use Psr\Http\Message\ResponseInterface; -use Stringable; use Throwable; use function array_filter; @@ -239,14 +238,14 @@ public function revokeRefreshTokens(string $uid): ResponseInterface } /** - * @param list $providers + * @param list $providers * * @throws AuthException */ public function unlinkProvider(string $uid, array $providers): ResponseInterface { $url = $this->awareAuthResourceUrlBuilder->getUrl('/accounts:update'); - $providers = array_map('strval', $providers); + $providers = array_map(strval(...), $providers); return $this->requestApi($url, [ 'localId' => $uid, diff --git a/src/Firebase/Auth/AuthResourceUrlBuilder.php b/src/Firebase/Auth/AuthResourceUrlBuilder.php index 3c612ac53..9003f4fe4 100644 --- a/src/Firebase/Auth/AuthResourceUrlBuilder.php +++ b/src/Firebase/Auth/AuthResourceUrlBuilder.php @@ -14,21 +14,21 @@ /** * @internal */ -final class AuthResourceUrlBuilder +final readonly class AuthResourceUrlBuilder { - private const URL_FORMAT = 'https://identitytoolkit.googleapis.com/{version}{api}'; + private const string URL_FORMAT = 'https://identitytoolkit.googleapis.com/{version}{api}'; - private const EMULATOR_URL_FORMAT = 'http://{host}/identitytoolkit.googleapis.com/{version}{api}'; + private const string EMULATOR_URL_FORMAT = 'http://{host}/identitytoolkit.googleapis.com/{version}{api}'; - private const DEFAULT_API_VERSION = 'v1'; + private const string DEFAULT_API_VERSION = 'v1'; /** * @param non-empty-string $apiVersion * @param non-empty-string $urlFormat */ private function __construct( - private readonly string $apiVersion, - private readonly string $urlFormat, + private string $apiVersion, + private string $urlFormat, ) { } diff --git a/src/Firebase/Auth/CreateActionLink.php b/src/Firebase/Auth/CreateActionLink.php index 4c215fd3e..3d5e41331 100644 --- a/src/Firebase/Auth/CreateActionLink.php +++ b/src/Firebase/Auth/CreateActionLink.php @@ -5,25 +5,24 @@ namespace Kreait\Firebase\Auth; use Kreait\Firebase\Value\Email; -use Stringable; /** * @internal */ -final class CreateActionLink +final readonly class CreateActionLink { private function __construct( - private readonly ?string $tenantId, - private readonly ?string $locale, - private readonly string $type, - private readonly string $email, - private readonly ActionCodeSettings $settings, + private ?string $tenantId, + private ?string $locale, + private string $type, + private string $email, + private ActionCodeSettings $settings, ) { } - public static function new(string $type, Stringable|string $email, ActionCodeSettings $settings, ?string $tenantId = null, ?string $locale = null): self + public static function new(string $type, string $email, ActionCodeSettings $settings, ?string $tenantId = null, ?string $locale = null): self { - $email = Email::fromString((string) $email)->value; + $email = Email::fromString($email)->value; return new self($tenantId, $locale, $type, $email, $settings); } diff --git a/src/Firebase/Auth/CreateActionLink/GuzzleApiClientHandler.php b/src/Firebase/Auth/CreateActionLink/GuzzleApiClientHandler.php index 399474aa1..7125b3ceb 100644 --- a/src/Firebase/Auth/CreateActionLink/GuzzleApiClientHandler.php +++ b/src/Firebase/Auth/CreateActionLink/GuzzleApiClientHandler.php @@ -13,7 +13,6 @@ use Kreait\Firebase\Auth\ProjectAwareAuthResourceUrlBuilder; use Kreait\Firebase\Auth\TenantAwareAuthResourceUrlBuilder; use Psr\Http\Client\ClientExceptionInterface; -use Psr\Http\Message\RequestInterface; use function array_filter; @@ -22,14 +21,14 @@ /** * @internal */ -final class GuzzleApiClientHandler +final readonly class GuzzleApiClientHandler { /** * @param non-empty-string $projectId */ public function __construct( - private readonly ClientInterface $client, - private readonly string $projectId, + private ClientInterface $client, + private string $projectId, ) { } @@ -40,7 +39,10 @@ public function handle(CreateActionLink $action): string try { $response = $this->client->send($request, ['http_errors' => false]); } catch (ClientExceptionInterface $e) { - throw new FailedToCreateActionLink('Failed to create action link: '.$e->getMessage(), $e->getCode(), $e); + throw new FailedToCreateActionLink( + message: 'Failed to create action link: '.$e->getMessage(), + previous: $e + ); } if ($response->getStatusCode() !== 200) { @@ -50,7 +52,10 @@ public function handle(CreateActionLink $action): string try { $data = Json::decode((string) $response->getBody(), true); } catch (InvalidArgumentException $e) { - throw new FailedToCreateActionLink('Unable to parse the response data: '.$e->getMessage(), $e->getCode(), $e); + throw new FailedToCreateActionLink( + message: 'Unable to parse the response data: '.$e->getMessage(), + previous: $e + ); } $actionCode = $data['oobLink'] ?? null; @@ -62,7 +67,7 @@ public function handle(CreateActionLink $action): string return (string) $actionCode; } - private function createRequest(CreateActionLink $action): RequestInterface + private function createRequest(CreateActionLink $action): Request { $data = [ 'requestType' => $action->type(), diff --git a/src/Firebase/Auth/CreateSessionCookie.php b/src/Firebase/Auth/CreateSessionCookie.php index d23b01589..1322743af 100644 --- a/src/Firebase/Auth/CreateSessionCookie.php +++ b/src/Firebase/Auth/CreateSessionCookie.php @@ -16,17 +16,17 @@ /** * @internal */ -final class CreateSessionCookie +final readonly class CreateSessionCookie { - private const FIVE_MINUTES = 'PT5M'; + private const string FIVE_MINUTES = 'PT5M'; - private const TWO_WEEKS = 'P14D'; + private const string TWO_WEEKS = 'P14D'; private function __construct( - private readonly string $idToken, - private readonly ?string $tenantId, - private readonly DateInterval $ttl, - private readonly ClockInterface $clock, + private string $idToken, + private ?string $tenantId, + private DateInterval $ttl, + private ClockInterface $clock, ) { } diff --git a/src/Firebase/Auth/CreateSessionCookie/GuzzleApiClientHandler.php b/src/Firebase/Auth/CreateSessionCookie/GuzzleApiClientHandler.php index ef7bb85ce..5c41c2741 100644 --- a/src/Firebase/Auth/CreateSessionCookie/GuzzleApiClientHandler.php +++ b/src/Firebase/Auth/CreateSessionCookie/GuzzleApiClientHandler.php @@ -13,7 +13,6 @@ use Kreait\Firebase\Auth\ProjectAwareAuthResourceUrlBuilder; use Kreait\Firebase\Auth\TenantAwareAuthResourceUrlBuilder; use Psr\Http\Client\ClientExceptionInterface; -use Psr\Http\Message\RequestInterface; use function array_filter; @@ -22,14 +21,14 @@ /** * @internal */ -final class GuzzleApiClientHandler +final readonly class GuzzleApiClientHandler { /** * @param non-empty-string $projectId */ public function __construct( - private readonly ClientInterface $client, - private readonly string $projectId, + private ClientInterface $client, + private string $projectId, ) { } @@ -63,7 +62,7 @@ public function handle(CreateSessionCookie $action): string throw new FailedToCreateSessionCookie($action, $response, 'The response did not contain a session cookie'); } - private function createRequest(CreateSessionCookie $action): RequestInterface + private function createRequest(CreateSessionCookie $action): Request { $data = [ 'idToken' => $action->idToken(), diff --git a/src/Firebase/Auth/CustomTokenViaGoogleCredentials.php b/src/Firebase/Auth/CustomTokenViaGoogleCredentials.php index 23d23f7ac..c0cd94378 100644 --- a/src/Firebase/Auth/CustomTokenViaGoogleCredentials.php +++ b/src/Firebase/Auth/CustomTokenViaGoogleCredentials.php @@ -13,31 +13,32 @@ use Lcobucci\JWT\Encoding\JoseEncoder; use Lcobucci\JWT\Token; use Lcobucci\JWT\Token\Parser; -use Stringable; /** * @internal */ -final class CustomTokenViaGoogleCredentials +final readonly class CustomTokenViaGoogleCredentials { - private readonly JoseEncoder $encoder; + private JoseEncoder $encoder; - private readonly Parser $parser; + private Parser $parser; - public function __construct(private readonly SignBlobInterface $signer, private readonly ?string $tenantId = null) + public function __construct(private SignBlobInterface $signer, private ?string $tenantId = null) { $this->encoder = new JoseEncoder(); $this->parser = new Parser($this->encoder); } /** - * @param Stringable|string $uid + * @param non-empty-string $uid * @param array $claims * * @throws AuthError */ - public function createCustomToken($uid, array $claims = [], ?DateTimeInterface $expiresAt = null): Token + public function createCustomToken(string $uid, ?array $claims = null, ?DateTimeInterface $expiresAt = null): Token { + $claims ??= []; + $now = new DateTimeImmutable(); $expiresAt = ($expiresAt !== null) ? DT::toUTCDateTimeImmutable($expiresAt) @@ -50,7 +51,7 @@ public function createCustomToken($uid, array $claims = [], ?DateTimeInterface $ 'aud' => 'https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit', 'iat' => $now->getTimestamp(), 'exp' => $expiresAt->getTimestamp(), - 'uid' => (string) $uid, + 'uid' => $uid, ]; if ($this->tenantId !== null) { diff --git a/src/Firebase/Auth/DeleteUsersRequest.php b/src/Firebase/Auth/DeleteUsersRequest.php index 1a29db2d3..c8cd7fa8f 100644 --- a/src/Firebase/Auth/DeleteUsersRequest.php +++ b/src/Firebase/Auth/DeleteUsersRequest.php @@ -6,24 +6,23 @@ use Kreait\Firebase\Exception\InvalidArgumentException; use Kreait\Firebase\Value\Uid; -use Stringable; /** * @internal */ -final class DeleteUsersRequest +final readonly class DeleteUsersRequest { - private const MAX_BATCH_SIZE = 1000; + private const int MAX_BATCH_SIZE = 1000; private function __construct( /** @var list $uids */ - private readonly array $uids, - private readonly bool $enabledUsersShouldBeForceDeleted, + private array $uids, + private bool $enabledUsersShouldBeForceDeleted, ) { } /** - * @param iterable $uids + * @param iterable $uids */ public static function withUids(iterable $uids, bool $forceDeleteEnabledUsers = false): self { diff --git a/src/Firebase/Auth/DeleteUsersResult.php b/src/Firebase/Auth/DeleteUsersResult.php index 6a7ebc5bf..902fbf6d9 100644 --- a/src/Firebase/Auth/DeleteUsersResult.php +++ b/src/Firebase/Auth/DeleteUsersResult.php @@ -10,7 +10,7 @@ use function count; use function is_countable; -final class DeleteUsersResult +final readonly class DeleteUsersResult { /** * @param list $rawErrors */ private function __construct( - private readonly int $successCount, - private readonly int $failureCount, - private readonly array $rawErrors, + private int $successCount, + private int $failureCount, + private array $rawErrors, ) { } diff --git a/src/Firebase/Auth/MfaInfo.php b/src/Firebase/Auth/MfaInfo.php index b7acb0e98..1ffcfc61e 100644 --- a/src/Firebase/Auth/MfaInfo.php +++ b/src/Firebase/Auth/MfaInfo.php @@ -17,13 +17,13 @@ * enrolledAt?: non-empty-string * } */ -final class MfaInfo +final readonly class MfaInfo { private function __construct( - public readonly string $mfaEnrollmentId, - public readonly ?string $displayName, - public readonly ?string $phoneInfo, - public readonly ?DateTimeImmutable $enrolledAt, + public string $mfaEnrollmentId, + public ?string $displayName, + public ?string $phoneInfo, + public ?DateTimeImmutable $enrolledAt, ) { } diff --git a/src/Firebase/Auth/ProjectAwareAuthResourceUrlBuilder.php b/src/Firebase/Auth/ProjectAwareAuthResourceUrlBuilder.php index d7a7320cf..eb2b6d116 100644 --- a/src/Firebase/Auth/ProjectAwareAuthResourceUrlBuilder.php +++ b/src/Firebase/Auth/ProjectAwareAuthResourceUrlBuilder.php @@ -13,13 +13,13 @@ /** * @internal */ -final class ProjectAwareAuthResourceUrlBuilder +final readonly class ProjectAwareAuthResourceUrlBuilder { - private const URL_FORMAT = 'https://identitytoolkit.googleapis.com/{version}/projects/{projectId}{api}'; + private const string URL_FORMAT = 'https://identitytoolkit.googleapis.com/{version}/projects/{projectId}{api}'; - private const EMULATOR_URL_FORMAT = 'http://{host}/identitytoolkit.googleapis.com/{version}/projects/{projectId}{api}'; + private const string EMULATOR_URL_FORMAT = 'http://{host}/identitytoolkit.googleapis.com/{version}/projects/{projectId}{api}'; - private const DEFAULT_API_VERSION = 'v1'; + private const string DEFAULT_API_VERSION = 'v1'; /** * @param non-empty-string $projectId @@ -27,9 +27,9 @@ final class ProjectAwareAuthResourceUrlBuilder * @param non-empty-string $urlFormat */ private function __construct( - private readonly string $projectId, - private readonly string $apiVersion, - private readonly string $urlFormat, + private string $projectId, + private string $apiVersion, + private string $urlFormat, ) { } diff --git a/src/Firebase/Auth/SendActionLink/GuzzleApiClientHandler.php b/src/Firebase/Auth/SendActionLink/GuzzleApiClientHandler.php index bf6e1591e..05c70253e 100644 --- a/src/Firebase/Auth/SendActionLink/GuzzleApiClientHandler.php +++ b/src/Firebase/Auth/SendActionLink/GuzzleApiClientHandler.php @@ -12,7 +12,6 @@ use Kreait\Firebase\Auth\SendActionLink; use Kreait\Firebase\Auth\TenantAwareAuthResourceUrlBuilder; use Psr\Http\Client\ClientExceptionInterface; -use Psr\Http\Message\RequestInterface; use function array_filter; @@ -21,14 +20,14 @@ /** * @internal */ -final class GuzzleApiClientHandler +final readonly class GuzzleApiClientHandler { /** * @param non-empty-string $projectId */ public function __construct( - private readonly ClientInterface $client, - private readonly string $projectId, + private ClientInterface $client, + private string $projectId, ) { } @@ -39,7 +38,10 @@ public function handle(SendActionLink $action): void try { $response = $this->client->send($request, ['http_errors' => false]); } catch (ClientExceptionInterface $e) { - throw new FailedToSendActionLink('Failed to send action link: '.$e->getMessage(), $e->getCode(), $e); + throw new FailedToSendActionLink( + message: 'Failed to send action link: '.$e->getMessage(), + previous: $e + ); } if ($response->getStatusCode() !== 200) { @@ -47,7 +49,7 @@ public function handle(SendActionLink $action): void } } - private function createRequest(SendActionLink $action): RequestInterface + private function createRequest(SendActionLink $action): Request { $data = [ 'requestType' => $action->type(), diff --git a/src/Firebase/Auth/SignIn/FailedToSignIn.php b/src/Firebase/Auth/SignIn/FailedToSignIn.php index b3d1d339e..f59e142fa 100644 --- a/src/Firebase/Auth/SignIn/FailedToSignIn.php +++ b/src/Firebase/Auth/SignIn/FailedToSignIn.php @@ -37,7 +37,10 @@ public static function withActionAndResponse(SignIn $action, ResponseInterface $ public static function fromPrevious(Throwable $e): self { - return new self('Sign in failed: '.$e->getMessage(), $e->getCode(), $e); + return new self( + message: 'Sign in failed: '.$e->getMessage(), + previous: $e + ); } public function action(): ?SignIn diff --git a/src/Firebase/Auth/SignIn/GuzzleHandler.php b/src/Firebase/Auth/SignIn/GuzzleHandler.php index 5619b78f4..35e25e94d 100644 --- a/src/Firebase/Auth/SignIn/GuzzleHandler.php +++ b/src/Firebase/Auth/SignIn/GuzzleHandler.php @@ -21,7 +21,6 @@ use Kreait\Firebase\Auth\SignInWithRefreshToken; use Kreait\Firebase\Util; use Psr\Http\Client\ClientExceptionInterface; -use Psr\Http\Message\RequestInterface; use UnexpectedValueException; use function http_build_query; @@ -77,7 +76,7 @@ public function handle(SignIn $action): SignInResult return SignInResult::fromData($data); } - private function createApiRequest(SignIn $action): RequestInterface + private function createApiRequest(SignIn $action): Request { return match (true) { $action instanceof SignInAnonymously => $this->anonymous($action), diff --git a/src/Firebase/Auth/TenantAwareAuthResourceUrlBuilder.php b/src/Firebase/Auth/TenantAwareAuthResourceUrlBuilder.php index ae40f8720..5787ba75f 100644 --- a/src/Firebase/Auth/TenantAwareAuthResourceUrlBuilder.php +++ b/src/Firebase/Auth/TenantAwareAuthResourceUrlBuilder.php @@ -13,13 +13,13 @@ /** * @internal */ -final class TenantAwareAuthResourceUrlBuilder +final readonly class TenantAwareAuthResourceUrlBuilder { - private const URL_FORMAT = 'https://identitytoolkit.googleapis.com/{version}/projects/{projectId}/tenants/{tenantId}{api}'; + private const string URL_FORMAT = 'https://identitytoolkit.googleapis.com/{version}/projects/{projectId}/tenants/{tenantId}{api}'; - private const EMULATOR_URL_FORMAT = 'http://{host}/identitytoolkit.googleapis.com/{version}/projects/{projectId}/tenants/{tenantId}{api}'; + private const string EMULATOR_URL_FORMAT = 'http://{host}/identitytoolkit.googleapis.com/{version}/projects/{projectId}/tenants/{tenantId}{api}'; - private const DEFAULT_API_VERSION = 'v1'; + private const string DEFAULT_API_VERSION = 'v1'; /** * @param non-empty-string $projectId @@ -28,10 +28,10 @@ final class TenantAwareAuthResourceUrlBuilder * @param non-empty-string $urlFormat */ private function __construct( - private readonly string $projectId, - private readonly string $tenantId, - private readonly string $apiVersion, - private readonly string $urlFormat, + private string $projectId, + private string $tenantId, + private string $apiVersion, + private string $urlFormat, ) { } diff --git a/src/Firebase/Auth/UserInfo.php b/src/Firebase/Auth/UserInfo.php index 4fcc23d8a..ac048406f 100644 --- a/src/Firebase/Auth/UserInfo.php +++ b/src/Firebase/Auth/UserInfo.php @@ -27,7 +27,7 @@ * phoneNumber?: non-empty-string * } */ -final class UserInfo +final readonly class UserInfo { /** * @param non-empty-string $uid @@ -38,12 +38,12 @@ final class UserInfo * @param non-empty-string|null $photoUrl */ public function __construct( - public readonly string $uid, - public readonly string $providerId, - public readonly ?string $displayName, - public readonly ?string $email, - public readonly ?string $phoneNumber, - public readonly ?string $photoUrl, + public string $uid, + public string $providerId, + public ?string $displayName, + public ?string $email, + public ?string $phoneNumber, + public ?string $photoUrl, ) { } diff --git a/src/Firebase/Auth/UserMetaData.php b/src/Firebase/Auth/UserMetaData.php index 1cb803870..088f1e122 100644 --- a/src/Firebase/Auth/UserMetaData.php +++ b/src/Firebase/Auth/UserMetaData.php @@ -17,13 +17,13 @@ * lastRefreshAt?: non-empty-string * } */ -final class UserMetaData +final readonly class UserMetaData { public function __construct( - public readonly DateTimeImmutable $createdAt, - public readonly ?DateTimeImmutable $lastLoginAt, - public readonly ?DateTimeImmutable $passwordUpdatedAt, - public readonly ?DateTimeImmutable $lastRefreshAt, + public DateTimeImmutable $createdAt, + public ?DateTimeImmutable $lastLoginAt, + public ?DateTimeImmutable $passwordUpdatedAt, + public ?DateTimeImmutable $lastRefreshAt, ) { } diff --git a/src/Firebase/Auth/UserQuery.php b/src/Firebase/Auth/UserQuery.php index b05fedc8e..74c804b43 100644 --- a/src/Firebase/Auth/UserQuery.php +++ b/src/Firebase/Auth/UserQuery.php @@ -21,27 +21,27 @@ */ class UserQuery implements JsonSerializable { - final public const FIELD_CREATED_AT = 'CREATED_AT'; + final public const string FIELD_CREATED_AT = 'CREATED_AT'; - final public const FIELD_LAST_LOGIN_AT = 'LAST_LOGIN_AT'; + final public const string FIELD_LAST_LOGIN_AT = 'LAST_LOGIN_AT'; - final public const FIELD_NAME = 'NAME'; + final public const string FIELD_NAME = 'NAME'; - final public const FIELD_USER_EMAIL = 'USER_EMAIL'; + final public const string FIELD_USER_EMAIL = 'USER_EMAIL'; - final public const FIELD_USER_ID = 'USER_ID'; + final public const string FIELD_USER_ID = 'USER_ID'; - final public const FILTER_EMAIL = 'email'; + final public const string FILTER_EMAIL = 'email'; - final public const FILTER_PHONE_NUMBER = 'phoneNumber'; + final public const string FILTER_PHONE_NUMBER = 'phoneNumber'; - final public const FILTER_USER_ID = 'userId'; + final public const string FILTER_USER_ID = 'userId'; - final public const ORDER_ASC = 'ASC'; + final public const string ORDER_ASC = 'ASC'; - final public const ORDER_DESC = 'DESC'; + final public const string ORDER_DESC = 'DESC'; - final public const MAX_LIMIT = 500; + final public const int MAX_LIMIT = 500; /** * @var positive-int|null diff --git a/src/Firebase/Auth/UserRecord.php b/src/Firebase/Auth/UserRecord.php index 025138700..009789bc5 100644 --- a/src/Firebase/Auth/UserRecord.php +++ b/src/Firebase/Auth/UserRecord.php @@ -37,7 +37,7 @@ * validSince?: non-empty-string * } */ -final class UserRecord +final readonly class UserRecord { /** * @param non-empty-string $uid @@ -52,21 +52,21 @@ final class UserRecord * @param non-empty-string|null $tenantId */ public function __construct( - public readonly string $uid, - public readonly ?string $email, - public readonly bool $emailVerified, - public readonly ?string $displayName, - public readonly ?string $phoneNumber, - public readonly ?string $photoUrl, - public readonly bool $disabled, - public readonly UserMetaData $metadata, - public readonly array $providerData, - public readonly ?MfaInfo $mfaInfo, - public readonly ?string $passwordHash, - public readonly ?string $passwordSalt, - public readonly array $customClaims, - public readonly ?string $tenantId, - public readonly ?DateTimeImmutable $tokensValidAfterTime, + public string $uid, + public ?string $email, + public bool $emailVerified, + public ?string $displayName, + public ?string $phoneNumber, + public ?string $photoUrl, + public bool $disabled, + public UserMetaData $metadata, + public array $providerData, + public ?MfaInfo $mfaInfo, + public ?string $passwordHash, + public ?string $passwordSalt, + public array $customClaims, + public ?string $tenantId, + public ?DateTimeImmutable $tokensValidAfterTime, ) { } @@ -144,7 +144,7 @@ private static function mfaInfoFromResponseData(array $data): ?MfaInfo private static function userInfoFromResponseData(array $data): array { return array_map( - static fn(array $userInfoData): UserInfo => UserInfo::fromResponseData($userInfoData), + UserInfo::fromResponseData(...), $data['providerUserInfo'], ); } diff --git a/src/Firebase/Contract/Auth.php b/src/Firebase/Contract/Auth.php index da8558194..8feffbda5 100644 --- a/src/Firebase/Contract/Auth.php +++ b/src/Firebase/Contract/Auth.php @@ -29,8 +29,6 @@ use Kreait\Firebase\Request\UpdateUser; use Lcobucci\JWT\Token; use Lcobucci\JWT\UnencryptedToken; -use Psr\Http\Message\UriInterface; -use Stringable; use Traversable; /** @@ -39,16 +37,16 @@ interface Auth { /** - * @param Stringable|non-empty-string $uid + * @param non-empty-string $uid * * @throws UserNotFound * @throws Exception\AuthException * @throws Exception\FirebaseException */ - public function getUser(Stringable|string $uid): UserRecord; + public function getUser(string $uid): UserRecord; /** - * @param non-empty-list $uids + * @param non-empty-list $uids * * @throws Exception\AuthException * @throws Exception\FirebaseException @@ -91,38 +89,39 @@ public function createUser(array|CreateUser $properties): UserRecord; /** * Updates the given user with the given properties. * + * @param non-empty-string $uid * @param non-empty-array|UpdateUser $properties * * @throws Exception\AuthException * @throws Exception\FirebaseException */ - public function updateUser(Stringable|string $uid, array|UpdateUser $properties): UserRecord; + public function updateUser(string $uid, array|UpdateUser $properties): UserRecord; /** - * @param Stringable|non-empty-string $email - * @param Stringable|non-empty-string $password + * @param non-empty-string $email + * @param non-empty-string $password * * @throws Exception\AuthException * @throws Exception\FirebaseException */ - public function createUserWithEmailAndPassword(Stringable|string $email, Stringable|string $password): UserRecord; + public function createUserWithEmailAndPassword(string $email, string $password): UserRecord; /** - * @param Stringable|non-empty-string $email + * @param non-empty-string $email * * @throws UserNotFound * @throws Exception\AuthException * @throws Exception\FirebaseException */ - public function getUserByEmail(Stringable|string $email): UserRecord; + public function getUserByEmail(string $email): UserRecord; /** - * @param Stringable|non-empty-string $phoneNumber + * @param non-empty-string $phoneNumber * * @throws Exception\AuthException * @throws Exception\FirebaseException */ - public function getUserByPhoneNumber(Stringable|string $phoneNumber): UserRecord; + public function getUserByPhoneNumber(string $phoneNumber): UserRecord; /** * @throws Exception\AuthException @@ -131,50 +130,50 @@ public function getUserByPhoneNumber(Stringable|string $phoneNumber): UserRecord public function createAnonymousUser(): UserRecord; /** - * @param Stringable|non-empty-string $uid - * @param Stringable|non-empty-string $newPassword + * @param non-empty-string $uid + * @param non-empty-string $newPassword * * @throws Exception\AuthException * @throws Exception\FirebaseException */ - public function changeUserPassword(Stringable|string $uid, Stringable|string $newPassword): UserRecord; + public function changeUserPassword(string $uid, string $newPassword): UserRecord; /** - * @param Stringable|non-empty-string $uid - * @param Stringable|non-empty-string $newEmail + * @param non-empty-string $uid + * @param non-empty-string $newEmail * * @throws Exception\AuthException * @throws Exception\FirebaseException */ - public function changeUserEmail(Stringable|string $uid, Stringable|string $newEmail): UserRecord; + public function changeUserEmail(string $uid, string $newEmail): UserRecord; /** - * @param Stringable|non-empty-string $uid + * @param non-empty-string $uid * * @throws Exception\AuthException * @throws Exception\FirebaseException */ - public function enableUser(Stringable|string $uid): UserRecord; + public function enableUser(string $uid): UserRecord; /** - * @param Stringable|non-empty-string $uid + * @param non-empty-string $uid * * @throws Exception\AuthException * @throws Exception\FirebaseException */ - public function disableUser(Stringable|string $uid): UserRecord; + public function disableUser(string $uid): UserRecord; /** - * @param Stringable|non-empty-string $uid + * @param non-empty-string $uid * * @throws UserNotFound * @throws Exception\AuthException * @throws Exception\FirebaseException */ - public function deleteUser(Stringable|string $uid): void; + public function deleteUser(string $uid): void; /** - * @param iterable $uids + * @param iterable $uids * @param bool $forceDeleteEnabledUsers Whether to force deleting accounts that are not in disabled state. If false, only disabled accounts will be deleted, and accounts that are not disabled will be added to the errors. * * @throws Exception\AuthException @@ -183,91 +182,91 @@ public function deleteUsers(iterable $uids, bool $forceDeleteEnabledUsers = fals /** * @param non-empty-string $type - * @param Stringable|non-empty-string $email + * @param non-empty-string $email * @param ActionCodeSettings|array|null $actionCodeSettings * @param non-empty-string|null $locale * * @throws FailedToCreateActionLink */ - public function getEmailActionLink(string $type, Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): string; + public function getEmailActionLink(string $type, string $email, $actionCodeSettings = null, ?string $locale = null): string; /** * @param non-empty-string $type - * @param Stringable|non-empty-string $email + * @param non-empty-string $email * @param ActionCodeSettings|array|null $actionCodeSettings * @param non-empty-string|null $locale * * @throws UserNotFound * @throws FailedToSendActionLink */ - public function sendEmailActionLink(string $type, Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): void; + public function sendEmailActionLink(string $type, string $email, $actionCodeSettings = null, ?string $locale = null): void; /** - * @param Stringable|non-empty-string $email + * @param non-empty-string $email * @param ActionCodeSettings|array|null $actionCodeSettings * @param non-empty-string|null $locale * * @throws FailedToCreateActionLink */ - public function getEmailVerificationLink(Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): string; + public function getEmailVerificationLink(string $email, $actionCodeSettings = null, ?string $locale = null): string; /** - * @param Stringable|non-empty-string $email + * @param non-empty-string $email * @param ActionCodeSettings|array|null $actionCodeSettings * @param non-empty-string|null $locale * * @throws FailedToSendActionLink */ - public function sendEmailVerificationLink(Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): void; + public function sendEmailVerificationLink(string $email, $actionCodeSettings = null, ?string $locale = null): void; /** - * @param Stringable|non-empty-string $email + * @param non-empty-string $email * @param ActionCodeSettings|array|null $actionCodeSettings * @param non-empty-string|null $locale * * @throws FailedToCreateActionLink */ - public function getPasswordResetLink(Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): string; + public function getPasswordResetLink(string $email, $actionCodeSettings = null, ?string $locale = null): string; /** - * @param Stringable|non-empty-string $email + * @param non-empty-string $email * @param ActionCodeSettings|array|null $actionCodeSettings * @param non-empty-string|null $locale * * @throws FailedToSendActionLink */ - public function sendPasswordResetLink(Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): void; + public function sendPasswordResetLink(string $email, $actionCodeSettings = null, ?string $locale = null): void; /** - * @param Stringable|non-empty-string $email + * @param non-empty-string $email * @param ActionCodeSettings|array|null $actionCodeSettings * @param non-empty-string|null $locale * * @throws FailedToCreateActionLink */ - public function getSignInWithEmailLink(Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): string; + public function getSignInWithEmailLink(string $email, $actionCodeSettings = null, ?string $locale = null): string; /** - * @param Stringable|non-empty-string $email + * @param non-empty-string $email * @param ActionCodeSettings|array|null $actionCodeSettings * @param non-empty-string|null $locale * * @throws FailedToSendActionLink */ - public function sendSignInWithEmailLink(Stringable|string $email, $actionCodeSettings = null, ?string $locale = null): void; + public function sendSignInWithEmailLink(string $email, $actionCodeSettings = null, ?string $locale = null): void; /** * Sets additional developer claims on an existing user identified by the provided UID. * * @see https://firebase.google.com/docs/auth/admin/custom-claims * - * @param Stringable|non-empty-string $uid + * @param non-empty-string $uid * @param array|null $claims * * @throws Exception\AuthException * @throws Exception\FirebaseException */ - public function setCustomUserClaims(Stringable|string $uid, ?array $claims): void; + public function setCustomUserClaims(string $uid, ?array $claims): void; /** * @param array $claims @@ -276,7 +275,7 @@ public function setCustomUserClaims(Stringable|string $uid, ?array $claims): voi * @throws Exception\AuthException * @throws Exception\FirebaseException */ - public function createCustomToken(Stringable|string $uid, array $claims = [], int|DateInterval|string $ttl = 3600): UnencryptedToken; + public function createCustomToken(string $uid, array $claims = [], int|DateInterval|string $ttl = 3600): UnencryptedToken; /** * @param non-empty-string $tokenString @@ -359,7 +358,7 @@ public function verifyPasswordResetCode(string $oobCode): string; * @see https://firebase.google.com/docs/reference/rest/auth#section-confirm-reset-password * * @param non-empty-string $oobCode the email action code sent to the user's email for resetting the password - * @param Stringable|non-empty-string $newPassword + * @param non-empty-string $newPassword * @param bool $invalidatePreviousSessions Invalidate sessions initialized with the previous credentials * * @throws ExpiredOobCode @@ -369,7 +368,7 @@ public function verifyPasswordResetCode(string $oobCode): string; * @throws Exception\AuthException * @throws Exception\FirebaseException */ - public function confirmPasswordReset(string $oobCode, Stringable|string $newPassword, bool $invalidatePreviousSessions = true): string; + public function confirmPasswordReset(string $oobCode, string $newPassword, bool $invalidatePreviousSessions = true): string; /** * Revokes all refresh tokens for the specified user identified by the uid provided. @@ -377,29 +376,29 @@ public function confirmPasswordReset(string $oobCode, Stringable|string $newPass * before revocation will also be revoked on the Auth backend. Any request with an * ID token generated before revocation will be rejected with a token expired error. * - * @param Stringable|string $uid the user whose tokens are to be revoked + * @param string $uid the user whose tokens are to be revoked * * @throws Exception\AuthException * @throws Exception\FirebaseException */ - public function revokeRefreshTokens(Stringable|string $uid): void; + public function revokeRefreshTokens(string $uid): void; /** - * @param Stringable|non-empty-string $uid - * @param list|Stringable|non-empty-string $provider + * @param non-empty-string $uid + * @param list|non-empty-string $provider * * @throws Exception\AuthException * @throws Exception\FirebaseException */ - public function unlinkProvider(Stringable|string $uid, array|Stringable|string $provider): UserRecord; + public function unlinkProvider(string $uid, array|string $provider): UserRecord; /** - * @param UserRecord|Stringable|non-empty-string $user + * @param UserRecord|non-empty-string $user * @param array|null $claims * * @throws FailedToSignIn */ - public function signInAsUser(UserRecord|Stringable|string $user, ?array $claims = null): SignInResult; + public function signInAsUser(UserRecord|string $user, ?array $claims = null): SignInResult; /** * @param Token|non-empty-string $token @@ -416,20 +415,20 @@ public function signInWithCustomToken(Token|string $token): SignInResult; public function signInWithRefreshToken(string $refreshToken): SignInResult; /** - * @param Stringable|non-empty-string $email - * @param Stringable|non-empty-string $clearTextPassword + * @param non-empty-string $email + * @param non-empty-string $clearTextPassword * * @throws FailedToSignIn */ - public function signInWithEmailAndPassword(Stringable|string $email, Stringable|string $clearTextPassword): SignInResult; + public function signInWithEmailAndPassword(string $email, string $clearTextPassword): SignInResult; /** - * @param Stringable|non-empty-string $email + * @param non-empty-string $email * @param non-empty-string $oobCode * * @throws FailedToSignIn */ - public function signInWithEmailAndOobCode(Stringable|string $email, string $oobCode): SignInResult; + public function signInWithEmailAndOobCode(string $email, string $oobCode): SignInResult; /** * @throws FailedToSignIn @@ -439,25 +438,25 @@ public function signInAnonymously(): SignInResult; /** * @see https://cloud.google.com/identity-platform/docs/reference/rest/v1/accounts/signInWithIdp * - * @param Stringable|non-empty-string $provider - * @param non-empty-string $accessToken - * @param UriInterface|non-empty-string|null $redirectUrl + * @param non-empty-string $provider + * @param Token|non-empty-string $accessToken + * @param non-empty-string|null $redirectUrl * @param non-empty-string|null $oauthTokenSecret * @param non-empty-string|null $linkingIdToken * @param non-empty-string|null $rawNonce * * @throws FailedToSignIn */ - public function signInWithIdpAccessToken(Stringable|string $provider, string $accessToken, $redirectUrl = null, ?string $oauthTokenSecret = null, ?string $linkingIdToken = null, ?string $rawNonce = null): SignInResult; + public function signInWithIdpAccessToken(string $provider, Token|string $accessToken, ?string $redirectUrl = null, ?string $oauthTokenSecret = null, ?string $linkingIdToken = null, ?string $rawNonce = null): SignInResult; /** - * @param Stringable|non-empty-string $provider + * @param non-empty-string $provider * @param Token|non-empty-string $idToken - * @param UriInterface|non-empty-string|null $redirectUrl + * @param non-empty-string|null $redirectUrl * @param non-empty-string|null $linkingIdToken * @param non-empty-string|null $rawNonce * * @throws FailedToSignIn */ - public function signInWithIdpIdToken(Stringable|string $provider, Token|string $idToken, $redirectUrl = null, ?string $linkingIdToken = null, ?string $rawNonce = null): SignInResult; + public function signInWithIdpIdToken(string $provider, Token|string $idToken, ?string $redirectUrl = null, ?string $linkingIdToken = null, ?string $rawNonce = null): SignInResult; } diff --git a/src/Firebase/Contract/DynamicLinks.php b/src/Firebase/Contract/DynamicLinks.php deleted file mode 100644 index 028f74a29..000000000 --- a/src/Firebase/Contract/DynamicLinks.php +++ /dev/null @@ -1,68 +0,0 @@ - + * @return Traversable */ public function listVersions($query = null): Traversable; } diff --git a/src/Firebase/Contract/Transitional/FederatedUserFetcher.php b/src/Firebase/Contract/Transitional/FederatedUserFetcher.php index 505802ae0..165e88355 100644 --- a/src/Firebase/Contract/Transitional/FederatedUserFetcher.php +++ b/src/Firebase/Contract/Transitional/FederatedUserFetcher.php @@ -7,7 +7,6 @@ use Kreait\Firebase\Auth\UserRecord; use Kreait\Firebase\Exception; use Kreait\Firebase\Exception\Auth\UserNotFound; -use Stringable; /** * @TODO: This interface is intended to be integrated into the Auth interface on the next major release. @@ -15,12 +14,12 @@ interface FederatedUserFetcher { /** - * @param Stringable|non-empty-string $providerId - * @param Stringable|non-empty-string $providerUid + * @param non-empty-string $providerId + * @param non-empty-string $providerUid * * @throws UserNotFound * @throws Exception\AuthException * @throws Exception\FirebaseException */ - public function getUserByProviderUid(Stringable|string $providerId, Stringable|string $providerUid): UserRecord; + public function getUserByProviderUid(string $providerId, string $providerUid): UserRecord; } diff --git a/src/Firebase/Database.php b/src/Firebase/Database.php index cc332129e..cc4fd36c4 100644 --- a/src/Firebase/Database.php +++ b/src/Firebase/Database.php @@ -19,11 +19,11 @@ /** * @internal */ -final class Database implements Contract\Database +final readonly class Database implements Contract\Database { public function __construct( - private readonly UriInterface $uri, - private readonly ApiClient $client, + private UriInterface $uri, + private ApiClient $client, ) { } @@ -38,7 +38,7 @@ public function getReference(?string $path = null): Reference try { return new Reference($this->uri->withPath($path), $this->client); } catch (\InvalidArgumentException $e) { - throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e); + throw new InvalidArgumentException(message: $e->getMessage(), previous: $e); } } diff --git a/src/Firebase/Database/Query.php b/src/Firebase/Database/Query.php index cc26e66df..66a52bbe4 100644 --- a/src/Firebase/Database/Query.php +++ b/src/Firebase/Database/Query.php @@ -84,7 +84,11 @@ public function getSnapshot(): Snapshot } catch (DatabaseNotFound $e) { throw $e; } catch (DatabaseException $e) { - throw new UnsupportedQuery($this, $e->getMessage(), $e->getCode(), $e->getPrevious()); + throw new UnsupportedQuery( + query: $this, + message: $e->getMessage(), + previous: $e->getPrevious() + ); } if ($this->sorter !== null) { diff --git a/src/Firebase/Database/Query/Filter/EndAt.php b/src/Firebase/Database/Query/Filter/EndAt.php index 6a1c5cbad..2e4b4e640 100644 --- a/src/Firebase/Database/Query/Filter/EndAt.php +++ b/src/Firebase/Database/Query/Filter/EndAt.php @@ -12,11 +12,11 @@ /** * @internal */ -final class EndAt implements Filter +final readonly class EndAt implements Filter { use ModifierTrait; - public function __construct(private readonly bool|float|int|string $value) + public function __construct(private bool|float|int|string $value) { } diff --git a/src/Firebase/Database/Query/Filter/EndBefore.php b/src/Firebase/Database/Query/Filter/EndBefore.php index 9d5968e29..e57874adb 100644 --- a/src/Firebase/Database/Query/Filter/EndBefore.php +++ b/src/Firebase/Database/Query/Filter/EndBefore.php @@ -12,11 +12,11 @@ /** * @internal */ -final class EndBefore implements Filter +final readonly class EndBefore implements Filter { use ModifierTrait; - public function __construct(private readonly int|float|string|bool $value) + public function __construct(private int|float|string|bool $value) { } diff --git a/src/Firebase/Database/Query/Filter/EqualTo.php b/src/Firebase/Database/Query/Filter/EqualTo.php index c82d0ea3b..02e56d5e5 100644 --- a/src/Firebase/Database/Query/Filter/EqualTo.php +++ b/src/Firebase/Database/Query/Filter/EqualTo.php @@ -12,11 +12,11 @@ /** * @internal */ -final class EqualTo implements Filter +final readonly class EqualTo implements Filter { use ModifierTrait; - public function __construct(private readonly bool|float|int|string $value) + public function __construct(private bool|float|int|string $value) { } diff --git a/src/Firebase/Database/Query/Filter/LimitToFirst.php b/src/Firebase/Database/Query/Filter/LimitToFirst.php index 6c16fa8c0..5a926ff8d 100644 --- a/src/Firebase/Database/Query/Filter/LimitToFirst.php +++ b/src/Firebase/Database/Query/Filter/LimitToFirst.php @@ -12,11 +12,11 @@ /** * @internal */ -final class LimitToFirst implements Filter +final readonly class LimitToFirst implements Filter { use ModifierTrait; - private readonly int $limit; + private int $limit; public function __construct(int $limit) { diff --git a/src/Firebase/Database/Query/Filter/LimitToLast.php b/src/Firebase/Database/Query/Filter/LimitToLast.php index b78f597f9..5231554ba 100644 --- a/src/Firebase/Database/Query/Filter/LimitToLast.php +++ b/src/Firebase/Database/Query/Filter/LimitToLast.php @@ -12,11 +12,11 @@ /** * @internal */ -final class LimitToLast implements Filter +final readonly class LimitToLast implements Filter { use ModifierTrait; - private readonly int $limit; + private int $limit; public function __construct(int $limit) { diff --git a/src/Firebase/Database/Query/Filter/StartAfter.php b/src/Firebase/Database/Query/Filter/StartAfter.php index 1feed9b66..4a10bf28d 100644 --- a/src/Firebase/Database/Query/Filter/StartAfter.php +++ b/src/Firebase/Database/Query/Filter/StartAfter.php @@ -12,11 +12,11 @@ /** * @internal */ -final class StartAfter implements Filter +final readonly class StartAfter implements Filter { use ModifierTrait; - public function __construct(private readonly int|float|string|bool $value) + public function __construct(private int|float|string|bool $value) { } diff --git a/src/Firebase/Database/Query/Filter/StartAt.php b/src/Firebase/Database/Query/Filter/StartAt.php index f887de2c8..371a77a8d 100644 --- a/src/Firebase/Database/Query/Filter/StartAt.php +++ b/src/Firebase/Database/Query/Filter/StartAt.php @@ -12,11 +12,11 @@ /** * @internal */ -final class StartAt implements Filter +final readonly class StartAt implements Filter { use ModifierTrait; - public function __construct(private readonly int|float|string|bool $value) + public function __construct(private int|float|string|bool $value) { } diff --git a/src/Firebase/Database/Query/Sorter/OrderByChild.php b/src/Firebase/Database/Query/Sorter/OrderByChild.php index 19f6d5f26..19374559c 100644 --- a/src/Firebase/Database/Query/Sorter/OrderByChild.php +++ b/src/Firebase/Database/Query/Sorter/OrderByChild.php @@ -17,11 +17,11 @@ /** * @internal */ -final class OrderByChild implements Sorter +final readonly class OrderByChild implements Sorter { use ModifierTrait; - public function __construct(private readonly string $childKey) + public function __construct(private string $childKey) { } diff --git a/src/Firebase/Database/Reference.php b/src/Firebase/Database/Reference.php index ff9fbcb22..28ae6615e 100644 --- a/src/Firebase/Database/Reference.php +++ b/src/Firebase/Database/Reference.php @@ -106,7 +106,7 @@ public function getChild(string $path): self try { return new self($this->uri->withPath($childPath), $this->apiClient); } catch (\InvalidArgumentException $e) { - throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e); + throw new InvalidArgumentException(message: $e->getMessage(), previous: $e); } } @@ -233,7 +233,7 @@ public function getChildKeys(): array $snapshot = $this->shallow()->getSnapshot(); if (is_array($value = $snapshot->getValue())) { - return array_map('strval', array_keys($value)); + return array_map(strval(...), array_keys($value)); } throw new OutOfRangeException(sprintf('%s has no children with keys', $this)); diff --git a/src/Firebase/Database/Transaction.php b/src/Firebase/Database/Transaction.php index 634b5a9cc..cb47c193e 100644 --- a/src/Firebase/Database/Transaction.php +++ b/src/Firebase/Database/Transaction.php @@ -15,14 +15,13 @@ class Transaction /** * @var array */ - private array $etags; + private array $etags = []; /** * @internal */ public function __construct(private readonly ApiClient $apiClient) { - $this->etags = []; } /** diff --git a/src/Firebase/Database/UrlBuilder.php b/src/Firebase/Database/UrlBuilder.php index 436806cc7..4bebf1b66 100644 --- a/src/Firebase/Database/UrlBuilder.php +++ b/src/Firebase/Database/UrlBuilder.php @@ -17,9 +17,9 @@ /** * @internal */ -final class UrlBuilder +final readonly class UrlBuilder { - private const EXPECTED_URL_FORMAT = '@^https://(?P[^.]+)\.(?P.+)$@'; + private const string EXPECTED_URL_FORMAT = '@^https://(?P[^.]+)\.(?P.+)$@'; /** * @param 'http'|'https' $scheme @@ -27,9 +27,9 @@ final class UrlBuilder * @param array $defaultQueryParams */ private function __construct( - private readonly string $scheme, - private readonly string $host, - private readonly array $defaultQueryParams, + private string $scheme, + private string $host, + private array $defaultQueryParams, ) { } diff --git a/src/Firebase/DynamicLink.php b/src/Firebase/DynamicLink.php deleted file mode 100644 index 807e05491..000000000 --- a/src/Firebase/DynamicLink.php +++ /dev/null @@ -1,103 +0,0 @@ - - * } - */ -final class DynamicLink implements JsonSerializable, Stringable -{ - /** - * @param DynamicLinkShape $data - */ - private function __construct(private readonly array $data) - { - } - - public function __toString(): string - { - return (string) $this->uri(); - } - - /** - * @internal - */ - public static function fromApiResponse(ResponseInterface $response): self - { - /** @var DynamicLinkShape $decoded */ - $decoded = Json::decode((string) $response->getBody(), true); - - return new self($decoded); - } - - public function uri(): UriInterface - { - return Utils::uriFor($this->data['shortLink']); - } - - public function previewUri(): ?UriInterface - { - $previewLink = $this->data['previewLink'] ?? null; - - return $previewLink !== null ? Utils::uriFor($previewLink) : null; - } - - /** - * @return non-empty-string - */ - public function domain(): string - { - $uri = $this->uri(); - - return $uri->getScheme().'://'.$uri->getHost(); - } - - public function suffix(): string - { - return trim($this->uri()->getPath(), '/'); - } - - /** - * @return list - */ - public function warnings(): array - { - return $this->data['warning'] ?? []; - } - - public function hasWarnings(): bool - { - return $this->warnings() !== []; - } - - public function jsonSerialize(): array - { - return $this->data; - } -} diff --git a/src/Firebase/DynamicLink/AnalyticsInfo.php b/src/Firebase/DynamicLink/AnalyticsInfo.php deleted file mode 100644 index da200b683..000000000 --- a/src/Firebase/DynamicLink/AnalyticsInfo.php +++ /dev/null @@ -1,81 +0,0 @@ -iTunesConnectAnalytics); - } - - /** - * @param ITunesConnectAnalytics|ITunesConnectAnalyticsShape $data - */ - public function withItunesConnectAnalytics($data): self - { - $icInfo = $data instanceof ITunesConnectAnalytics ? $data : ITunesConnectAnalytics::fromArray($data); - - return new self($this->googlePlayAnalytics, $icInfo); - } - - /** - * @return AnalyticsInfoShape - */ - public function jsonSerialize(): array - { - return array_filter([ - 'googlePlayAnalytics' => $this->googlePlayAnalytics?->jsonSerialize(), - 'itunesConnectAnalytics' => $this->iTunesConnectAnalytics?->jsonSerialize(), - ], fn(?array $value): bool => $value !== null); - } -} diff --git a/src/Firebase/DynamicLink/AnalyticsInfo/GooglePlayAnalytics.php b/src/Firebase/DynamicLink/AnalyticsInfo/GooglePlayAnalytics.php deleted file mode 100644 index 411517a67..000000000 --- a/src/Firebase/DynamicLink/AnalyticsInfo/GooglePlayAnalytics.php +++ /dev/null @@ -1,139 +0,0 @@ -data; - $data['utmSource'] = $utmSource; - - return new self($data); - } - - /** - * The advertising or marketing medium, for example: cpc, banner, email newsletter. - * - * @see https://support.google.com/analytics/answer/1033863#parameters - * - * @param non-empty-string $utmMedium - */ - public function withUtmMedium(string $utmMedium): self - { - $data = $this->data; - $data['utmMedium'] = $utmMedium; - - return new self($data); - } - - /** - * The individual campaign name, slogan, promo code, etc. for a product. - * - * @see https://support.google.com/analytics/answer/1033863#parameters - * - * @param non-empty-string $utmCampaign - */ - public function withUtmCampaign(string $utmCampaign): self - { - $data = $this->data; - $data['utmCampaign'] = $utmCampaign; - - return new self($data); - } - - /** - * Identifies paid search keywords. If you're manually tagging paid keyword campaigns, you should also use - * utm_term to specify the keyword. - * - * @see https://support.google.com/analytics/answer/1033863#parameters - * - * @param non-empty-string $utmTerm - */ - public function withUtmTerm(string $utmTerm): self - { - $data = $this->data; - $data['utmTerm'] = $utmTerm; - - return new self($data); - } - - /** - * Used to differentiate similar content, or links within the same ad. For example, if you have two call-to-action - * links within the same email message, you can use utm_content and set different values for each, so you can tell - * which version is more effective. - * - * @see https://support.google.com/analytics/answer/1033863#parameters - * - * @param non-empty-string $utmContent - */ - public function withUtmContent(string $utmContent): self - { - $data = $this->data; - $data['utmContent'] = $utmContent; - - return new self($data); - } - - /** - * The Google Click ID. - * - * @see https://support.google.com/analytics/answer/2938246?hl=en - * - * @param non-empty-string $gclid - */ - public function withGclid(string $gclid): self - { - $data = $this->data; - $data['gclid'] = $gclid; - - return new self($data); - } - - public function jsonSerialize(): array - { - return $this->data; - } -} diff --git a/src/Firebase/DynamicLink/AnalyticsInfo/ITunesConnectAnalytics.php b/src/Firebase/DynamicLink/AnalyticsInfo/ITunesConnectAnalytics.php deleted file mode 100644 index 26e421840..000000000 --- a/src/Firebase/DynamicLink/AnalyticsInfo/ITunesConnectAnalytics.php +++ /dev/null @@ -1,106 +0,0 @@ -data; - $data['at'] = $affiliateToken; - - return new self($data); - } - - /** - * The iTunes connect/affiliate partner token. - * - * @see https://blog.geni.us/parameter-cheat-sheet-for-itunes-and-app-store-links/ - * - * @param non-empty-string $campaignToken - */ - public function withCampaignToken(string $campaignToken): self - { - $data = $this->data; - $data['ct'] = $campaignToken; - - return new self($data); - } - - /** - * The media type. - * - * @see https://blog.geni.us/parameter-cheat-sheet-for-itunes-and-app-store-links/ - * - * @param non-empty-string $mediaType - */ - public function withMediaType(string $mediaType): self - { - $data = $this->data; - $data['mt'] = $mediaType; - - return new self($data); - } - - /** - * The provider token. - * - * @see https://www.macstories.net/tutorials/a-comprehensive-guide-to-the-itunes-affiliate-program/ - * - * @param non-empty-string $providerToken - */ - public function withProviderToken(string $providerToken): self - { - $data = $this->data; - $data['pt'] = $providerToken; - - return new self($data); - } - - public function jsonSerialize(): array - { - return $this->data; - } -} diff --git a/src/Firebase/DynamicLink/AndroidInfo.php b/src/Firebase/DynamicLink/AndroidInfo.php deleted file mode 100644 index a7c1efb51..000000000 --- a/src/Firebase/DynamicLink/AndroidInfo.php +++ /dev/null @@ -1,87 +0,0 @@ -data; - $data['androidPackageName'] = $packageName; - - return new self($data); - } - - /** - * The link to open when the app isn't installed. Specify this to do something other than install your app - * from the Play Store when the app isn't installed, such as open the mobile web version of the content, - * or display a promotional page for your app. - * - * @param non-empty-string $fallbackLink - */ - public function withFallbackLink(string $fallbackLink): self - { - $data = $this->data; - $data['androidFallbackLink'] = $fallbackLink; - - return new self($data); - } - - /** - * The versionCode of the minimum version of your app that can open the link. If the installed app is an older - * version, the user is taken to the Play Store to upgrade the app. - * - * @see https://developer.android.com/studio/publish/versioning#appversioning - * - * @param non-empty-string $minPackageVersionCode - */ - public function withMinPackageVersionCode(string $minPackageVersionCode): self - { - $data = $this->data; - $data['androidMinPackageVersionCode'] = $minPackageVersionCode; - - return new self($data); - } - - public function jsonSerialize(): array - { - return $this->data; - } -} diff --git a/src/Firebase/DynamicLink/ApiClient.php b/src/Firebase/DynamicLink/ApiClient.php deleted file mode 100644 index 0c7a1c749..000000000 --- a/src/Firebase/DynamicLink/ApiClient.php +++ /dev/null @@ -1,70 +0,0 @@ -requestFactory - ->createRequest('POST', 'https://firebasedynamiclinks.googleapis.com/v1/shortLinks') - ->withBody($this->streamFactory->createStream(Json::encode($action, JSON_FORCE_OBJECT))) - ->withHeader('Content-Type', 'application/json; charset=UTF-8') - ; - } - - public function createStatisticsRequest(GetStatisticsForDynamicLink $action): RequestInterface - { - $url = sprintf( - 'https://firebasedynamiclinks.googleapis.com/v1/%s/linkStats?durationDays=%d', - rawurlencode($action->dynamicLink()), - $action->durationInDays(), - ); - - return $this->requestFactory - ->createRequest('GET', $url) - ->withHeader('Content-Type', 'application/json; charset=UTF-8') - ; - } - - public function createShortenLinkRequest(ShortenLongDynamicLink $action): RequestInterface - { - return $this->requestFactory - ->createRequest('POST', 'https://firebasedynamiclinks.googleapis.com/v1/shortLinks') - ->withBody($this->streamFactory->createStream(Json::encode($action, JSON_FORCE_OBJECT))) - ->withHeader('Content-Type', 'application/json; charset=UTF-8') - ; - } - - /** - * @param array $options - * - * @throws ClientExceptionInterface - */ - public function send(RequestInterface $request, array $options = []): ResponseInterface - { - return $this->client->send($request, $options); - } -} diff --git a/src/Firebase/DynamicLink/CreateDynamicLink.php b/src/Firebase/DynamicLink/CreateDynamicLink.php deleted file mode 100644 index e488ddabe..000000000 --- a/src/Firebase/DynamicLink/CreateDynamicLink.php +++ /dev/null @@ -1,177 +0,0 @@ - [], - 'suffix' => ['option' => self::WITH_UNGUESSABLE_SUFFIX], - ]); - } - - /** - * The link your app will open. Specify a URL that your app can handle, typically the app's content - * or payload, which initiates app-specific logic (such as crediting the user with a coupon or - * displaying a welcome screen). This link must be a well-formatted URL, be properly - * URL-encoded, use either HTTP or HTTPS, and cannot be another Dynamic Link. - */ - public static function forUrl(Stringable|string $url): self - { - return new self([ - 'dynamicLinkInfo' => [ - 'link' => Url::fromString($url)->value, - ], - 'suffix' => ['option' => self::WITH_UNGUESSABLE_SUFFIX], - ]); - } - - public function withDynamicLinkDomain(Stringable|string $dynamicLinkDomain): self - { - $data = $this->data; - $data['dynamicLinkInfo']['domainUriPrefix'] = Url::fromString($dynamicLinkDomain)->value; - - return new self($data); - } - - public function hasDynamicLinkDomain(): bool - { - return (bool) ($this->data['dynamicLinkInfo']['domainUriPrefix'] ?? null); - } - - /** - * @param AnalyticsInfo|AnalyticsInfoShape $data - */ - public function withAnalyticsInfo(AnalyticsInfo|array $data): self - { - $info = $data instanceof AnalyticsInfo ? $data : AnalyticsInfo::fromArray($data); - - $data = $this->data; - $data['dynamicLinkInfo']['analyticsInfo'] = Json::decode(Json::encode($info), true); - - return new self($data); - } - - /** - * @param AndroidInfo|AndroidInfoShape $data - */ - public function withAndroidInfo(AndroidInfo|array $data): self - { - $info = $data instanceof AndroidInfo ? $data : AndroidInfo::fromArray($data); - - $data = $this->data; - $data['dynamicLinkInfo']['androidInfo'] = Json::decode(Json::encode($info), true); - - return new self($data); - } - - /** - * @param IOSInfo|IOSInfoShape $data - */ - public function withIOSInfo(IOSInfo|array $data): self - { - $info = $data instanceof IOSInfo ? $data : IOSInfo::fromArray($data); - - $data = $this->data; - $data['dynamicLinkInfo']['iosInfo'] = Json::decode(Json::encode($info), true); - - return new self($data); - } - - /** - * @param NavigationInfo|NavigationInfoShape $data - */ - public function withNavigationInfo(NavigationInfo|array $data): self - { - $info = $data instanceof NavigationInfo ? $data : NavigationInfo::fromArray($data); - - $data = $this->data; - $data['dynamicLinkInfo']['navigationInfo'] = Json::decode(Json::encode($info), true); - - return new self($data); - } - - /** - * @param SocialMetaTagInfo|SocialMetaTagInfoShape $data - */ - public function withSocialMetaTagInfo(SocialMetaTagInfo|array $data): self - { - $info = $data instanceof SocialMetaTagInfo ? $data : SocialMetaTagInfo::fromArray($data); - - $data = $this->data; - $data['dynamicLinkInfo']['socialMetaTagInfo'] = Json::decode(Json::encode($info), true); - - return new self($data); - } - - public function withUnguessableSuffix(): self - { - $data = $this->data; - $data['suffix']['option'] = self::WITH_UNGUESSABLE_SUFFIX; - - return new self($data); - } - - public function withShortSuffix(): self - { - $data = $this->data; - $data['suffix']['option'] = self::WITH_SHORT_SUFFIX; - - return new self($data); - } - - public function jsonSerialize(): array - { - return $this->data; - } -} diff --git a/src/Firebase/DynamicLink/CreateDynamicLink/FailedToCreateDynamicLink.php b/src/Firebase/DynamicLink/CreateDynamicLink/FailedToCreateDynamicLink.php deleted file mode 100644 index 3de00e4ec..000000000 --- a/src/Firebase/DynamicLink/CreateDynamicLink/FailedToCreateDynamicLink.php +++ /dev/null @@ -1,45 +0,0 @@ -getBody(), true)['error']['message'] ?? $fallbackMessage; - } catch (UnexpectedValueException) { - $message = $fallbackMessage; - } - - $error = new self($message); - $error->action = $action; - $error->response = $response; - - return $error; - } - - public function action(): ?CreateDynamicLink - { - return $this->action; - } - - public function response(): ?ResponseInterface - { - return $this->response; - } -} diff --git a/src/Firebase/DynamicLink/DynamicLinkStatistics.php b/src/Firebase/DynamicLink/DynamicLinkStatistics.php deleted file mode 100644 index 6320dbce4..000000000 --- a/src/Firebase/DynamicLink/DynamicLinkStatistics.php +++ /dev/null @@ -1,50 +0,0 @@ ->> - */ - private array $rawData = []; - - private EventStatistics $events; - - private function __construct() - { - $this->events = EventStatistics::fromArray([]); - } - - /** - * @internal - */ - public static function fromApiResponse(ResponseInterface $response): self - { - $data = Json::decode((string) $response->getBody(), true); - - $link = new self(); - $link->rawData = $data; - $link->events = EventStatistics::fromArray($data['linkEventStats'] ?? []); - - return $link; - } - - public function eventStatistics(): EventStatistics - { - return $this->events; - } - - /** - * @return array>> - */ - public function rawData(): array - { - return $this->rawData; - } -} diff --git a/src/Firebase/DynamicLink/EventStatistics.php b/src/Firebase/DynamicLink/EventStatistics.php deleted file mode 100644 index 229c18fe3..000000000 --- a/src/Firebase/DynamicLink/EventStatistics.php +++ /dev/null @@ -1,133 +0,0 @@ - - */ -final class EventStatistics implements Countable, IteratorAggregate -{ - public const PLATFORM_ANDROID = 'ANDROID'; - - public const PLATFORM_DESKTOP = 'DESKTOP'; - - public const PLATFORM_IOS = 'IOS'; - - // Any click on a Dynamic Link, irrespective to how it is handled and its destinations - public const TYPE_CLICK = 'CLICK'; - - // Attempts to redirect users, either to the App Store or Play Store to install or update the app, - // or to some other destination - public const TYPE_REDIRECT = 'REDIRECT'; - - // Actual installs (only supported by the Play Store) - public const TYPE_APP_INSTALL = 'APP_INSTALL'; - - // First-opens after an install - public const TYPE_APP_FIRST_OPEN = 'APP_FIRST_OPEN'; - - // Re-opens of an app - public const TYPE_APP_RE_OPEN = 'APP_RE_OPEN'; - - /** - * @param list $events - */ - private function __construct(private readonly array $events) - { - } - - /** - * @param list $events - */ - public static function fromArray(array $events): self - { - return new self($events); - } - - public function onAndroid(): self - { - return $this->filterByPlatform(self::PLATFORM_ANDROID); - } - - public function onDesktop(): self - { - return $this->filterByPlatform(self::PLATFORM_DESKTOP); - } - - public function onIOS(): self - { - return $this->filterByPlatform(self::PLATFORM_IOS); - } - - public function clicks(): self - { - return $this->filterByType(self::TYPE_CLICK); - } - - public function redirects(): self - { - return $this->filterByType(self::TYPE_REDIRECT); - } - - public function appInstalls(): self - { - return $this->filterByType(self::TYPE_APP_INSTALL); - } - - public function appFirstOpens(): self - { - return $this->filterByType(self::TYPE_APP_FIRST_OPEN); - } - - public function appReOpens(): self - { - return $this->filterByType(self::TYPE_APP_RE_OPEN); - } - - public function filterByType(string $type): self - { - return $this->filter(static fn(array $event): bool => ($event['event'] ?? null) === $type); - } - - public function filterByPlatform(string $platform): self - { - return $this->filter(static fn(array $event): bool => ($event['platform'] ?? null) === $platform); - } - - public function filter(callable $filter): self - { - return new self(array_values(array_filter($this->events, $filter))); - } - - /** - * @return Traversable - */ - public function getIterator(): Traversable - { - yield from $this->events; - } - - public function count(): int - { - return array_sum(array_column($this->events, 'count')); - } -} diff --git a/src/Firebase/DynamicLink/GetStatisticsForDynamicLink.php b/src/Firebase/DynamicLink/GetStatisticsForDynamicLink.php deleted file mode 100644 index ce7e58e1a..000000000 --- a/src/Firebase/DynamicLink/GetStatisticsForDynamicLink.php +++ /dev/null @@ -1,42 +0,0 @@ -value); - } - - public function withDurationInDays(int $durationInDays): self - { - $action = clone $this; - $action->durationInDays = $durationInDays; - - return $action; - } - - public function dynamicLink(): string - { - return $this->dynamicLink; - } - - public function durationInDays(): int - { - return $this->durationInDays; - } -} diff --git a/src/Firebase/DynamicLink/GetStatisticsForDynamicLink/FailedToGetStatisticsForDynamicLink.php b/src/Firebase/DynamicLink/GetStatisticsForDynamicLink/FailedToGetStatisticsForDynamicLink.php deleted file mode 100644 index bd600fc05..000000000 --- a/src/Firebase/DynamicLink/GetStatisticsForDynamicLink/FailedToGetStatisticsForDynamicLink.php +++ /dev/null @@ -1,85 +0,0 @@ - $code, 'message' => $message] = self::getCodeAndMessageFromResponse($response); - - $error = new self($message, $code); - $error->action = $action; - $error->response = $response; - - return $error; - } - - public function action(): ?GetStatisticsForDynamicLink - { - return $this->action; - } - - public function response(): ?ResponseInterface - { - return $this->response; - } - - /** - * @return array{ - * code: int, - * message: string - * } - */ - private static function getCodeAndMessageFromResponse(ResponseInterface $response): array - { - $message = match ($code = $response->getStatusCode()) { - StatusCode::STATUS_FORBIDDEN => <<<'MSG' - Firebase reported missing permissions to access the statistics - for the requested Dynamic Link. Please make sure that the - Google Dynamic Links API is enabled for your project at - - https://console.cloud.google.com/apis/library/firebasedynamiclinks.googleapis.com - - If the API is enabled, you or the Service Account you're using - might be missing the required permissions. You can check by - visiting - - https://console.cloud.google.com/iam-admin/serviceaccounts/ - - and making sure that the Service Account has one of the following roles - - - Firebase Admin - - Firebase Dynamic Links Viewer - - Firebase Dynamic Links Admin - - MSG, - default => <<<'MSG' - Failed to get statistics for dynamic link. Please inspect the - response for further details. - - If the response type is not covered by the SDK, please create - a new issue in the SDK's GitHub repository and include the - HTTP Status code (`$response->getStatusCode()`) and the - message body (`$response->getBody()->getContents()`) - - MSG, - }; - - return [ - 'code' => $code, - 'message' => $message, - ]; - } -} diff --git a/src/Firebase/DynamicLink/IOSInfo.php b/src/Firebase/DynamicLink/IOSInfo.php deleted file mode 100644 index a96e0fb27..000000000 --- a/src/Firebase/DynamicLink/IOSInfo.php +++ /dev/null @@ -1,129 +0,0 @@ -data; - $data['iosBundleId'] = $bundleId; - - return new self($data); - } - - /** - * The link to open when the app isn't installed. Specify this to do something other than install your app from the - * App Store when the app isn't installed, such as open the mobile web version of the content, or display a - * promotional page for your app. - * - * @param non-empty-string $fallbackLink - */ - public function withFallbackLink(string $fallbackLink): self - { - $data = $this->data; - $data['iosFallbackLink'] = $fallbackLink; - - return new self($data); - } - - /** - * Your app's custom URL scheme, if defined to be something other than your app's bundle ID. - * - * @param non-empty-string $customScheme - */ - public function withCustomScheme(string $customScheme): self - { - $data = $this->data; - $data['iosCustomScheme'] = $customScheme; - - return new self($data); - } - - /** - * The link to open on iPads when the app isn't installed. Specify this to do something other than install your - * app from the App Store when the app isn't installed, such as open the web version of the content, or - * display a promotional page for your app. - * - * @param non-empty-string $ipadFallbackLink - */ - public function withIPadFallbackLink(string $ipadFallbackLink): self - { - $data = $this->data; - $data['iosIpadFallbackLink'] = $ipadFallbackLink; - - return new self($data); - } - - /** - * The bundle ID of the iOS app to use on iPads to open the link. The app must be connected to your project from - * the Overview page of the Firebase console. - * - * @param non-empty-string $iPadBundleId - */ - public function withIPadBundleId(string $iPadBundleId): self - { - $data = $this->data; - $data['iosIpadBundleId'] = $iPadBundleId; - - return new self($data); - } - - /** - * Your app's App Store ID, used to send users to the App Store when the app isn't installed. - * - * @param non-empty-string $appStoreId - */ - public function withAppStoreId(string $appStoreId): self - { - $data = $this->data; - $data['iosAppStoreId'] = $appStoreId; - - return new self($data); - } - - public function jsonSerialize(): array - { - return $this->data; - } -} diff --git a/src/Firebase/DynamicLink/NavigationInfo.php b/src/Firebase/DynamicLink/NavigationInfo.php deleted file mode 100644 index 69a09a049..000000000 --- a/src/Firebase/DynamicLink/NavigationInfo.php +++ /dev/null @@ -1,68 +0,0 @@ -data; - $data['enableForcedRedirect'] = true; - - return new self($data); - } - - /** - * @see withForcedRedirect() - */ - public function withoutForcedRedirect(): self - { - $data = $this->data; - unset($data['enableForcedRedirect']); - - return new self($data); - } - - public function jsonSerialize(): array - { - return $this->data; - } -} diff --git a/src/Firebase/DynamicLink/ShortenLongDynamicLink.php b/src/Firebase/DynamicLink/ShortenLongDynamicLink.php deleted file mode 100644 index e848302ec..000000000 --- a/src/Firebase/DynamicLink/ShortenLongDynamicLink.php +++ /dev/null @@ -1,71 +0,0 @@ - Url::fromString($url)->value, - 'suffix' => ['option' => self::WITH_UNGUESSABLE_SUFFIX], - ]); - } - - /** - * @param ShortenLongDynamicLinkShape $data - */ - public static function fromArray(array $data): self - { - return new self($data); - } - - public function withUnguessableSuffix(): self - { - $data = $this->data; - $data['suffix']['option'] = self::WITH_UNGUESSABLE_SUFFIX; - - return new self($data); - } - - public function withShortSuffix(): self - { - $data = $this->data; - $data['suffix']['option'] = self::WITH_SHORT_SUFFIX; - - return new self($data); - } - - public function jsonSerialize(): array - { - return $this->data; - } -} diff --git a/src/Firebase/DynamicLink/ShortenLongDynamicLink/FailedToShortenLongDynamicLink.php b/src/Firebase/DynamicLink/ShortenLongDynamicLink/FailedToShortenLongDynamicLink.php deleted file mode 100644 index be7a78764..000000000 --- a/src/Firebase/DynamicLink/ShortenLongDynamicLink/FailedToShortenLongDynamicLink.php +++ /dev/null @@ -1,45 +0,0 @@ -getBody(), true)['error']['message'] ?? $fallbackMessage; - } catch (UnexpectedValueException) { - $message = $fallbackMessage; - } - - $error = new self($message); - $error->action = $action; - $error->response = $response; - - return $error; - } - - public function action(): ?ShortenLongDynamicLink - { - return $this->action; - } - - public function response(): ?ResponseInterface - { - return $this->response; - } -} diff --git a/src/Firebase/DynamicLink/SocialMetaTagInfo.php b/src/Firebase/DynamicLink/SocialMetaTagInfo.php deleted file mode 100644 index 77967f97a..000000000 --- a/src/Firebase/DynamicLink/SocialMetaTagInfo.php +++ /dev/null @@ -1,81 +0,0 @@ -data; - $data['socialTitle'] = $title; - - return new self($data); - } - - /** - * The description to use when the Dynamic Link is shared in a social post. - * - * @param non-empty-string $description - */ - public function withDescription(string $description): self - { - $data = $this->data; - $data['socialDescription'] = $description; - - return new self($data); - } - - /** - * The URL to an image related to this link. - * - * @param non-empty-string $imageLink - */ - public function withImageLink(string $imageLink): self - { - $data = $this->data; - $data['socialImageLink'] = $imageLink; - - return new self($data); - } - - public function jsonSerialize(): array - { - return $this->data; - } -} diff --git a/src/Firebase/DynamicLinks.php b/src/Firebase/DynamicLinks.php deleted file mode 100644 index 9c4777df1..000000000 --- a/src/Firebase/DynamicLinks.php +++ /dev/null @@ -1,200 +0,0 @@ -value; - - return new self($domainUrl, $apiClient); - } - - public function createUnguessableLink($url): DynamicLink - { - return $this->createDynamicLink($url, CreateDynamicLink::WITH_UNGUESSABLE_SUFFIX); - } - - public function createShortLink($url): DynamicLink - { - return $this->createDynamicLink($url, CreateDynamicLink::WITH_SHORT_SUFFIX); - } - - public function createDynamicLink($actionOrParametersOrUrl, ?string $suffixType = null): DynamicLink - { - $action = $this->ensureCreateAction($actionOrParametersOrUrl); - - if ($this->defaultDynamicLinksDomain !== null && $action->hasDynamicLinkDomain() === false) { - $action = $action->withDynamicLinkDomain($this->defaultDynamicLinksDomain); - } - - if ($suffixType === CreateDynamicLink::WITH_SHORT_SUFFIX) { - $action = $action->withShortSuffix(); - } elseif ($suffixType === CreateDynamicLink::WITH_UNGUESSABLE_SUFFIX) { - $action = $action->withUnguessableSuffix(); - } - - $request = $this->apiClient->createDynamicLinkRequest($action); - - try { - $response = $this->apiClient->send($request, ['http_errors' => false]); - } catch (ClientExceptionInterface $e) { - throw new FailedToCreateDynamicLink('Failed to create dynamic link: '.$e->getMessage(), $e->getCode(), $e); - } - - if ($response->getStatusCode() === 200) { - return DynamicLink::fromApiResponse($response); - } - - throw FailedToCreateDynamicLink::withActionAndResponse($action, $response); - } - - public function shortenLongDynamicLink($longDynamicLinkOrAction, ?string $suffixType = null): DynamicLink - { - $action = $this->ensureShortenAction($longDynamicLinkOrAction); - - if ($suffixType === ShortenLongDynamicLink::WITH_SHORT_SUFFIX) { - $action = $action->withShortSuffix(); - } elseif ($suffixType === ShortenLongDynamicLink::WITH_UNGUESSABLE_SUFFIX) { - $action = $action->withUnguessableSuffix(); - } - - $request = $this->apiClient->createShortenLinkRequest($action); - - try { - $response = $this->apiClient->send($request, ['http_errors' => false]); - } catch (ClientExceptionInterface $e) { - throw new FailedToShortenLongDynamicLink('Failed to shorten long dynamic link: '.$e->getMessage(), $e->getCode(), $e); - } - - if ($response->getStatusCode() === 200) { - return DynamicLink::fromApiResponse($response); - } - - throw FailedToShortenLongDynamicLink::withActionAndResponse($action, $response); - } - - public function getStatistics(Stringable|string|GetStatisticsForDynamicLink $dynamicLinkOrAction, ?int $durationInDays = null): DynamicLinkStatistics - { - $action = $this->ensureGetStatisticsAction($dynamicLinkOrAction); - - if ($durationInDays !== null && $durationInDays < 1) { - throw new InvalidArgumentException('The duration in days must be a positive integer'); - } - - if ($durationInDays !== null) { - $action = $action->withDurationInDays($durationInDays); - } - - $request = $this->apiClient->createStatisticsRequest($action); - - try { - $response = $this->apiClient->send($request, ['http_errors' => false]); - } catch (ClientExceptionInterface $e) { - throw new FailedToGetStatisticsForDynamicLink('Failed to get statistics for Dynamic Link: '.$e->getMessage(), $e->getCode(), $e); - } - - if ($response->getStatusCode() === 200) { - return DynamicLinkStatistics::fromApiResponse($response); - } - - throw FailedToGetStatisticsForDynamicLink::withActionAndResponse($action, $response); - } - - /** - * @param Stringable|non-empty-string|CreateDynamicLink|CreateDynamicLinkShape $actionOrParametersOrUrl - */ - private function ensureCreateAction(Stringable|string|CreateDynamicLink|array $actionOrParametersOrUrl): CreateDynamicLink - { - if (is_array($actionOrParametersOrUrl)) { - return CreateDynamicLink::fromArray($actionOrParametersOrUrl); - } - - if ($actionOrParametersOrUrl instanceof CreateDynamicLink) { - return $actionOrParametersOrUrl; - } - - return CreateDynamicLink::forUrl((string) $actionOrParametersOrUrl); - } - - /** - * @param Stringable|non-empty-string|ShortenLongDynamicLink|ShortenLongDynamicLinkShape $actionOrParametersOrUrl - */ - private function ensureShortenAction(Stringable|string|ShortenLongDynamicLink|array $actionOrParametersOrUrl): ShortenLongDynamicLink - { - if (is_array($actionOrParametersOrUrl)) { - return ShortenLongDynamicLink::fromArray($actionOrParametersOrUrl); - } - - if ($actionOrParametersOrUrl instanceof ShortenLongDynamicLink) { - return $actionOrParametersOrUrl; - } - - return ShortenLongDynamicLink::forLongDynamicLink((string) $actionOrParametersOrUrl); - } - - /** - * @throw InvalidArgumentException - */ - private function ensureGetStatisticsAction(Stringable|string|GetStatisticsForDynamicLink $actionOrUrl): GetStatisticsForDynamicLink - { - if ($actionOrUrl instanceof GetStatisticsForDynamicLink) { - return $actionOrUrl; - } - - $actionOrUrl = trim((string) $actionOrUrl); - - if ($actionOrUrl === '') { - throw new InvalidArgumentException('A dynamic link must not be empty'); - } - - return GetStatisticsForDynamicLink::forLink($actionOrUrl); - } -} diff --git a/src/Firebase/Exception/AppCheckApiExceptionConverter.php b/src/Firebase/Exception/AppCheckApiExceptionConverter.php index 6fcf115cf..8861e1aa2 100644 --- a/src/Firebase/Exception/AppCheckApiExceptionConverter.php +++ b/src/Firebase/Exception/AppCheckApiExceptionConverter.php @@ -16,9 +16,9 @@ /** * @internal */ -final class AppCheckApiExceptionConverter +final readonly class AppCheckApiExceptionConverter { - public function __construct(private readonly ErrorResponseParser $responseParser) + public function __construct(private ErrorResponseParser $responseParser) { } @@ -29,10 +29,13 @@ public function convertException(Throwable $exception): AppCheckException } if ($exception instanceof NetworkExceptionInterface) { - return new ApiConnectionFailed('Unable to connect to the API: '.$exception->getMessage(), $exception->getCode(), $exception); + return new ApiConnectionFailed( + message: 'Unable to connect to the API: '.$exception->getMessage(), + previous: $exception + ); } - return new AppCheckError($exception->getMessage(), $exception->getCode(), $exception); + return new AppCheckError(message: $exception->getMessage(), previous: $exception); } private function convertGuzzleRequestException(RequestException $e): AppCheckException diff --git a/src/Firebase/Exception/AuthApiExceptionConverter.php b/src/Firebase/Exception/AuthApiExceptionConverter.php index 8d41a161b..cce5ca359 100644 --- a/src/Firebase/Exception/AuthApiExceptionConverter.php +++ b/src/Firebase/Exception/AuthApiExceptionConverter.php @@ -43,10 +43,13 @@ public function convertException(Throwable $exception): AuthException } if ($exception instanceof NetworkExceptionInterface) { - return new ApiConnectionFailed('Unable to connect to the API: '.$exception->getMessage(), $exception->getCode(), $exception); + return new ApiConnectionFailed( + message: 'Unable to connect to the API: '.$exception->getMessage(), + previous: $exception + ); } - return new AuthError($exception->getMessage(), $exception->getCode(), $exception); + return new AuthError(message: $exception->getMessage(), previous: $exception); } private function convertGuzzleRequestException(RequestException $e): AuthException diff --git a/src/Firebase/Exception/Database/TransactionFailed.php b/src/Firebase/Exception/Database/TransactionFailed.php index 6131ea47b..6ce5ccb48 100644 --- a/src/Firebase/Exception/Database/TransactionFailed.php +++ b/src/Firebase/Exception/Database/TransactionFailed.php @@ -15,7 +15,7 @@ final class TransactionFailed extends RuntimeException implements DatabaseExcept { private readonly Reference $reference; - public function __construct(Reference $query, string $message = '', int $code = 0, ?Throwable $previous = null) + public function __construct(Reference $query, string $message = '', ?Throwable $previous = null) { if (trim($message) === '') { $queryPath = $query->getPath(); @@ -29,16 +29,14 @@ public function __construct(Reference $query, string $message = '', int $code = } } - parent::__construct($message, $code, $previous); + parent::__construct(message: $message, previous: $previous); $this->reference = $query; } public static function onReference(Reference $reference, ?Throwable $error = null): self { - $code = $error !== null ? $error->getCode() : 0; - - return new self($reference, '', $code, $error); + return new self($reference, $error?->getMessage() ?? '', $error); } public function getReference(): Reference diff --git a/src/Firebase/Exception/Database/UnsupportedQuery.php b/src/Firebase/Exception/Database/UnsupportedQuery.php index 6c55b10c2..7f641f255 100644 --- a/src/Firebase/Exception/Database/UnsupportedQuery.php +++ b/src/Firebase/Exception/Database/UnsupportedQuery.php @@ -13,11 +13,10 @@ final class UnsupportedQuery extends RuntimeException implements DatabaseExcepti { public function __construct( private readonly Query $query, - string $message = '', - int $code = 0, + string $message, ?Throwable $previous = null, ) { - parent::__construct($message, $code, $previous); + parent::__construct(message: $message, previous: $previous); } public function getQuery(): Query diff --git a/src/Firebase/Exception/DatabaseApiExceptionConverter.php b/src/Firebase/Exception/DatabaseApiExceptionConverter.php index 9030ac31a..b2186dad2 100644 --- a/src/Firebase/Exception/DatabaseApiExceptionConverter.php +++ b/src/Firebase/Exception/DatabaseApiExceptionConverter.php @@ -31,10 +31,13 @@ public function convertException(Throwable $exception): DatabaseException } if ($exception instanceof NetworkExceptionInterface) { - return new ApiConnectionFailed('Unable to connect to the API: '.$exception->getMessage(), $exception->getCode(), $exception); + return new ApiConnectionFailed( + message: 'Unable to connect to the API: '.$exception->getMessage(), + previous: $exception + ); } - return new DatabaseError($exception->getMessage(), $exception->getCode(), $exception); + return new DatabaseError(message: $exception->getMessage(), previous: $exception); } private function convertGuzzleRequestException(RequestException $e): DatabaseException diff --git a/src/Firebase/Exception/Messaging/AuthenticationError.php b/src/Firebase/Exception/Messaging/AuthenticationError.php index 39d1c21e0..392a29907 100644 --- a/src/Firebase/Exception/Messaging/AuthenticationError.php +++ b/src/Firebase/Exception/Messaging/AuthenticationError.php @@ -19,7 +19,7 @@ final class AuthenticationError extends RuntimeException implements MessagingExc */ public function withErrors(array $errors): self { - $new = new self($this->getMessage(), $this->getCode(), $this->getPrevious()); + $new = new self(message: $this->getMessage(), previous: $this->getPrevious()); $new->errors = $errors; return $new; diff --git a/src/Firebase/Exception/Messaging/InvalidMessage.php b/src/Firebase/Exception/Messaging/InvalidMessage.php index 6fc747323..a99b83a58 100644 --- a/src/Firebase/Exception/Messaging/InvalidMessage.php +++ b/src/Firebase/Exception/Messaging/InvalidMessage.php @@ -19,7 +19,7 @@ final class InvalidMessage extends RuntimeException implements MessagingExceptio */ public function withErrors(array $errors): self { - $new = new self($this->getMessage(), $this->getCode(), $this->getPrevious()); + $new = new self(message: $this->getMessage(), previous: $this->getPrevious()); $new->errors = $errors; return $new; diff --git a/src/Firebase/Exception/Messaging/MessagingError.php b/src/Firebase/Exception/Messaging/MessagingError.php index 19d308d8a..25080674b 100644 --- a/src/Firebase/Exception/Messaging/MessagingError.php +++ b/src/Firebase/Exception/Messaging/MessagingError.php @@ -19,7 +19,7 @@ final class MessagingError extends RuntimeException implements MessagingExceptio */ public function withErrors(array $errors): self { - $new = new self($this->getMessage(), $this->getCode(), $this->getPrevious()); + $new = new self(message: $this->getMessage(), previous: $this->getPrevious()); $new->errors = $errors; return $new; diff --git a/src/Firebase/Exception/Messaging/NotFound.php b/src/Firebase/Exception/Messaging/NotFound.php index 0054705fe..7fd30d1d6 100644 --- a/src/Firebase/Exception/Messaging/NotFound.php +++ b/src/Firebase/Exception/Messaging/NotFound.php @@ -57,7 +57,7 @@ public static function becauseTokenNotFound(string $token, array $errors = []): */ public function withErrors(array $errors): self { - $new = new self($this->getMessage(), $this->getCode(), $this->getPrevious()); + $new = new self(message: $this->getMessage(), previous: $this->getPrevious()); $new->errors = $errors; return $new; diff --git a/src/Firebase/Exception/Messaging/QuotaExceeded.php b/src/Firebase/Exception/Messaging/QuotaExceeded.php index 36c22bc1b..ed6c03adf 100644 --- a/src/Firebase/Exception/Messaging/QuotaExceeded.php +++ b/src/Firebase/Exception/Messaging/QuotaExceeded.php @@ -22,7 +22,7 @@ final class QuotaExceeded extends RuntimeException implements MessagingException */ public function withErrors(array $errors): self { - $new = new self($this->getMessage(), $this->getCode(), $this->getPrevious()); + $new = new self(message: $this->getMessage(), previous: $this->getPrevious()); $new->errors = $errors; $new->retryAfter = $this->retryAfter; @@ -31,7 +31,7 @@ public function withErrors(array $errors): self public function withRetryAfter(DateTimeImmutable $retryAfter): self { - $new = new self($this->getMessage(), $this->getCode(), $this->getPrevious()); + $new = new self(message: $this->getMessage(), previous: $this->getPrevious()); $new->errors = $this->errors; $new->retryAfter = $retryAfter; diff --git a/src/Firebase/Exception/Messaging/ServerError.php b/src/Firebase/Exception/Messaging/ServerError.php index a7b87838d..d656b81a0 100644 --- a/src/Firebase/Exception/Messaging/ServerError.php +++ b/src/Firebase/Exception/Messaging/ServerError.php @@ -19,7 +19,7 @@ final class ServerError extends RuntimeException implements MessagingException */ public function withErrors(array $errors): self { - $new = new self($this->getMessage(), $this->getCode(), $this->getPrevious()); + $new = new self(message: $this->getMessage(), previous: $this->getPrevious()); $new->errors = $errors; return $new; diff --git a/src/Firebase/Exception/Messaging/ServerUnavailable.php b/src/Firebase/Exception/Messaging/ServerUnavailable.php index d6fe95c88..f48a4d7c6 100644 --- a/src/Firebase/Exception/Messaging/ServerUnavailable.php +++ b/src/Firebase/Exception/Messaging/ServerUnavailable.php @@ -22,7 +22,7 @@ final class ServerUnavailable extends RuntimeException implements MessagingExcep */ public function withErrors(array $errors): self { - $new = new self($this->getMessage(), $this->getCode(), $this->getPrevious()); + $new = new self(message: $this->getMessage(), previous: $this->getPrevious()); $new->errors = $errors; $new->retryAfter = $this->retryAfter; @@ -31,7 +31,7 @@ public function withErrors(array $errors): self public function withRetryAfter(DateTimeImmutable $retryAfter): self { - $new = new self($this->getMessage(), $this->getCode(), $this->getPrevious()); + $new = new self(message: $this->getMessage(), previous: $this->getPrevious()); $new->errors = $this->errors; $new->retryAfter = $retryAfter; diff --git a/src/Firebase/Exception/MessagingApiExceptionConverter.php b/src/Firebase/Exception/MessagingApiExceptionConverter.php index 23aa406c7..ad5f31837 100644 --- a/src/Firebase/Exception/MessagingApiExceptionConverter.php +++ b/src/Firebase/Exception/MessagingApiExceptionConverter.php @@ -47,10 +47,13 @@ public function convertException(Throwable $exception): MessagingException } if ($exception instanceof NetworkExceptionInterface) { - return new ApiConnectionFailed('Unable to connect to the API: '.$exception->getMessage(), $exception->getCode(), $exception); + return new ApiConnectionFailed( + message: 'Unable to connect to the API: '.$exception->getMessage(), + previous: $exception + ); } - return new MessagingError($exception->getMessage(), $exception->getCode(), $exception); + return new MessagingError(message: $exception->getMessage(), previous: $exception); } public function convertResponse(ResponseInterface $response, ?Throwable $previous = null): MessagingException @@ -142,7 +145,7 @@ private function convertGuzzleRequestException(RequestException $e): MessagingEx return $this->convertResponse($response, $e); } - return new MessagingError($e->getMessage(), $e->getCode(), $e); + return new MessagingError(message: $e->getMessage(), previous: $e); } private function getRetryAfter(ResponseInterface $response): ?DateTimeImmutable diff --git a/src/Firebase/Exception/RemoteConfigApiExceptionConverter.php b/src/Firebase/Exception/RemoteConfigApiExceptionConverter.php index 7a5a4bc50..0e3d5efc0 100644 --- a/src/Firebase/Exception/RemoteConfigApiExceptionConverter.php +++ b/src/Firebase/Exception/RemoteConfigApiExceptionConverter.php @@ -33,10 +33,13 @@ public function convertException(Throwable $exception): RemoteConfigException } if ($exception instanceof ConnectException) { - return new ApiConnectionFailed('Unable to connect to the API: '.$exception->getMessage(), $exception->getCode(), $exception); + return new ApiConnectionFailed( + message: 'Unable to connect to the API: '.$exception->getMessage(), + previous: $exception + ); } - return new RemoteConfigError($exception->getMessage(), $exception->getCode(), $exception); + return new RemoteConfigError(message: $exception->getMessage(), previous: $exception); } private function convertGuzzleRequestException(RequestException $e): RemoteConfigException diff --git a/src/Firebase/Factory.php b/src/Firebase/Factory.php index 1482b3575..fe5a20931 100644 --- a/src/Firebase/Factory.php +++ b/src/Firebase/Factory.php @@ -19,7 +19,6 @@ use Google\Cloud\Storage\StorageClient; use GuzzleHttp\Client; use GuzzleHttp\HandlerStack; -use GuzzleHttp\MessageFormatter; use GuzzleHttp\Psr7\HttpFactory; use GuzzleHttp\Psr7\Utils as GuzzleUtils; use Kreait\Firebase\AppCheck\AppCheckTokenGenerator; @@ -48,9 +47,6 @@ use Psr\Cache\CacheItemPoolInterface; use Psr\Clock\ClockInterface; use Psr\Http\Message\UriInterface; -use Psr\Log\LoggerInterface; -use Psr\Log\LogLevel; -use Stringable; use Throwable; use function array_filter; @@ -60,7 +56,7 @@ final class Factory { - public const API_CLIENT_SCOPES = [ + public const array API_CLIENT_SCOPES = [ 'https://www.googleapis.com/auth/iam', 'https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/firebase', @@ -212,17 +208,6 @@ public function withDatabaseAuthVariableOverride(?array $override): self return $factory; } - /** - * @deprecated 7.19.0 Use `createFirestore($database)` instead - * @see createFirestore() - * - * @param non-empty-string $database - */ - public function withFirestoreDatabase(string $database): self - { - return $this->withFirestoreClientConfig(['database' => $database]); - } - /** * @param array $config */ @@ -306,60 +291,6 @@ public function withHttpClientOptions(HttpClientOptions $options): self return $factory; } - /** - * @deprecated 7.25.0 Create the log middleware outside the factory and use `HttpClientOptions::withGuzzleMiddleware()` and `withClientOptions()` instead - * - * @see withHttpClientOptions() - * @see HttpClientOptions::withGuzzleMiddleware() - * - * @param non-empty-string|null $logLevel - * @param non-empty-string|null $errorLogLevel - */ - public function withHttpLogger(LoggerInterface $logger, ?MessageFormatter $formatter = null, ?string $logLevel = null, ?string $errorLogLevel = null): self - { - $clientOptions = $this->httpClientOptions->withGuzzleMiddleware( - middleware: Middleware::log( - $logger, - $formatter ?? new MessageFormatter(), - $logLevel ?? LogLevel::INFO, - $errorLogLevel ?? LogLevel::NOTICE, - ), - name: 'http_logs' - ); - - $factory = clone $this; - $factory->httpClientOptions = $clientOptions; - - return $factory; - } - - /** - * @deprecated 7.25.0 Create the log middleware outside the factory and use `HttpClientOptions::withGuzzleMiddleware()` and `withClientOptions()` instead - * - * @see withHttpClientOptions() - * @see HttpClientOptions::withGuzzleMiddleware() - * - * @param non-empty-string|null $logLevel - * @param non-empty-string|null $errorLogLevel - */ - public function withHttpDebugLogger(LoggerInterface $logger, ?MessageFormatter $formatter = null, ?string $logLevel = null, ?string $errorLogLevel = null): self - { - $clientOptions = $this->httpClientOptions->withGuzzleMiddleware( - middleware: Middleware::log( - $logger, - $formatter ?? new MessageFormatter(MessageFormatter::DEBUG), - $logLevel ?? LogLevel::INFO, - $errorLogLevel ?? LogLevel::NOTICE, - ), - name: 'http_debug_logs' - ); - - $factory = clone $this; - $factory->httpClientOptions = $clientOptions; - - return $factory; - } - public function withClock(object $clock): self { if (!$clock instanceof ClockInterface) { @@ -372,6 +303,9 @@ public function withClock(object $clock): self return $factory; } + /** + * @phpstan-ignore typePerfect.narrowReturnObjectType + */ public function createAppCheck(): Contract\AppCheck { $projectId = $this->getProjectId(); @@ -405,6 +339,9 @@ public function createAppCheck(): Contract\AppCheck ); } + /** + * @phpstan-ignore typePerfect.narrowReturnObjectType + */ public function createAuth(): Contract\Auth { $projectId = $this->getProjectId(); @@ -427,6 +364,9 @@ public function createAuth(): Contract\Auth return new Auth($authApiClient, $customTokenGenerator, $idTokenVerifier, $sessionCookieVerifier, $this->clock); } + /** + * @phpstan-ignore typePerfect.narrowReturnObjectType + */ public function createDatabase(): Contract\Database { $middlewares = array_filter([ @@ -448,6 +388,9 @@ public function createDatabase(): Contract\Database ); } + /** + * @phpstan-ignore typePerfect.narrowReturnObjectType + */ public function createRemoteConfig(): Contract\RemoteConfig { $http = $this->createApiClient([ @@ -463,6 +406,9 @@ public function createRemoteConfig(): Contract\RemoteConfig ); } + /** + * @phpstan-ignore typePerfect.narrowReturnObjectType + */ public function createMessaging(): Contract\Messaging { $projectId = $this->getProjectId(); @@ -492,33 +438,6 @@ public function createMessaging(): Contract\Messaging return new Messaging($messagingApiClient, $appInstanceApiClient, $errorHandler); } - /** - * @deprecated 7.14.0 Firebase Dynamic Links is deprecated and should not be used in new projects. The service will - * shut down on August 25, 2025. The component will remain in the SDK until then, but as the - * Firebase service is deprecated, this component is also deprecated - * @codeCoverageIgnore - * - * @see https://firebase.google.com/support/dynamic-links-faq Dynamic Links Deprecation FAQ - * - * @param Stringable|non-empty-string|null $defaultDynamicLinksDomain - */ - public function createDynamicLinksService($defaultDynamicLinksDomain = null): Contract\DynamicLinks - { - $apiClient = new DynamicLink\ApiClient( - $this->createApiClient(), - $this->httpFactory, - $this->httpFactory, - ); - - $defaultDynamicLinksDomain = trim((string) $defaultDynamicLinksDomain); - - if ($defaultDynamicLinksDomain !== '') { - return DynamicLinks::withApiClientAndDefaultDomain($apiClient, $defaultDynamicLinksDomain); - } - - return DynamicLinks::withApiClient($apiClient); - } - /** * @param non-empty-string|null $databaseName */ @@ -533,59 +452,23 @@ public function createFirestore(?string $databaseName = null): Contract\Firestor return Firestore::fromConfig($config); } + /** + * @phpstan-ignore typePerfect.narrowReturnObjectType + */ public function createStorage(): Contract\Storage { try { $storageClient = new StorageClient($this->googleCloudClientConfig()); } catch (Throwable $e) { - throw new RuntimeException('Unable to create a StorageClient: '.$e->getMessage(), $e->getCode(), $e); + throw new RuntimeException( + message: 'Unable to create a StorageClient: '.$e->getMessage(), + previous: $e + ); } return new Storage($storageClient, $this->getStorageBucketName()); } - /** - * @deprecated 7.20.0 - * @codeCoverageIgnore - * - * @return array - */ - public function getDebugInfo(): array - { - try { - $projectId = $this->getProjectId(); - } catch (Throwable $e) { - $projectId = $e->getMessage(); - } - - try { - $credentials = $this->getGoogleAuthTokenCredentials(); - - if ($credentials !== null) { - $credentials = $credentials::class; - } - } catch (Throwable $e) { - $credentials = $e->getMessage(); - } - - try { - $databaseUrl = $this->getDatabaseUrl(); - } catch (Throwable $e) { - $databaseUrl = $e->getMessage(); - } - - return [ - 'credentialsType' => $credentials, - 'databaseUrl' => $databaseUrl, - 'defaultStorageBucket' => $this->defaultStorageBucket, - 'projectId' => $projectId, - 'serviceAccount' => $this->getServiceAccount(), - 'tenantId' => $this->tenantId, - 'tokenCacheType' => $this->authTokenCache !== null ? $this->authTokenCache::class : $this->defaultCache::class, - 'verifierCacheType' => $this->verifierCache !== null ? $this->verifierCache::class : $this->defaultCache::class, - ]; - } - /** * @param array|null $config * @param array|null $middlewares diff --git a/src/Firebase/Firestore.php b/src/Firebase/Firestore.php index 88a89e1e6..8f4d21917 100644 --- a/src/Firebase/Firestore.php +++ b/src/Firebase/Firestore.php @@ -11,21 +11,26 @@ /** * @internal */ -final class Firestore implements Contract\Firestore +final readonly class Firestore implements Contract\Firestore { - private function __construct(private readonly FirestoreClient $client) + private function __construct(private FirestoreClient $client) { } /** * @param array $config + * + * @phpstan-ignore typePerfect.narrowReturnObjectType */ public static function fromConfig(array $config): Contract\Firestore { try { return new self(new FirestoreClient($config)); } catch (Throwable $e) { - throw new RuntimeException('Unable to create a FirestoreClient: '.$e->getMessage(), $e->getCode(), $e); + throw new RuntimeException( + message: 'Unable to create a FirestoreClient: '.$e->getMessage(), + previous: $e + ); } } diff --git a/src/Firebase/Http/HttpClientOptions.php b/src/Firebase/Http/HttpClientOptions.php index 28f391e49..b6059a5af 100644 --- a/src/Firebase/Http/HttpClientOptions.php +++ b/src/Firebase/Http/HttpClientOptions.php @@ -11,15 +11,15 @@ use function is_callable; -final class HttpClientOptions +final readonly class HttpClientOptions { /** * @param array $guzzleConfig * @param list $guzzleMiddlewares */ private function __construct( - private readonly array $guzzleConfig, - private readonly array $guzzleMiddlewares, + private array $guzzleConfig, + private array $guzzleMiddlewares, ) { } diff --git a/src/Firebase/Http/Middleware.php b/src/Firebase/Http/Middleware.php index 14c8ce18a..022bd994d 100644 --- a/src/Firebase/Http/Middleware.php +++ b/src/Firebase/Http/Middleware.php @@ -6,16 +6,8 @@ use Beste\Json; use Closure; -use Exception; -use Fig\Http\Message\StatusCodeInterface as StatusCode; -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\MessageFormatter; -use GuzzleHttp\Promise\Create; -use GuzzleHttp\Promise\PromiseInterface; use GuzzleHttp\Psr7\Query; use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; -use Psr\Log\LoggerInterface; use function array_merge; use function ltrim; @@ -63,31 +55,4 @@ public static function addDatabaseAuthVariableOverride(?array $override): callab return $handler($request->withUri($uri), $options); }; } - - /** - * @deprecated 7.25.0 Use the Log Middleware provided by the GuzzleHTTP library instead - * - * @return callable(callable): Closure - */ - public static function log(LoggerInterface $logger, MessageFormatter $formatter, string $logLevel, string $errorLogLevel): callable - { - return static fn(callable $handler): Closure => static fn(RequestInterface $request, array $options) => $handler($request, $options)->then( - static function (ResponseInterface $response) use ($logger, $request, $formatter, $logLevel, $errorLogLevel): ResponseInterface { - $message = $formatter->format($request, $response); - $messageLogLevel = $response->getStatusCode() >= StatusCode::STATUS_BAD_REQUEST ? $errorLogLevel : $logLevel; - - $logger->log($messageLogLevel, $message); - - return $response; - }, - static function (Exception $reason) use ($logger, $request, $formatter, $errorLogLevel): PromiseInterface { - $response = $reason instanceof RequestException ? $reason->getResponse() : null; - $message = $formatter->format($request, $response, $reason); - - $logger->log($errorLogLevel, $message, ['request' => $request, 'response' => $response]); - - return Create::rejectionFor($reason); - }, - ); - } } diff --git a/src/Firebase/Messaging.php b/src/Firebase/Messaging.php index 8220338f4..62a171df7 100644 --- a/src/Firebase/Messaging.php +++ b/src/Firebase/Messaging.php @@ -15,6 +15,7 @@ use Kreait\Firebase\Messaging\AppInstance; use Kreait\Firebase\Messaging\AppInstanceApiClient; use Kreait\Firebase\Messaging\Message; +use Kreait\Firebase\Messaging\Messages; use Kreait\Firebase\Messaging\MessageTarget; use Kreait\Firebase\Messaging\MulticastSendReport; use Kreait\Firebase\Messaging\Processor\SetApnsContentAvailableIfNeeded; @@ -35,12 +36,12 @@ /** * @internal */ -final class Messaging implements Contract\Messaging +final readonly class Messaging implements Contract\Messaging { public function __construct( - private readonly ApiClient $messagingApi, - private readonly AppInstanceApiClient $appInstanceApi, - private readonly MessagingApiExceptionConverter $exceptionConverter, + private ApiClient $messagingApi, + private AppInstanceApiClient $appInstanceApi, + private MessagingApiExceptionConverter $exceptionConverter, ) { } @@ -66,7 +67,7 @@ public function send(Message|array $message, bool $validateOnly = false): array throw $error; } - public function sendMulticast($message, $registrationTokens, bool $validateOnly = false): MulticastSendReport + public function sendMulticast(Message|array $message, RegistrationTokens|RegistrationToken|array|string $registrationTokens, bool $validateOnly = false): MulticastSendReport { $message = $message instanceof Message ? $message : new RawMessageFromArray($message); $registrationTokens = RegistrationTokens::fromValue($registrationTokens); @@ -80,7 +81,7 @@ public function sendMulticast($message, $registrationTokens, bool $validateOnly return $this->sendAll($messages, $validateOnly); } - public function sendAll($messages, bool $validateOnly = false): MulticastSendReport + public function sendAll(array|Messages $messages, bool $validateOnly = false): MulticastSendReport { $messages = $this->ensureMessages($messages); $requests = $this->createSendRequests($messages, $validateOnly); @@ -113,12 +114,12 @@ public function sendAll($messages, bool $validateOnly = false): MulticastSendRep return MulticastSendReport::withItems($sendReports); } - public function validate($message): array + public function validate(Message|array $message): array { return $this->send($message, true); } - public function validateRegistrationTokens($registrationTokenOrTokens): array + public function validateRegistrationTokens(RegistrationTokens|RegistrationToken|array|string $registrationTokenOrTokens): array { $tokens = RegistrationTokens::fromValue($registrationTokenOrTokens); @@ -136,7 +137,7 @@ public function subscribeToTopic(string|Topic $topic, RegistrationTokens|Registr return $this->subscribeToTopics([$topic], $registrationTokenOrTokens); } - public function subscribeToTopics(iterable $topics, $registrationTokenOrTokens): array + public function subscribeToTopics(iterable $topics, RegistrationTokens|RegistrationToken|array|string $registrationTokenOrTokens): array { $topicObjects = []; @@ -166,7 +167,7 @@ public function unsubscribeFromTopics(array $topics, RegistrationTokens|Registra return $this->appInstanceApi->unsubscribeFromTopics($topics, $tokens); } - public function unsubscribeFromAllTopics($registrationTokenOrTokens): array + public function unsubscribeFromAllTopics(RegistrationTokens|RegistrationToken|array|string $registrationTokenOrTokens): array { $tokens = RegistrationTokens::fromValue($registrationTokenOrTokens); @@ -211,7 +212,10 @@ public function getAppInstance(RegistrationToken|string $registrationToken): App throw NotFound::becauseTokenNotFound($token->value(), $e->errors()); } catch (MessagingException $e) { // The token is invalid - throw new InvalidArgument("The registration token '{$token}' is invalid or not available", $e->getCode(), $e); + throw new InvalidArgument( + message: "The registration token '{$token}' is invalid or not available", + previous: $e + ); } } @@ -267,7 +271,7 @@ private function messageHasTarget(Message $message): bool || array_key_exists(MessageTarget::TOPIC, $check); } - private function withChangedTarget(Message $message, string $target, string $value): Message + private function withChangedTarget(Message $message, string $target, string $value): RawMessageFromArray { $message = Json::decode(Json::encode($message), true); diff --git a/src/Firebase/Messaging/AndroidConfig.php b/src/Firebase/Messaging/AndroidConfig.php index 3c7a5d2f2..25a765827 100644 --- a/src/Firebase/Messaging/AndroidConfig.php +++ b/src/Firebase/Messaging/AndroidConfig.php @@ -79,27 +79,27 @@ */ final class AndroidConfig implements JsonSerializable { - private const MESSAGE_PRIORITY_NORMAL = 'normal'; + private const string MESSAGE_PRIORITY_NORMAL = 'normal'; - private const MESSAGE_PRIORITY_HIGH = 'high'; + private const string MESSAGE_PRIORITY_HIGH = 'high'; - private const NOTIFICATION_PRIORITY_UNSPECIFIED = 'PRIORITY_UNSPECIFIED'; + private const string NOTIFICATION_PRIORITY_UNSPECIFIED = 'PRIORITY_UNSPECIFIED'; - private const NOTIFICATION_PRIORITY_MIN = 'PRIORITY_MIN'; + private const string NOTIFICATION_PRIORITY_MIN = 'PRIORITY_MIN'; - private const NOTIFICATION_PRIORITY_LOW = 'PRIORITY_LOW'; + private const string NOTIFICATION_PRIORITY_LOW = 'PRIORITY_LOW'; - private const NOTIFICATION_PRIORITY_DEFAULT = 'PRIORITY_DEFAULT'; + private const string NOTIFICATION_PRIORITY_DEFAULT = 'PRIORITY_DEFAULT'; - private const NOTIFICATION_PRIORITY_HIGH = 'PRIORITY_HIGH'; + private const string NOTIFICATION_PRIORITY_HIGH = 'PRIORITY_HIGH'; - private const NOTIFICATION_PRIORITY_MAX = 'PRIORITY_MAX'; + private const string NOTIFICATION_PRIORITY_MAX = 'PRIORITY_MAX'; - private const NOTIFICATION_VISIBILITY_PRIVATE = 'PRIVATE'; + private const string NOTIFICATION_VISIBILITY_PRIVATE = 'PRIVATE'; - private const NOTIFICATION_VISIBILITY_PUBLIC = 'PUBLIC'; + private const string NOTIFICATION_VISIBILITY_PUBLIC = 'PUBLIC'; - private const NOTIFICATION_VISIBILITY_SECRET = 'SECRET'; + private const string NOTIFICATION_VISIBILITY_SECRET = 'SECRET'; /** * @param AndroidConfigShape $config diff --git a/src/Firebase/Messaging/ApnsConfig.php b/src/Firebase/Messaging/ApnsConfig.php index 138ff9e8d..40b431a3f 100644 --- a/src/Firebase/Messaging/ApnsConfig.php +++ b/src/Firebase/Messaging/ApnsConfig.php @@ -25,11 +25,11 @@ * live_activity_token?: non-empty-string * } */ -final class ApnsConfig implements JsonSerializable +final readonly class ApnsConfig implements JsonSerializable { - private const PRIORITY_CONSERVE_POWER = '5'; + private const string PRIORITY_CONSERVE_POWER = '5'; - private const PRIORITY_IMMEDIATE = '10'; + private const string PRIORITY_IMMEDIATE = '10'; /** * @param array $headers @@ -38,10 +38,10 @@ final class ApnsConfig implements JsonSerializable * @param non-empty-string|null $liveActivityToken */ private function __construct( - private readonly array $headers, - private readonly array $payload, - private readonly array $fcmOptions, - private readonly ?string $liveActivityToken, + private array $headers, + private array $payload, + private array $fcmOptions, + private ?string $liveActivityToken, ) { } @@ -105,7 +105,7 @@ public function withApsField(string $key, mixed $value): self /** * @param non-empty-string $name */ - public function withDataField(string $name, mixed $value): self + public function withDataField(string $name, string $value): self { if ($name === 'aps') { throw new InvalidArgument('"aps" is a reserved field name'); diff --git a/src/Firebase/Messaging/AppInstance.php b/src/Firebase/Messaging/AppInstance.php index 54a25e96f..d1611531d 100644 --- a/src/Firebase/Messaging/AppInstance.php +++ b/src/Firebase/Messaging/AppInstance.php @@ -10,15 +10,15 @@ /** * @see https://developers.google.com/instance-id/reference/server#results */ -final class AppInstance implements JsonSerializable +final readonly class AppInstance implements JsonSerializable { /** * @param array $rawData */ private function __construct( - private readonly RegistrationToken $registrationToken, - private readonly TopicSubscriptions $topicSubscriptions, - private readonly array $rawData, + private RegistrationToken $registrationToken, + private TopicSubscriptions $topicSubscriptions, + private array $rawData, ) { } @@ -38,7 +38,7 @@ public static function fromRawData(RegistrationToken $registrationToken, array $ $subscriptions = []; foreach ($rawData['rel']['topics'] ?? [] as $topicName => $subscriptionInfo) { - $topic = Topic::fromValue((string) $topicName); + $topic = Topic::fromValue($topicName); $addedAt = DT::toUTCDateTimeImmutable($subscriptionInfo['addDate'] ?? null); $subscriptions[] = new TopicSubscription($topic, $registrationToken, $addedAt); } diff --git a/src/Firebase/Messaging/AppInstanceApiClient.php b/src/Firebase/Messaging/AppInstanceApiClient.php index f4e9fad28..8ba1ec7df 100644 --- a/src/Firebase/Messaging/AppInstanceApiClient.php +++ b/src/Firebase/Messaging/AppInstanceApiClient.php @@ -85,7 +85,7 @@ public function subscribeToTopics(array $topics, RegistrationTokens $tokens): ar break; case 'rejected': - $result[$topicName] = $response['reason']->getMessage(); + $result[$topicName] = $response['reason']->getMessage(); // @phpstan-ignore typePerfect.noMixedMethodCaller break; } @@ -152,7 +152,7 @@ public function unsubscribeFromTopics(array $topics, RegistrationTokens $tokens) break; case 'rejected': - $result[$topicName] = $response['reason']->getMessage(); + $result[$topicName] = $response['reason']->getMessage(); // @phpstan-ignore typePerfect.noMixedMethodCaller break; } diff --git a/src/Firebase/Messaging/CloudMessage.php b/src/Firebase/Messaging/CloudMessage.php index 360cdc443..1f178008c 100644 --- a/src/Firebase/Messaging/CloudMessage.php +++ b/src/Firebase/Messaging/CloudMessage.php @@ -7,7 +7,6 @@ use Beste\Json; use Kreait\Firebase\Exception\InvalidArgumentException; use Kreait\Firebase\Exception\Messaging\InvalidArgument; -use Stringable; use function array_filter; use function array_intersect; @@ -51,17 +50,6 @@ private function __construct( $this->fcmOptions = FcmOptions::fromArray([]); } - /** - * @deprecated 7.16.0 Use `CloudMessage::new()` and one of `toToken()`, `toTopic()`, or `toCondition()` instead. - * - * @param MessageTarget::CONDITION|MessageTarget::TOKEN|MessageTarget::TOPIC|MessageTarget::UNKNOWN $type - * @param non-empty-string $value - */ - public static function withTarget(string $type, string $value): self - { - return new self(MessageTarget::with($type, $value)); - } - public static function new(): self { return new self(MessageTarget::with(MessageTarget::UNKNOWN, 'unknown')); @@ -115,23 +103,7 @@ public static function fromArray(array $data): self } /** - * @deprecated 7.16.0 Use one of `toToken()`, `toTopic()`, or `toCondition()` instead. - * - * @param MessageTarget::CONDITION|MessageTarget::TOKEN|MessageTarget::TOPIC|MessageTarget::UNKNOWN $type - * @param non-empty-string $value - * - * @throws InvalidArgumentException if the target type or value is invalid - */ - public function withChangedTarget(string $type, string $value): self - { - $new = clone $this; - $new->target = MessageTarget::with($type, $value); - - return $new; - } - - /** - * @param MessageData|array $data + * @param MessageData|array $data * * @throws InvalidArgumentException */ @@ -161,7 +133,7 @@ public function withNotification(Notification|array $notification): self * * @throws InvalidArgumentException */ - public function withAndroidConfig($config): self + public function withAndroidConfig(AndroidConfig|array $config): self { $new = clone $this; $new->androidConfig = $config instanceof AndroidConfig ? $config : AndroidConfig::fromArray($config); @@ -174,7 +146,7 @@ public function withAndroidConfig($config): self * * @throws InvalidArgumentException */ - public function withApnsConfig($config): self + public function withApnsConfig(ApnsConfig|array $config): self { $new = clone $this; $new->apnsConfig = $config instanceof ApnsConfig ? $config : ApnsConfig::fromArray($config); @@ -269,22 +241,6 @@ public function toCondition(string $condition): self return $new; } - /** - * @deprecated 7.16.0 - */ - public function hasTarget(): bool - { - return $this->target->type() !== MessageTarget::UNKNOWN; - } - - /** - * @deprecated 7.16.0 - */ - public function target(): MessageTarget - { - return $this->target; - } - public function jsonSerialize(): array { $data = [ diff --git a/src/Firebase/Messaging/Condition.php b/src/Firebase/Messaging/Condition.php index 561bedee2..543d1aa3d 100644 --- a/src/Firebase/Messaging/Condition.php +++ b/src/Firebase/Messaging/Condition.php @@ -13,12 +13,12 @@ use function sprintf; use function str_replace; -final class Condition implements JsonSerializable, Stringable +final readonly class Condition implements JsonSerializable, Stringable { /** * @param non-empty-string $value */ - private function __construct(private readonly string $value) + private function __construct(private string $value) { } diff --git a/src/Firebase/Messaging/Message.php b/src/Firebase/Messaging/Message.php index f9a3cf0d9..b3a199586 100644 --- a/src/Firebase/Messaging/Message.php +++ b/src/Firebase/Messaging/Message.php @@ -5,7 +5,6 @@ namespace Kreait\Firebase\Messaging; use JsonSerializable; -use Stringable; /** * @phpstan-import-type AndroidConfigShape from AndroidConfig @@ -18,7 +17,7 @@ * token?: non-empty-string, * topic?: non-empty-string, * condition?: non-empty-string, - * data?: MessageData|array, + * data?: MessageData|array, * notification?: Notification|NotificationShape, * android?: AndroidConfigShape, * apns?: ApnsConfig|ApnsConfigShape, diff --git a/src/Firebase/Messaging/MessageData.php b/src/Firebase/Messaging/MessageData.php index b1a1a3e8e..634f37b9c 100644 --- a/src/Firebase/Messaging/MessageData.php +++ b/src/Firebase/Messaging/MessageData.php @@ -6,7 +6,6 @@ use JsonSerializable; use Kreait\Firebase\Exception\InvalidArgumentException; -use Stringable; use function in_array; use function mb_detect_encoding; @@ -14,25 +13,23 @@ use function mb_strtolower; use function str_starts_with; -final class MessageData implements JsonSerializable +final readonly class MessageData implements JsonSerializable { /** * @param array $data */ - private function __construct(private readonly array $data) + private function __construct(private array $data) { } /** - * @param array $data + * @param array $data */ public static function fromArray(array $data): self { $validated = []; foreach ($data as $key => $value) { - $value = (string) $value; - if (self::isBinary($value)) { throw new InvalidArgumentException( "The message data field '{$key}' seems to contain binary data. As this can lead to broken messages, " diff --git a/src/Firebase/Messaging/MessageTarget.php b/src/Firebase/Messaging/MessageTarget.php index 3c5580115..f51422954 100644 --- a/src/Firebase/Messaging/MessageTarget.php +++ b/src/Firebase/Messaging/MessageTarget.php @@ -8,20 +8,20 @@ use function mb_strtolower; -final class MessageTarget +final readonly class MessageTarget { - public const CONDITION = 'condition'; + public const string CONDITION = 'condition'; - public const TOKEN = 'token'; + public const string TOKEN = 'token'; - public const TOPIC = 'topic'; + public const string TOPIC = 'topic'; /** * @internal */ - public const UNKNOWN = 'unknown'; + public const string UNKNOWN = 'unknown'; - public const TYPES = [ + public const array TYPES = [ self::CONDITION, self::TOKEN, self::TOPIC, self::UNKNOWN, ]; @@ -30,8 +30,8 @@ final class MessageTarget * @param non-empty-string $value */ private function __construct( - private readonly string $type, - private readonly string $value, + private string $type, + private string $value, ) { } diff --git a/src/Firebase/Messaging/Messages.php b/src/Firebase/Messaging/Messages.php index cc4840ea2..3f919d481 100644 --- a/src/Firebase/Messaging/Messages.php +++ b/src/Firebase/Messaging/Messages.php @@ -13,12 +13,12 @@ /** * @implements IteratorAggregate */ -final class Messages implements Countable, IteratorAggregate +final readonly class Messages implements Countable, IteratorAggregate { /** * @var Message[] */ - private readonly array $messages; + private array $messages; public function __construct(Message ...$messages) { diff --git a/src/Firebase/Messaging/RawMessageFromArray.php b/src/Firebase/Messaging/RawMessageFromArray.php index 92a418f48..48fc50454 100644 --- a/src/Firebase/Messaging/RawMessageFromArray.php +++ b/src/Firebase/Messaging/RawMessageFromArray.php @@ -10,12 +10,12 @@ * @phpstan-import-type MessageInputShape from Message * @phpstan-import-type MessageOutputShape from Message */ -final class RawMessageFromArray implements Message +final readonly class RawMessageFromArray implements Message { /** * @param MessageInputShape $data */ - public function __construct(private readonly array $data) + public function __construct(private array $data) { } diff --git a/src/Firebase/Messaging/RegistrationToken.php b/src/Firebase/Messaging/RegistrationToken.php index 72f23dac6..61e205c8b 100644 --- a/src/Firebase/Messaging/RegistrationToken.php +++ b/src/Firebase/Messaging/RegistrationToken.php @@ -7,12 +7,12 @@ use JsonSerializable; use Stringable; -final class RegistrationToken implements JsonSerializable, Stringable +final readonly class RegistrationToken implements JsonSerializable, Stringable { /** * @param non-empty-string $value */ - private function __construct(private readonly string $value) + private function __construct(private string $value) { } diff --git a/src/Firebase/Messaging/RegistrationTokens.php b/src/Firebase/Messaging/RegistrationTokens.php index e23c56781..6d0ea7ffc 100644 --- a/src/Firebase/Messaging/RegistrationTokens.php +++ b/src/Firebase/Messaging/RegistrationTokens.php @@ -16,12 +16,12 @@ /** * @implements IteratorAggregate */ -final class RegistrationTokens implements Countable, IteratorAggregate +final readonly class RegistrationTokens implements Countable, IteratorAggregate { /** * @var list */ - private readonly array $tokens; + private array $tokens; /** * @internal diff --git a/src/Firebase/Messaging/RequestFactory.php b/src/Firebase/Messaging/RequestFactory.php index 5d600f637..f8889f4c1 100644 --- a/src/Firebase/Messaging/RequestFactory.php +++ b/src/Firebase/Messaging/RequestFactory.php @@ -12,13 +12,13 @@ /** * @internal */ -final class RequestFactory +final readonly class RequestFactory { - private readonly bool $environmentSupportsHTTP2; + private bool $environmentSupportsHTTP2; public function __construct( - private readonly RequestFactoryInterface $requestFactory, - private readonly StreamFactoryInterface $streamFactory, + private RequestFactoryInterface $requestFactory, + private StreamFactoryInterface $streamFactory, ) { $this->environmentSupportsHTTP2 = self::environmentSupportsHTTP2(); } diff --git a/src/Firebase/Messaging/Topic.php b/src/Firebase/Messaging/Topic.php index e194b37b3..0fc26c5d0 100644 --- a/src/Firebase/Messaging/Topic.php +++ b/src/Firebase/Messaging/Topic.php @@ -13,12 +13,12 @@ use function sprintf; use function trim; -final class Topic implements JsonSerializable, Stringable +final readonly class Topic implements JsonSerializable, Stringable { /** * @param non-empty-string $value */ - private function __construct(private readonly string $value) + private function __construct(private string $value) { } diff --git a/src/Firebase/Messaging/TopicSubscription.php b/src/Firebase/Messaging/TopicSubscription.php index ecf619642..f88205982 100644 --- a/src/Firebase/Messaging/TopicSubscription.php +++ b/src/Firebase/Messaging/TopicSubscription.php @@ -9,12 +9,12 @@ use const DATE_ATOM; -final class TopicSubscription implements JsonSerializable +final readonly class TopicSubscription implements JsonSerializable { public function __construct( - private readonly Topic $topic, - private readonly RegistrationToken $registrationToken, - private readonly DateTimeImmutable $subscribedAt, + private Topic $topic, + private RegistrationToken $registrationToken, + private DateTimeImmutable $subscribedAt, ) { } diff --git a/src/Firebase/Messaging/TopicSubscriptions.php b/src/Firebase/Messaging/TopicSubscriptions.php index 76f3b8c16..81c92b5ee 100644 --- a/src/Firebase/Messaging/TopicSubscriptions.php +++ b/src/Firebase/Messaging/TopicSubscriptions.php @@ -14,12 +14,12 @@ /** * @implements IteratorAggregate */ -final class TopicSubscriptions implements Countable, IteratorAggregate +final readonly class TopicSubscriptions implements Countable, IteratorAggregate { /** * @var list */ - private readonly array $subscriptions; + private array $subscriptions; public function __construct(TopicSubscription ...$subscriptions) { diff --git a/src/Firebase/Messaging/WebPushConfig.php b/src/Firebase/Messaging/WebPushConfig.php index 3ba6584d2..384401481 100644 --- a/src/Firebase/Messaging/WebPushConfig.php +++ b/src/Firebase/Messaging/WebPushConfig.php @@ -66,15 +66,15 @@ */ final class WebPushConfig implements JsonSerializable { - private const URGENCY_VERY_LOW = 'very-low'; + private const string URGENCY_VERY_LOW = 'very-low'; - private const URGENCY_LOW = 'low'; + private const string URGENCY_LOW = 'low'; - private const URGENCY_NORMAL = 'normal'; + private const string URGENCY_NORMAL = 'normal'; - private const URGENCY_HIGH = 'high'; + private const string URGENCY_HIGH = 'high'; - private const VALID_URGENCIES = [ + private const array VALID_URGENCIES = [ self::URGENCY_VERY_LOW, self::URGENCY_LOW, self::URGENCY_NORMAL, diff --git a/src/Firebase/RemoteConfig.php b/src/Firebase/RemoteConfig.php index 4b972c17e..f2ba556fd 100644 --- a/src/Firebase/RemoteConfig.php +++ b/src/Firebase/RemoteConfig.php @@ -22,9 +22,9 @@ * * @phpstan-import-type RemoteConfigTemplateShape from Template */ -final class RemoteConfig implements Contract\RemoteConfig +final readonly class RemoteConfig implements Contract\RemoteConfig { - public function __construct(private readonly ApiClient $client) + public function __construct(private ApiClient $client) { } diff --git a/src/Firebase/RemoteConfig/Condition.php b/src/Firebase/RemoteConfig/Condition.php index 62396542c..f52d63051 100644 --- a/src/Firebase/RemoteConfig/Condition.php +++ b/src/Firebase/RemoteConfig/Condition.php @@ -43,7 +43,7 @@ public static function fromArray(array $data): self */ public static function named(string $name): self { - return new self($name, 'false', null); + return new self($name, 'false'); } /** diff --git a/src/Firebase/RemoteConfig/ConditionalValue.php b/src/Firebase/RemoteConfig/ConditionalValue.php index 98a8b1621..4b8d33762 100644 --- a/src/Firebase/RemoteConfig/ConditionalValue.php +++ b/src/Firebase/RemoteConfig/ConditionalValue.php @@ -44,7 +44,7 @@ public static function basedOn($condition): self /** * @return RemoteConfigParameterValueShape|non-empty-string */ - public function value() + public function value(): string|array { $data = $this->value->toArray(); @@ -60,7 +60,7 @@ public function value() /** * @param ParameterValue|RemoteConfigParameterValueShape|string $value */ - public function withValue($value): self + public function withValue(ParameterValue|array|string $value): self { if (is_string($value)) { return new self($this->conditionName, ParameterValue::withValue($value)); diff --git a/src/Firebase/RemoteConfig/ExplicitValue.php b/src/Firebase/RemoteConfig/ExplicitValue.php deleted file mode 100644 index 8aabfc67e..000000000 --- a/src/Firebase/RemoteConfig/ExplicitValue.php +++ /dev/null @@ -1,44 +0,0 @@ - $value]); - } - - /** - * @return RemoteConfigExplicitValueShape - */ - public function toArray(): array - { - return $this->data; - } - - public function jsonSerialize(): array - { - return $this->data; - } -} diff --git a/src/Firebase/RemoteConfig/ParameterValue.php b/src/Firebase/RemoteConfig/ParameterValue.php index cd302f1e4..67bba0517 100644 --- a/src/Firebase/RemoteConfig/ParameterValue.php +++ b/src/Firebase/RemoteConfig/ParameterValue.php @@ -21,13 +21,13 @@ * * @see https://firebase.google.com/docs/reference/remote-config/rest/v1/RemoteConfig#remoteconfigparametervalue */ -final class ParameterValue implements JsonSerializable +final readonly class ParameterValue implements JsonSerializable { private function __construct( - private readonly ?string $value = null, - private readonly ?bool $useInAppDefault = null, - private readonly ?PersonalizationValue $personalizationValue = null, - private readonly ?RolloutValue $rolloutValue = null, + private ?string $value = null, + private ?bool $useInAppDefault = null, + private ?PersonalizationValue $personalizationValue = null, + private ?RolloutValue $rolloutValue = null, ) { } diff --git a/src/Firebase/RemoteConfig/PersonalizationValue.php b/src/Firebase/RemoteConfig/PersonalizationValue.php index 5d37903e8..c704bb3e7 100644 --- a/src/Firebase/RemoteConfig/PersonalizationValue.php +++ b/src/Firebase/RemoteConfig/PersonalizationValue.php @@ -13,12 +13,12 @@ * * @see https://firebase.google.com/docs/reference/remote-config/rest/v1/RemoteConfig#personalizationvalue */ -final class PersonalizationValue implements JsonSerializable +final readonly class PersonalizationValue implements JsonSerializable { /** * @param RemoteConfigPersonalizationValueShape $data */ - public function __construct(private readonly array $data) + public function __construct(private array $data) { } diff --git a/src/Firebase/RemoteConfig/RolloutValue.php b/src/Firebase/RemoteConfig/RolloutValue.php index 7173c70fe..c422f4f69 100644 --- a/src/Firebase/RemoteConfig/RolloutValue.php +++ b/src/Firebase/RemoteConfig/RolloutValue.php @@ -15,12 +15,12 @@ * * @see https://firebase.google.com/docs/reference/remote-config/rest/v1/RemoteConfig#rolloutvalue */ -final class RolloutValue implements JsonSerializable +final readonly class RolloutValue implements JsonSerializable { /** * @param RemoteConfigRolloutValueShape $data */ - private function __construct(private readonly array $data) + private function __construct(private array $data) { } diff --git a/src/Firebase/RemoteConfig/TagColor.php b/src/Firebase/RemoteConfig/TagColor.php index a8b0a814b..85cf29894 100644 --- a/src/Firebase/RemoteConfig/TagColor.php +++ b/src/Firebase/RemoteConfig/TagColor.php @@ -14,29 +14,29 @@ class TagColor implements Stringable { - final public const BLUE = 'BLUE'; + final public const string BLUE = 'BLUE'; - final public const BROWN = 'BROWN'; + final public const string BROWN = 'BROWN'; - final public const CYAN = 'CYAN'; + final public const string CYAN = 'CYAN'; - final public const DEEP_ORANGE = 'DEEP_ORANGE'; + final public const string DEEP_ORANGE = 'DEEP_ORANGE'; - final public const GREEN = 'GREEN'; + final public const string GREEN = 'GREEN'; - final public const INDIGO = 'INDIGO'; + final public const string INDIGO = 'INDIGO'; - final public const LIME = 'LIME'; + final public const string LIME = 'LIME'; - final public const ORANGE = 'ORANGE'; + final public const string ORANGE = 'ORANGE'; - final public const PINK = 'PINK'; + final public const string PINK = 'PINK'; - final public const PURPLE = 'PURPLE'; + final public const string PURPLE = 'PURPLE'; - final public const TEAL = 'TEAL'; + final public const string TEAL = 'TEAL'; - final public const VALID_COLORS = [ + final public const array VALID_COLORS = [ self::BLUE, self::BROWN, self::CYAN, self::DEEP_ORANGE, self::GREEN, self::INDIGO, self::LIME, self::ORANGE, self::PINK, self::PURPLE, self::TEAL, ]; @@ -69,7 +69,7 @@ public function __construct(string $value) /** * @return non-empty-string */ - public function __toString() + public function __toString(): string { return $this->value; } diff --git a/src/Firebase/RemoteConfig/Template.php b/src/Firebase/RemoteConfig/Template.php index f1510208b..9d1355ebc 100644 --- a/src/Firebase/RemoteConfig/Template.php +++ b/src/Firebase/RemoteConfig/Template.php @@ -244,12 +244,12 @@ private static function buildParameter(string $name, array $data): Parameter $valueType = ParameterValueType::tryFrom($data['valueType'] ?? '') ?? ParameterValueType::UNSPECIFIED; $parameter = Parameter::named($name) - ->withDescription((string) ($data['description'] ?? '')) + ->withDescription($data['description'] ?? '') ->withDefaultValue($data['defaultValue'] ?? null) ->withValueType($valueType) ; - foreach ((array) ($data['conditionalValues'] ?? []) as $key => $conditionalValueData) { + foreach (($data['conditionalValues'] ?? []) as $key => $conditionalValueData) { $parameter = $parameter->withConditionalValue(new ConditionalValue($key, ParameterValue::fromArray($conditionalValueData))); } @@ -263,7 +263,7 @@ private static function buildParameter(string $name, array $data): Parameter private static function buildParameterGroup(string $name, array $parameterGroupData): ParameterGroup { $group = ParameterGroup::named($name) - ->withDescription((string) ($parameterGroupData['description'] ?? '')) + ->withDescription($parameterGroupData['description'] ?? '') ; foreach ($parameterGroupData['parameters'] as $parameterName => $parameterData) { diff --git a/src/Firebase/RemoteConfig/UpdateOrigin.php b/src/Firebase/RemoteConfig/UpdateOrigin.php index 4555d997c..545c494e7 100644 --- a/src/Firebase/RemoteConfig/UpdateOrigin.php +++ b/src/Firebase/RemoteConfig/UpdateOrigin.php @@ -7,15 +7,15 @@ use JsonSerializable; use Stringable; -final class UpdateOrigin implements JsonSerializable, Stringable +final readonly class UpdateOrigin implements JsonSerializable, Stringable { - public const UNSPECIFIED = 'REMOTE_CONFIG_UPDATE_ORIGIN_UNSPECIFIED'; + public const string UNSPECIFIED = 'REMOTE_CONFIG_UPDATE_ORIGIN_UNSPECIFIED'; - public const CONSOLE = 'CONSOLE'; + public const string CONSOLE = 'CONSOLE'; - public const REST_API = 'REST_API'; + public const string REST_API = 'REST_API'; - private function __construct(private readonly string $value) + private function __construct(private string $value) { } diff --git a/src/Firebase/RemoteConfig/UpdateType.php b/src/Firebase/RemoteConfig/UpdateType.php index 00e4ba301..c87a8cd14 100644 --- a/src/Firebase/RemoteConfig/UpdateType.php +++ b/src/Firebase/RemoteConfig/UpdateType.php @@ -7,17 +7,17 @@ use JsonSerializable; use Stringable; -final class UpdateType implements JsonSerializable, Stringable +final readonly class UpdateType implements JsonSerializable, Stringable { - public const UNSPECIFIED = 'REMOTE_CONFIG_UPDATE_TYPE_UNSPECIFIED'; + public const string UNSPECIFIED = 'REMOTE_CONFIG_UPDATE_TYPE_UNSPECIFIED'; - public const INCREMENTAL_UPDATE = 'INCREMENTAL_UPDATE'; + public const string INCREMENTAL_UPDATE = 'INCREMENTAL_UPDATE'; - public const FORCED_UPDATE = 'FORCED_UPDATE'; + public const string FORCED_UPDATE = 'FORCED_UPDATE'; - public const ROLLBACK = 'ROLLBACK'; + public const string ROLLBACK = 'ROLLBACK'; - private function __construct(private readonly string $value) + private function __construct(private string $value) { } diff --git a/src/Firebase/RemoteConfig/User.php b/src/Firebase/RemoteConfig/User.php index 7362d4cdd..4f856830b 100644 --- a/src/Firebase/RemoteConfig/User.php +++ b/src/Firebase/RemoteConfig/User.php @@ -14,16 +14,16 @@ * imageUrl?: non-empty-string * } */ -final class User +final readonly class User { /** * @param non-empty-string|null $name * @param non-empty-string|null $email */ private function __construct( - private readonly ?string $name, - private readonly ?string $email, - private readonly ?UriInterface $imageUri, + private ?string $name, + private ?string $email, + private ?UriInterface $imageUri, ) { } diff --git a/src/Firebase/RemoteConfig/Version.php b/src/Firebase/RemoteConfig/Version.php index a5e7339bf..48b8fcfa1 100644 --- a/src/Firebase/RemoteConfig/Version.php +++ b/src/Firebase/RemoteConfig/Version.php @@ -22,16 +22,16 @@ * rollbackSource?: non-empty-string * } */ -final class Version +final readonly class Version { private function __construct( - private readonly VersionNumber $versionNumber, - private readonly User $user, - private readonly string $description, - private readonly DateTimeImmutable $updatedAt, - private readonly UpdateOrigin $updateOrigin, - private readonly UpdateType $updateType, - private readonly ?VersionNumber $rollbackSource, + private VersionNumber $versionNumber, + private User $user, + private string $description, + private DateTimeImmutable $updatedAt, + private UpdateOrigin $updateOrigin, + private UpdateType $updateType, + private ?VersionNumber $rollbackSource, ) { } diff --git a/src/Firebase/RemoteConfig/VersionNumber.php b/src/Firebase/RemoteConfig/VersionNumber.php index 089086a54..2ad840d7a 100644 --- a/src/Firebase/RemoteConfig/VersionNumber.php +++ b/src/Firebase/RemoteConfig/VersionNumber.php @@ -10,12 +10,12 @@ use function ctype_digit; -final class VersionNumber implements JsonSerializable, Stringable +final readonly class VersionNumber implements JsonSerializable, Stringable { /** * @param non-empty-string $value */ - private function __construct(private readonly string $value) + private function __construct(private string $value) { } diff --git a/src/Firebase/Request/EditUserTrait.php b/src/Firebase/Request/EditUserTrait.php index 520e05f3b..a3e4ab54e 100644 --- a/src/Firebase/Request/EditUserTrait.php +++ b/src/Firebase/Request/EditUserTrait.php @@ -9,7 +9,6 @@ use Kreait\Firebase\Value\Email; use Kreait\Firebase\Value\Uid; use Kreait\Firebase\Value\Url; -use Stringable; use function array_filter; use function mb_strtolower; @@ -41,10 +40,7 @@ trait EditUserTrait /** @var array|null */ protected ?array $multiFactor = null; - /** - * @param Stringable|mixed $uid - */ - public function withUid($uid): self + public function withUid(string $uid): self { $request = clone $this; $request->uid = Uid::fromString($uid)->value; @@ -52,27 +48,27 @@ public function withUid($uid): self return $request; } - public function withEmail(Stringable|string $email): self + public function withEmail(string $email): self { $request = clone $this; - $request->email = Email::fromString((string) $email)->value; + $request->email = Email::fromString($email)->value; return $request; } - public function withVerifiedEmail(Stringable|string $email): self + public function withVerifiedEmail(string $email): self { $request = clone $this; - $request->email = Email::fromString((string) $email)->value; + $request->email = Email::fromString($email)->value; $request->emailIsVerified = true; return $request; } - public function withUnverifiedEmail(Stringable|string $email): self + public function withUnverifiedEmail(string $email): self { $request = clone $this; - $request->email = Email::fromString((string) $email)->value; + $request->email = Email::fromString($email)->value; $request->emailIsVerified = false; return $request; @@ -87,19 +83,17 @@ public function withDisplayName(string $displayName): self } /** - * @param Stringable|string|null $phoneNumber + * @param non-empty-string|null $phoneNumber */ - public function withPhoneNumber($phoneNumber): self + public function withPhoneNumber(string|null $phoneNumber): self { - $phoneNumber = $phoneNumber !== null ? (string) $phoneNumber : null; - $request = clone $this; $request->phoneNumber = $phoneNumber; return $request; } - public function withPhotoUrl(Stringable|string $url): self + public function withPhotoUrl(string $url): self { $request = clone $this; $request->photoUrl = Url::fromString($url)->value; @@ -141,7 +135,7 @@ public function markEmailAsUnverified(): self return $request; } - public function withClearTextPassword(Stringable|string $clearTextPassword): self + public function withClearTextPassword(string $clearTextPassword): self { $request = clone $this; $request->clearTextPassword = ClearTextPassword::fromString($clearTextPassword)->value; diff --git a/src/Firebase/Request/UpdateUser.php b/src/Firebase/Request/UpdateUser.php index 542e7ecbe..e731e1ffd 100644 --- a/src/Firebase/Request/UpdateUser.php +++ b/src/Firebase/Request/UpdateUser.php @@ -7,9 +7,6 @@ use Beste\Json; use Kreait\Firebase\Exception\InvalidArgumentException; use Kreait\Firebase\Request; -use Stringable; - -use function array_reduce; use function array_unique; use function is_array; use function is_string; @@ -21,11 +18,11 @@ final class UpdateUser implements Request /** @phpstan-use EditUserTrait */ use EditUserTrait; - public const DISPLAY_NAME = 'DISPLAY_NAME'; + public const string DISPLAY_NAME = 'DISPLAY_NAME'; - public const PHOTO_URL = 'PHOTO_URL'; + public const string PHOTO_URL = 'PHOTO_URL'; - public const EMAIL = 'EMAIL'; + public const string EMAIL = 'EMAIL'; /** * @var list @@ -146,11 +143,13 @@ public static function withProperties(array $properties): self case 'deleteproviders': case 'removeprovider': case 'removeproviders': - $request = array_reduce( - (array) $value, - static fn(self $request, $provider): UpdateUser => $request->withRemovedProvider($provider), - $request, - ); + if (is_string($value)) { + $value = [$value]; + } + + foreach ($value as $provider) { + $request = $request->withRemovedProvider($provider); + } break; @@ -180,18 +179,12 @@ public function withRemovedPhoneNumber(): self } /** - * @param Stringable|string $provider + * @param non-empty-string $provider */ - public function withRemovedProvider($provider): self + public function withRemovedProvider(string $provider): self { - $providerString = trim((string) $provider); - - if ($providerString === '') { - return $this; - } - $request = clone $this; - $request->providersToDelete[] = $providerString; + $request->providersToDelete[] = $provider; return $request; } diff --git a/src/Firebase/Valinor/Mapper.php b/src/Firebase/Valinor/Mapper.php index 766721962..e24fb731d 100644 --- a/src/Firebase/Valinor/Mapper.php +++ b/src/Firebase/Valinor/Mapper.php @@ -12,11 +12,11 @@ /** * @internal */ -final class Mapper +final readonly class Mapper { - private readonly MapperBuilder $mapperBuilder; + private MapperBuilder $mapperBuilder; - public function __construct(private readonly mixed $cache = null, ?MapperBuilder $builder = null) + public function __construct(private mixed $cache = null, ?MapperBuilder $builder = null) { $builder ??= new MapperBuilder(); diff --git a/src/Firebase/Valinor/Source.php b/src/Firebase/Valinor/Source.php index fc09736df..ee611d14d 100644 --- a/src/Firebase/Valinor/Source.php +++ b/src/Firebase/Valinor/Source.php @@ -16,11 +16,11 @@ * * @implements IteratorAggregate */ -final class Source implements IteratorAggregate +final readonly class Source implements IteratorAggregate { private function __construct( /** @var iterable */ - private readonly iterable $delegate, + private iterable $delegate, ) { } @@ -57,11 +57,17 @@ public static function file(string $value): self throw new InvalidArgumentException(message: $e->getMessage(), previous: $e); } - $content = $file->fread($file->getSize()); + $fileSize = $file->getSize(); $pathName = $file->getPathname(); + if (!is_int($fileSize)) { + throw new InvalidArgumentException("Unable to get filesize of `$pathName`"); + } + + $content = $file->fread($fileSize); + if ($content === false) { - throw new InvalidArgumentException("Unable to parse `$pathName`"); + throw new InvalidArgumentException("Unable to read `$pathName`"); } return self::json($content); diff --git a/src/Firebase/Value/ClearTextPassword.php b/src/Firebase/Value/ClearTextPassword.php index 8094b4bb3..72bf7153e 100644 --- a/src/Firebase/Value/ClearTextPassword.php +++ b/src/Firebase/Value/ClearTextPassword.php @@ -5,19 +5,18 @@ namespace Kreait\Firebase\Value; use Kreait\Firebase\Exception\InvalidArgumentException; -use Stringable; use function mb_strlen; /** * @internal */ -final class ClearTextPassword +final readonly class ClearTextPassword { /** * @var non-empty-string */ - public readonly string $value; + public string $value; private function __construct(string $value) { @@ -28,8 +27,8 @@ private function __construct(string $value) $this->value = $value; } - public static function fromString(Stringable|string $value): self + public static function fromString(string $value): self { - return new self((string) $value); + return new self($value); } } diff --git a/src/Firebase/Value/Email.php b/src/Firebase/Value/Email.php index 0a0ddd605..dd6795de5 100644 --- a/src/Firebase/Value/Email.php +++ b/src/Firebase/Value/Email.php @@ -5,7 +5,6 @@ namespace Kreait\Firebase\Value; use Kreait\Firebase\Exception\InvalidArgumentException; -use Stringable; use function filter_var; @@ -14,12 +13,12 @@ /** * @internal */ -final class Email +final readonly class Email { /** * @var non-empty-string */ - public readonly string $value; + public string $value; private function __construct(string $value) { @@ -30,8 +29,8 @@ private function __construct(string $value) $this->value = $value; } - public static function fromString(Stringable|string $value): self + public static function fromString(string $value): self { - return new self((string) $value); + return new self($value); } } diff --git a/src/Firebase/Value/Uid.php b/src/Firebase/Value/Uid.php index 7917c8e16..47a45d6f6 100644 --- a/src/Firebase/Value/Uid.php +++ b/src/Firebase/Value/Uid.php @@ -5,19 +5,18 @@ namespace Kreait\Firebase\Value; use Kreait\Firebase\Exception\InvalidArgumentException; -use Stringable; use function mb_strlen; /** * @internal */ -final class Uid +final readonly class Uid { /** * @var non-empty-string */ - public readonly string $value; + public string $value; private function __construct(string $value) { @@ -28,8 +27,8 @@ private function __construct(string $value) $this->value = $value; } - public static function fromString(Stringable|string $value): self + public static function fromString(string $value): self { - return new self((string) $value); + return new self($value); } } diff --git a/src/Firebase/Value/Url.php b/src/Firebase/Value/Url.php index 0ae0dfe55..b9daa2b3e 100644 --- a/src/Firebase/Value/Url.php +++ b/src/Firebase/Value/Url.php @@ -5,17 +5,16 @@ namespace Kreait\Firebase\Value; use Kreait\Firebase\Exception\InvalidArgumentException; -use Stringable; /** * @internal */ -final class Url +final readonly class Url { /** * @var non-empty-string */ - public readonly string $value; + public string $value; /** * @param non-empty-string $value @@ -32,10 +31,8 @@ private function __construct(string $value) $this->value = $value; } - public static function fromString(Stringable|string $value): self + public static function fromString(string $value): self { - $value = (string) $value; - if ($value === '') { throw new InvalidArgumentException('The URL cannot be empty.'); } diff --git a/tests/Integration/AppCheckTest.php b/tests/Integration/AppCheckTest.php index efc8c510e..d2af597e4 100644 --- a/tests/Integration/AppCheckTest.php +++ b/tests/Integration/AppCheckTest.php @@ -6,7 +6,6 @@ use Kreait\Firebase\Contract\AppCheck; use Kreait\Firebase\Tests\IntegrationTestCase; -use PHPUnit\Framework\Attributes\Test; /** * @internal @@ -26,24 +25,21 @@ protected function setUp(): void $this->appCheck = self::$factory->createAppCheck(); } - #[Test] - public function createTokenWithDefaultTtl(): void + public function testCreateTokenWithDefaultTtl(): void { $token = $this->appCheck->createToken(self::$appId); $this->assertSame('3600s', $token->ttl); } - #[Test] - public function createTokenWithCustomTtl(): void + public function testCreateTokenWithCustomTtl(): void { $token = $this->appCheck->createToken(self::$appId, ['ttl' => 1800]); $this->assertSame('1800s', $token->ttl); } - #[Test] - public function verifyToken(): void + public function testVerifyToken(): void { $token = $this->appCheck->createToken(self::$appId); diff --git a/tests/Integration/Auth/CustomTokenViaGoogleCredentialsTest.php b/tests/Integration/Auth/CustomTokenViaGoogleCredentialsTest.php index 36fab221f..3bc724839 100644 --- a/tests/Integration/Auth/CustomTokenViaGoogleCredentialsTest.php +++ b/tests/Integration/Auth/CustomTokenViaGoogleCredentialsTest.php @@ -16,7 +16,6 @@ use Lcobucci\JWT\Encoding\JoseEncoder; use Lcobucci\JWT\Token\Parser; use Lcobucci\JWT\UnencryptedToken; -use PHPUnit\Framework\Attributes\Test; /** * @internal @@ -44,8 +43,7 @@ protected function setUp(): void $this->auth = self::$factory->createAuth(); } - #[Test] - public function createCustomToken(): void + public function testCreateCustomToken(): void { $token = $this->generator->createCustomToken($this->uid, ['a-claim' => 'a-value']); @@ -54,8 +52,7 @@ public function createCustomToken(): void $this->assertSame($this->uid, $check->firebaseUserId()); } - #[Test] - public function aGeneratedCustomTokenCanBeParsed(): void + public function testAGeneratedCustomTokenCanBeParsed(): void { $token = $this->generator->createCustomToken($this->uid, ['a-claim' => 'a-value']); diff --git a/tests/Integration/Auth/UserQueryTest.php b/tests/Integration/Auth/UserQueryTest.php index 045ae1d5b..362942cb0 100644 --- a/tests/Integration/Auth/UserQueryTest.php +++ b/tests/Integration/Auth/UserQueryTest.php @@ -8,7 +8,6 @@ use Kreait\Firebase\Auth\UserRecord; use Kreait\Firebase\Contract\Auth; use Kreait\Firebase\Tests\IntegrationTestCase; -use PHPUnit\Framework\Attributes\Test; use function random_int; @@ -27,8 +26,7 @@ protected function setUp(): void $this->ensureNumberOfUsers(2); } - #[Test] - public function itReturnsResultsInAscendingOrder(): void + public function testItReturnsResultsInAscendingOrder(): void { $query = UserQuery::all() ->withLimit(2) @@ -46,8 +44,7 @@ public function itReturnsResultsInAscendingOrder(): void $this->assertGreaterThan($first->metadata->createdAt, $second->metadata->createdAt); } - #[Test] - public function itReturnsResultsInDescendingOrder(): void + public function testItReturnsResultsInDescendingOrder(): void { $query = UserQuery::all() ->withLimit(2) @@ -65,16 +62,14 @@ public function itReturnsResultsInDescendingOrder(): void $this->assertLessThan($first->metadata->createdAt, $second->metadata->createdAt); } - #[Test] - public function limit(): void + public function testLimit(): void { $result = $this->auth->queryUsers(UserQuery::all()->withLimit(1)); $this->assertCount(1, $result); } - #[Test] - public function filterByUid(): void + public function testFilterByUid(): void { $user = $this->createUserWithEmailAndPassword(); @@ -95,8 +90,7 @@ public function filterByUid(): void } } - #[Test] - public function filterByEmail(): void + public function testFilterByEmail(): void { $user = $this->createUserWithEmailAndPassword(); @@ -117,8 +111,7 @@ public function filterByEmail(): void } } - #[Test] - public function filterByPhoneNumber(): void + public function testFilterByPhoneNumber(): void { $user = $this->auth->createUser([ 'phoneNumber' => '+49'.random_int(90_000_000_000, 99_999_999_999), diff --git a/tests/Integration/AuthTestCase.php b/tests/Integration/AuthTestCase.php index ad2c4026e..4510fa4bd 100644 --- a/tests/Integration/AuthTestCase.php +++ b/tests/Integration/AuthTestCase.php @@ -6,7 +6,6 @@ use DateInterval; use GuzzleHttp\Psr7\Query; -use GuzzleHttp\Psr7\Utils; use InvalidArgumentException; use Kreait\Firebase\Auth\CreateActionLink\FailedToCreateActionLink; use Kreait\Firebase\Auth\CreateSessionCookie\FailedToCreateSessionCookie; @@ -22,7 +21,6 @@ use Kreait\Firebase\Tests\IntegrationTestCase; use Kreait\Firebase\Util; use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; -use PHPUnit\Framework\Attributes\Test; use function assert; use function bin2hex; @@ -49,8 +47,7 @@ protected function setUp(): void $this->auth = self::$factory->createAuth(); } - #[Test] - public function createAnonymousUser(): void + public function testCreateAnonymousUser(): void { $user = $this->auth->createAnonymousUser(); @@ -61,8 +58,7 @@ public function createAnonymousUser(): void } } - #[Test] - public function changeUserPassword(): void + public function testChangeUserPassword(): void { $email = self::randomEmail(__FUNCTION__); @@ -72,7 +68,7 @@ public function changeUserPassword(): void $this->auth->changeUserPassword($user->uid, 'new password'); $updatedUser = $this->auth->signInWithEmailAndPassword($email, 'new password'); - assert($updatedUser->firebaseUserId() === $user->uid); + $this->assertSame($user->uid, $updatedUser->firebaseUserId()); try { $this->expectException(FailedToSignIn::class); @@ -82,8 +78,7 @@ public function changeUserPassword(): void } } - #[Test] - public function changeUserEmail(): void + public function testChangeUserEmail(): void { $email = self::randomEmail(__FUNCTION__.'_1'); $newEmail = self::randomEmail(__FUNCTION__.'_2'); @@ -100,8 +95,7 @@ public function changeUserEmail(): void $this->auth->deleteUser($user->uid); } - #[Test] - public function getEmailVerificationLink(): void + public function testGetEmailVerificationLink(): void { $user = $this->createUserWithEmailAndPassword(); assert(is_string($user->email)); @@ -115,8 +109,7 @@ public function getEmailVerificationLink(): void } #[DoesNotPerformAssertions] - #[Test] - public function sendEmailVerificationLink(): void + public function testSendEmailVerificationLink(): void { $user = $this->createUserWithEmailAndPassword(); assert(is_string($user->email)); @@ -128,15 +121,13 @@ public function sendEmailVerificationLink(): void } } - #[Test] - public function sendEmailVerificationLinkToUnknownUser(): void + public function testSendEmailVerificationLinkToUnknownUser(): void { $this->expectException(FailedToSendActionLink::class); $this->auth->sendEmailVerificationLink(self::randomEmail(__FUNCTION__)); } - #[Test] - public function sendEmailVerificationLinkToDisabledUser(): void + public function testSendEmailVerificationLinkToDisabledUser(): void { $user = $this->createUserWithEmailAndPassword(); assert(is_string($user->email)); @@ -151,8 +142,7 @@ public function sendEmailVerificationLinkToDisabledUser(): void } } - #[Test] - public function getPasswordResetLink(): void + public function testGetPasswordResetLink(): void { $user = $this->createUserWithEmailAndPassword(); assert(is_string($user->email)); @@ -166,8 +156,7 @@ public function getPasswordResetLink(): void } #[DoesNotPerformAssertions] - #[Test] - public function sendPasswordResetLink(): void + public function testSendPasswordResetLink(): void { $user = $this->createUserWithEmailAndPassword(); assert(is_string($user->email)); @@ -180,8 +169,7 @@ public function sendPasswordResetLink(): void } } - #[Test] - public function getSignInWithEmailLink(): void + public function testGetSignInWithEmailLink(): void { $user = $this->createUserWithEmailAndPassword(); assert(is_string($user->email)); @@ -195,8 +183,7 @@ public function getSignInWithEmailLink(): void } #[DoesNotPerformAssertions] - #[Test] - public function sendSignInWithEmailLink(): void + public function testSendSignInWithEmailLink(): void { $user = $this->createUserWithEmailAndPassword(); @@ -208,15 +195,13 @@ public function sendSignInWithEmailLink(): void } } - #[Test] - public function getUnsupportedEmailActionLink(): void + public function testGetUnsupportedEmailActionLink(): void { $this->expectException(FailedToCreateActionLink::class); $this->auth->getEmailActionLink('unsupported', self::randomEmail(__FUNCTION__)); } - #[Test] - public function getLocalizedEmailActionLink(): void + public function testGetLocalizedEmailActionLink(): void { $user = $this->createUserWithEmailAndPassword(); assert(is_string($user->email)); @@ -234,15 +219,13 @@ public function getLocalizedEmailActionLink(): void } } - #[Test] - public function sendUnsupportedEmailActionLink(): void + public function testSendUnsupportedEmailActionLink(): void { $this->expectException(FailedToSendActionLink::class); $this->auth->sendEmailActionLink('unsupported', self::randomEmail(__FUNCTION__)); } - #[Test] - public function listUsers(): void + public function testListUsers(): void { // We already should have a list of users, but let's add another one, // just to be sure @@ -261,8 +244,7 @@ public function listUsers(): void } } - #[Test] - public function verifyIdToken(): void + public function testVerifyIdToken(): void { $result = $this->auth->signInAnonymously(); @@ -282,8 +264,7 @@ public function verifyIdToken(): void } } - #[Test] - public function revokeRefreshTokensAfterIdTokenVerification(): void + public function testRevokeRefreshTokensAfterIdTokenVerification(): void { $idToken = $this->auth->signInAnonymously()->idToken(); $this->assertIsString($idToken); @@ -306,8 +287,7 @@ public function revokeRefreshTokensAfterIdTokenVerification(): void } } - #[Test] - public function verifyIdTokenString(): void + public function testVerifyIdTokenString(): void { $result = $this->auth->signInAnonymously(); @@ -325,13 +305,12 @@ public function verifyIdTokenString(): void } } - #[Test] - public function createSessionCookie(): void + public function testCreateSessionCookie(): void { $signInResult = $this->auth->signInAnonymously(); $uid = $signInResult->firebaseUserId(); - assert($uid !== null); + $this->assertNotNull($uid); try { $idToken = $signInResult->idToken(); @@ -347,13 +326,12 @@ public function createSessionCookie(): void } } - #[Test] - public function createSessionCookieWithInvalidTTL(): void + public function testCreateSessionCookieWithInvalidTTL(): void { $signInResult = $this->auth->signInAnonymously(); $uid = $signInResult->firebaseUserId(); - assert($uid !== null); + $this->assertNotNull($uid); try { $idToken = $signInResult->idToken(); @@ -366,8 +344,7 @@ public function createSessionCookieWithInvalidTTL(): void } } - #[Test] - public function createSessionCookieWithInvalidIdToken(): void + public function testCreateSessionCookieWithInvalidIdToken(): void { $this->expectException(FailedToCreateSessionCookie::class); $this->expectExceptionMessageMatches('/INVALID_ID_TOKEN/'); @@ -375,8 +352,7 @@ public function createSessionCookieWithInvalidIdToken(): void $this->auth->createSessionCookie('invalid', 3600); } - #[Test] - public function verifySessionCookie(): void + public function testVerifySessionCookie(): void { $result = $this->auth->signInAnonymously(); @@ -396,8 +372,7 @@ public function verifySessionCookie(): void } } - #[Test] - public function verifySessionCookieAfterTokenRevocation(): void + public function testVerifySessionCookieAfterTokenRevocation(): void { $result = $this->auth->signInAnonymously(); @@ -425,8 +400,7 @@ public function verifySessionCookieAfterTokenRevocation(): void } } - #[Test] - public function disableAndEnableUser(): void + public function testDisableAndEnableUser(): void { $user = $this->auth->createUser([]); @@ -439,8 +413,7 @@ public function disableAndEnableUser(): void $this->auth->deleteUser($user->uid); } - #[Test] - public function getUser(): void + public function testGetUser(): void { $user = $this->auth->createUser([]); @@ -451,8 +424,7 @@ public function getUser(): void $this->auth->deleteUser($user->uid); } - #[Test] - public function getUsers(): void + public function testGetUsers(): void { $one = $this->auth->createAnonymousUser(); $two = $this->auth->createAnonymousUser(); @@ -469,8 +441,7 @@ public function getUsers(): void } } - #[Test] - public function getNonExistingUser(): void + public function testGetNonExistingUser(): void { $user = $this->auth->createUser([]); $this->auth->deleteUser($user->uid); @@ -479,8 +450,7 @@ public function getNonExistingUser(): void $this->auth->getUser($user->uid); } - #[Test] - public function getUserByNonExistingEmail(): void + public function testGetUserByNonExistingEmail(): void { $user = $this->auth->createUser([ 'email' => $email = self::randomEmail(__FUNCTION__), @@ -491,8 +461,7 @@ public function getUserByNonExistingEmail(): void $this->auth->getUserByEmail($email); } - #[Test] - public function getUserByPhoneNumber(): void + public function testGetUserByPhoneNumber(): void { $phoneNumber = '+1234567'.random_int(1000, 9999); @@ -507,8 +476,7 @@ public function getUserByPhoneNumber(): void $this->auth->deleteUser($user->uid); } - #[Test] - public function getUserByNonExistingPhoneNumber(): void + public function testGetUserByNonExistingPhoneNumber(): void { $phoneNumber = '+1234567'.random_int(1000, 9999); @@ -521,8 +489,7 @@ public function getUserByNonExistingPhoneNumber(): void $this->auth->getUserByPhoneNumber($phoneNumber); } - #[Test] - public function getUserByProviderUid(): void + public function testGetUserByProviderUid(): void { if (Util::authEmulatorHost() === null) { $this->markTestSkipped('Getting user by provider UID can only be tested with the Firebase emulator.'); @@ -549,8 +516,7 @@ public function getUserByProviderUid(): void } - #[Test] - public function getUserByNonExistingProviderUid(): void + public function testGetUserByNonExistingProviderUid(): void { if (Util::authEmulatorHost() === null) { $this->markTestSkipped('Getting user by provider UID can only be tested with the Firebase emulator.'); @@ -565,8 +531,7 @@ public function getUserByNonExistingProviderUid(): void $auth->getUserByProviderUid('phone', '+192837465'); } - #[Test] - public function createUser(): void + public function testCreateUser(): void { $uid = bin2hex(random_bytes(5)); $userRecord = $this->auth->createUser([ @@ -583,8 +548,7 @@ public function createUser(): void $this->auth->deleteUser($uid); } - #[Test] - public function deleteNonExistingUser(): void + public function testDeleteNonExistingUser(): void { $user = $this->auth->createUser([]); @@ -594,8 +558,7 @@ public function deleteNonExistingUser(): void $this->auth->deleteUser($user->uid); } - #[Test] - public function batchDeleteDisabledUsers(): void + public function testBatchDeleteDisabledUsers(): void { $enabledOne = $this->auth->createAnonymousUser(); $enabledTwo = $this->auth->createAnonymousUser(); @@ -612,8 +575,7 @@ public function batchDeleteDisabledUsers(): void $this->assertCount(2, $result->rawErrors()); } - #[Test] - public function batchForceDeleteUsers(): void + public function testBatchForceDeleteUsers(): void { $enabledOne = $this->auth->createAnonymousUser(); $enabledTwo = $this->auth->createAnonymousUser(); @@ -630,8 +592,7 @@ public function batchForceDeleteUsers(): void $this->assertEmpty($result->rawErrors()); } - #[Test] - public function setCustomUserClaims(): void + public function testSetCustomUserClaims(): void { $user = $this->auth->createAnonymousUser(); @@ -648,8 +609,7 @@ public function setCustomUserClaims(): void } } - #[Test] - public function unlinkProvider(): void + public function testUnlinkProvider(): void { $uid = self::randomString(__FUNCTION__); @@ -666,8 +626,7 @@ public function unlinkProvider(): void $this->auth->deleteUser($user->uid); } - #[Test] - public function verifyPasswordResetCode(): void + public function testVerifyPasswordResetCode(): void { $user = $this->createUserWithEmailAndPassword(); assert(is_string($user->email)); @@ -684,15 +643,13 @@ public function verifyPasswordResetCode(): void } } - #[Test] - public function verifyPasswordWithInvalidOobCode(): void + public function testVerifyPasswordWithInvalidOobCode(): void { $this->expectException(InvalidOobCode::class); $this->auth->verifyPasswordResetCode('invalid'); } - #[Test] - public function confirmPasswordReset(): void + public function testConfirmPasswordReset(): void { $user = $this->createUserWithEmailAndPassword(); @@ -709,8 +666,7 @@ public function confirmPasswordReset(): void } } - #[Test] - public function confirmPasswordResetAndInvalidateRefreshTokens(): void + public function testConfirmPasswordResetAndInvalidateRefreshTokens(): void { $user = $this->createUserWithEmailAndPassword(); assert(is_string($user->email)); @@ -732,15 +688,13 @@ public function confirmPasswordResetAndInvalidateRefreshTokens(): void } } - #[Test] - public function confirmPasswordResetWithInvalidOobCode(): void + public function testConfirmPasswordResetWithInvalidOobCode(): void { $this->expectException(InvalidOobCode::class); $this->auth->confirmPasswordReset('invalid', 'newPassword123'); } - #[Test] - public function signInAsUser(): void + public function testSignInAsUser(): void { $user = $this->auth->createAnonymousUser(); @@ -754,8 +708,7 @@ public function signInAsUser(): void $this->auth->deleteUser($user->uid); } - #[Test] - public function signInWithCustomToken(): void + public function testSignInWithCustomToken(): void { $user = $this->auth->createAnonymousUser(); @@ -771,8 +724,7 @@ public function signInWithCustomToken(): void $this->auth->deleteUser($user->uid); } - #[Test] - public function signInWithRefreshToken(): void + public function testSignInWithRefreshToken(): void { $user = $this->auth->createAnonymousUser(); @@ -790,8 +742,7 @@ public function signInWithRefreshToken(): void $this->auth->deleteUser($user->uid); } - #[Test] - public function signInWithEmailAndPassword(): void + public function testSignInWithEmailAndPassword(): void { $email = self::randomEmail(__FUNCTION__); $password = 'my-perfect-password'; @@ -808,8 +759,7 @@ public function signInWithEmailAndPassword(): void $this->auth->deleteUser($user->uid); } - #[Test] - public function signInWithEmailAndOobCode(): void + public function testSignInWithEmailAndOobCode(): void { $email = self::randomEmail(__FUNCTION__); $password = 'my-perfect-password'; @@ -830,8 +780,7 @@ public function signInWithEmailAndOobCode(): void $this->auth->deleteUser($user->uid); } - #[Test] - public function signInAnonymously(): void + public function testSignInAnonymously(): void { $result = $this->auth->signInAnonymously(); @@ -859,17 +808,15 @@ public function signInAnonymously(): void $this->auth->deleteUser($uid); } - #[Test] - public function signInWithIdpAccessToken(): void + public function testSignInWithIdpAccessToken(): void { // I don't know how to retrieve a current user access token programmatically, so we'll // test the failure case only here $this->expectException(FailedToSignIn::class); - $this->auth->signInWithIdpAccessToken('google.com', 'invalid', Utils::uriFor('http://localhost')); + $this->auth->signInWithIdpAccessToken('google.com', 'invalid'); } - #[Test] - public function signInWithIdpIdToken(): void + public function testSignInWithIdpIdToken(): void { // I don't know how to retrieve a current user access token programmatically, so we'll // test the failure case only here @@ -877,8 +824,7 @@ public function signInWithIdpIdToken(): void $this->auth->signInWithIdpIdToken('google.com', 'invalid', 'http://localhost'); } - #[Test] - public function removeEmailFromUser(): void + public function testRemoveEmailFromUser(): void { $user = $this->createUserWithEmailAndPassword(); @@ -896,8 +842,7 @@ public function removeEmailFromUser(): void } } - #[Test] - public function verifyIdTokenAcceptsResultFromParseToken(): void + public function testVerifyIdTokenAcceptsResultFromParseToken(): void { $signInResult = $this->auth->signInAnonymously(); $uid = $signInResult->firebaseUserId(); @@ -917,8 +862,7 @@ public function verifyIdTokenAcceptsResultFromParseToken(): void } } - #[Test] - public function itDownloadsOnlyAsManyAccountsAsItIsSupposedTo(): void + public function testItDownloadsOnlyAsManyAccountsAsItIsSupposedTo(): void { // Make sure we have at least two users present $first = $this->auth->createAnonymousUser(); diff --git a/tests/Integration/Database/AuthVariableOverrideTest.php b/tests/Integration/Database/AuthVariableOverrideTest.php index 097138b87..9803eaf41 100644 --- a/tests/Integration/Database/AuthVariableOverrideTest.php +++ b/tests/Integration/Database/AuthVariableOverrideTest.php @@ -10,7 +10,6 @@ use Kreait\Firebase\Exception\Database\PermissionDenied; use Kreait\Firebase\Tests\Integration\DatabaseTestCase; use PHPUnit\Framework\Attributes\Group; -use PHPUnit\Framework\Attributes\Test; use function assert; use function is_string; @@ -35,8 +34,7 @@ protected function tearDown(): void parent::tearDown(); } - #[Test] - public function itCanAccessAReferenceThatBelongsToTheSameUser(): void + public function testItCanAccessAReferenceThatBelongsToTheSameUser(): void { $uid = $this->auth->signInAnonymously()->firebaseUserId(); assert(is_string($uid)); @@ -56,8 +54,7 @@ public function itCanAccessAReferenceThatBelongsToTheSameUser(): void } } - #[Test] - public function itCanNotSetTheValueOfAReferenceIfItIsOnlyAllowedToRead(): void + public function testItCanNotSetTheValueOfAReferenceIfItIsOnlyAllowedToRead(): void { $uid = $this->auth->signInAnonymously()->firebaseUserId(); assert(is_string($uid)); @@ -74,8 +71,7 @@ public function itCanNotSetTheValueOfAReferenceIfItIsOnlyAllowedToRead(): void } } - #[Test] - public function itCanNotAccessAReferenceThatRequiresAnotherUser(): void + public function testItCanNotAccessAReferenceThatRequiresAnotherUser(): void { $uid = $this->auth->signInAnonymously()->firebaseUserId(); assert(is_string($uid)); @@ -92,8 +88,7 @@ public function itCanNotAccessAReferenceThatRequiresAnotherUser(): void } } - #[Test] - public function itCanAccessAPublicReferenceWhenAuthOverrideIsSetToBeUnauthenticated(): void + public function testItCanAccessAPublicReferenceWhenAuthOverrideIsSetToBeUnauthenticated(): void { $uid = $this->auth->signInAnonymously()->firebaseUserId(); assert(is_string($uid)); @@ -114,8 +109,7 @@ public function itCanAccessAPublicReferenceWhenAuthOverrideIsSetToBeUnauthentica } } - #[Test] - public function whenUnauthenticatedItCanNotAccessAReferenceThatRequiresAuthentication(): void + public function testWhenUnauthenticatedItCanNotAccessAReferenceThatRequiresAuthentication(): void { $uid = $this->auth->signInAnonymously()->firebaseUserId(); assert(is_string($uid)); @@ -148,7 +142,7 @@ private function publishRules(string $path, array $permissions): void private function database(): Database { // If the RTDB Url is not set, the database tests are already skipped - assert(self::$rtdbUrl !== null); + $this->assertNotNull(self::$rtdbUrl); return self::$factory ->withDatabaseUri(self::$rtdbUrl) @@ -162,7 +156,7 @@ private function database(): Database private function databaseWithAuthOverride(?array $override): Database { // If the RTDB Url is not set, the database tests are already skipped - assert(self::$rtdbUrl !== null); + $this->assertNotNull(self::$rtdbUrl); return self::$factory ->withDatabaseUri(self::$rtdbUrl) diff --git a/tests/Integration/Database/QueryTest.php b/tests/Integration/Database/QueryTest.php index 6c4fdbb38..cfdad0f5c 100644 --- a/tests/Integration/Database/QueryTest.php +++ b/tests/Integration/Database/QueryTest.php @@ -8,7 +8,6 @@ use Kreait\Firebase\Database\RuleSet; use Kreait\Firebase\Tests\Integration\DatabaseTestCase; use PHPUnit\Framework\Attributes\Group; -use PHPUnit\Framework\Attributes\Test; use function current; @@ -26,8 +25,7 @@ protected function setUp(): void $this->ref = self::$db->getReference(self::$refPrefix); } - #[Test] - public function limitToLast(): void + public function testLimitToLast(): void { $ref = $this->ref->getChild(__FUNCTION__); @@ -48,8 +46,7 @@ public function limitToLast(): void $this->assertSame(['key' => 3], current($value)); } - #[Test] - public function orderByChild(): void + public function testOrderByChild(): void { $ref = $this->ref->getChild(__FUNCTION__); diff --git a/tests/Integration/Database/ReferenceTest.php b/tests/Integration/Database/ReferenceTest.php index 971d0fd5d..d28c0c865 100644 --- a/tests/Integration/Database/ReferenceTest.php +++ b/tests/Integration/Database/ReferenceTest.php @@ -10,7 +10,6 @@ use Kreait\Firebase\Tests\Integration\DatabaseTestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; -use PHPUnit\Framework\Attributes\Test; /** * @internal @@ -27,8 +26,7 @@ protected function setUp(): void } #[DataProvider('validValues')] - #[Test] - public function setAndGet(string $key, mixed $value): void + public function testSetAndGet(string $key, mixed $value): void { $ref = $this->ref->getChild(__FUNCTION__.'/'.$key); $ref->set($value); @@ -36,8 +34,7 @@ public function setAndGet(string $key, mixed $value): void $this->assertSame($value, $ref->getValue()); } - #[Test] - public function update(): void + public function testUpdate(): void { $ref = $this->ref->getChild(__FUNCTION__); $ref->set([ @@ -59,8 +56,7 @@ public function update(): void $this->assertEqualsCanonicalizing($expected, $ref->getValue()); } - #[Test] - public function push(): void + public function testPush(): void { $ref = $this->ref->getChild(__FUNCTION__); $value = 'a value'; @@ -71,8 +67,7 @@ public function push(): void $this->assertSame($value, $newRef->getValue()); } - #[Test] - public function remove(): void + public function testRemove(): void { $ref = $this->ref->getChild(__FUNCTION__); @@ -86,8 +81,7 @@ public function remove(): void $this->assertEqualsCanonicalizing(['second' => 'value'], $ref->getValue()); } - #[Test] - public function removeChildren(): void + public function testRemoveChildren(): void { $ref = $this->ref->getChild(__FUNCTION__); @@ -113,8 +107,7 @@ public function removeChildren(): void ], $ref->getValue()); } - #[Test] - public function pushToGetKey(): void + public function testPushToGetKey(): void { $ref = $this->ref->getChild(__FUNCTION__); $key = $ref->push()->getKey(); @@ -123,8 +116,7 @@ public function pushToGetKey(): void $this->assertSame(0, $ref->getSnapshot()->numChildren()); } - #[Test] - public function setWithNullIsSameAsRemove(): void + public function testSetWithNullIsSameAsRemove(): void { $ref = $this->ref->getChild(__FUNCTION__); @@ -138,8 +130,7 @@ public function setWithNullIsSameAsRemove(): void $this->assertSame(0, $ref->getSnapshot()->numChildren()); } - #[Test] - public function setServerTimestamp(): void + public function testSetServerTimestamp(): void { $value = $this->ref->getChild(__FUNCTION__) ->push(['updatedAt' => Database::SERVER_TIMESTAMP]) @@ -154,8 +145,7 @@ public function setServerTimestamp(): void /** * @see https://github.com/kreait/firebase-php/issues/1031 */ - #[Test] - public function useNonLatinCharacters(): void + public function testUseNonLatinCharacters(): void { $ref = $this->ref->getChild(__FUNCTION__); diff --git a/tests/Integration/Database/RuleSetTest.php b/tests/Integration/Database/RuleSetTest.php index 285429aa7..f75a0d7dd 100644 --- a/tests/Integration/Database/RuleSetTest.php +++ b/tests/Integration/Database/RuleSetTest.php @@ -7,7 +7,6 @@ use Kreait\Firebase\Database\RuleSet; use Kreait\Firebase\Tests\Integration\DatabaseTestCase; use PHPUnit\Framework\Attributes\Group; -use PHPUnit\Framework\Attributes\Test; /** * @internal @@ -16,8 +15,7 @@ #[Group('emulator')] final class RuleSetTest extends DatabaseTestCase { - #[Test] - public function default(): void + public function testDefault(): void { $ruleSet = RuleSet::default(); @@ -26,8 +24,7 @@ public function default(): void $this->assertEqualsCanonicalizing($ruleSet->getRules(), self::$db->getRuleSet()->getRules()); } - #[Test] - public function public(): void + public function testPublic(): void { $ruleSet = RuleSet::public(); @@ -36,8 +33,7 @@ public function public(): void $this->assertEqualsCanonicalizing($ruleSet->getRules(), self::$db->getRuleSet()->getRules()); } - #[Test] - public function private(): void + public function testPrivate(): void { $ruleSet = RuleSet::private(); @@ -49,8 +45,7 @@ public function private(): void /** * @see https://github.com/kreait/firebase-php/issues/705 */ - #[Test] - public function rulesAreProperlyEncoded(): void + public function testRulesAreProperlyEncoded(): void { $rules = RuleSet::private()->getRules(); $rules['rules'][self::$refPrefix.__FUNCTION__] = [ diff --git a/tests/Integration/Database/TransactionTest.php b/tests/Integration/Database/TransactionTest.php index 29663df00..8681ae337 100644 --- a/tests/Integration/Database/TransactionTest.php +++ b/tests/Integration/Database/TransactionTest.php @@ -9,7 +9,6 @@ use Kreait\Firebase\Exception\Database\TransactionFailed; use Kreait\Firebase\Tests\Integration\DatabaseTestCase; use PHPUnit\Framework\Attributes\Group; -use PHPUnit\Framework\Attributes\Test; /** * @internal @@ -25,8 +24,7 @@ protected function setUp(): void $this->ref = self::$db->getReference(self::$refPrefix); } - #[Test] - public function aValueCanBeWritten(): void + public function testAValueCanBeWritten(): void { $ref = $this->ref->getChild(__FUNCTION__); @@ -39,8 +37,7 @@ public function aValueCanBeWritten(): void $this->assertSame('new value', $ref->getValue()); } - #[Test] - public function aTransactionPreventsAChangeWhenTheRemoteHasChanged(): void + public function testATransactionPreventsAChangeWhenTheRemoteHasChanged(): void { $firstRef = $this->ref->getChild(__FUNCTION__); $firstRef->set(['key' => 'value']); @@ -59,8 +56,7 @@ public function aTransactionPreventsAChangeWhenTheRemoteHasChanged(): void }); } - #[Test] - public function aTransactionKeepsTrackOfMultipleReferences(): void + public function testATransactionKeepsTrackOfMultipleReferences(): void { $firstRef = $this->ref->getChild(__FUNCTION__.'_first'); $secondRef = $this->ref->getChild(__FUNCTION__.'_second'); @@ -96,8 +92,7 @@ public function aTransactionKeepsTrackOfMultipleReferences(): void }); } - #[Test] - public function aValueCanBeDeleted(): void + public function testAValueCanBeDeleted(): void { $ref = $this->ref->getChild(__FUNCTION__); $ref->set('value'); @@ -112,8 +107,7 @@ public function aValueCanBeDeleted(): void }); } - #[Test] - public function aTransactionPreventsADeletionWhenTheRemoteHasChanged(): void + public function testATransactionPreventsADeletionWhenTheRemoteHasChanged(): void { $ref = $this->ref->getChild(__FUNCTION__); $ref->set(['key' => 'value']); diff --git a/tests/Integration/DatabaseTestCase.php b/tests/Integration/DatabaseTestCase.php index f1053f40b..eccf8add7 100644 --- a/tests/Integration/DatabaseTestCase.php +++ b/tests/Integration/DatabaseTestCase.php @@ -22,6 +22,7 @@ abstract class DatabaseTestCase extends IntegrationTestCase protected static Client $apiClient; + #[\Override] public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); diff --git a/tests/Integration/Factory/FirestoreTest.php b/tests/Integration/Factory/FirestoreTest.php index 3affef32b..7a5c1296a 100644 --- a/tests/Integration/Factory/FirestoreTest.php +++ b/tests/Integration/Factory/FirestoreTest.php @@ -7,7 +7,6 @@ use Exception; use Kreait\Firebase\Tests\IntegrationTestCase; use Kreait\Firebase\Util; -use PHPUnit\Framework\Attributes\Test; /** * @internal @@ -18,8 +17,7 @@ final class FirestoreTest extends IntegrationTestCase * If we write a document into the instance created without an explicit database name, * we should be able to read it from the instance created with an explicit database name. */ - #[Test] - public function itUsesTheDefaultDatabaseByDefault(): void + public function testItUsesTheDefaultDatabaseByDefault(): void { // @see https://github.com/grpc/grpc/issues/38184 // @see https://github.com/googleapis/gax-php/issues/584 @@ -42,7 +40,6 @@ public function itUsesTheDefaultDatabaseByDefault(): void } } - #[Test] public function testItCannotConnectToAnUnknownDatabase(): void { // @see https://github.com/grpc/grpc/issues/38184 @@ -61,8 +58,7 @@ public function testItCannotConnectToAnUnknownDatabase(): void $database->collection('foo')->document(__FUNCTION__)->create(); } - #[Test] - public function itCanConnectToACustomDatabase(): void + public function testItCanConnectToACustomDatabase(): void { $collection = __FUNCTION__; $documentName = __FUNCTION__.self::randomString(); @@ -77,27 +73,7 @@ public function itCanConnectToACustomDatabase(): void } } - /** - * @deprecated 7.19.0 - */ - #[Test] - public function itSupportsOverridingTheDefaultFirestoreDatabase(): void - { - $collection = __FUNCTION__; - $documentName = __FUNCTION__.self::randomString(); - - $database = self::$factory->withFirestoreDatabase($this->customDBName())->createFirestore()->database(); - - try { - $database->collection($collection)->document($documentName)->create(); - $this->assertTrue($database->collection($collection)->document($documentName)->snapshot()->exists()); - } finally { - $database->collection($collection)->document($documentName)->delete(); - } - } - - #[Test] - public function itSupportsAdditionalFirestoreConfig(): void + public function testItSupportsAdditionalFirestoreConfig(): void { $collection = __FUNCTION__; $documentName = __FUNCTION__.self::randomString(); diff --git a/tests/Integration/FactoryTest.php b/tests/Integration/FactoryTest.php index ad92976e3..cf1349c88 100644 --- a/tests/Integration/FactoryTest.php +++ b/tests/Integration/FactoryTest.php @@ -7,18 +7,14 @@ use Closure; use Kreait\Firebase\Http\HttpClientOptions; use Kreait\Firebase\Tests\IntegrationTestCase; -use PHPUnit\Framework\Attributes\Test; use Psr\Http\Message\RequestInterface; -use function assert; - /** * @internal */ final class FactoryTest extends IntegrationTestCase { - #[Test] - public function itSupportsExtendingTheHttpClientConfig(): void + public function testItSupportsExtendingTheHttpClientConfig(): void { if (self::$rtdbUrl === null) { $this->markTestSkipped('The HTTP client Config extension test requires a database URL'); @@ -34,7 +30,7 @@ public function itSupportsExtendingTheHttpClientConfig(): void ->createDatabase() ; - assert(file_exists($sink) === false); + $this->assertFileDoesNotExist($sink); // We're only interested in the file, not the actual result $db->getReference(__FUNCTION__)->shallow()->getSnapshot(); @@ -46,8 +42,7 @@ public function itSupportsExtendingTheHttpClientConfig(): void } } - #[Test] - public function itSupportsAddingAdditionalHttpClientMiddlewares(): void + public function testItSupportsAddingAdditionalHttpClientMiddlewares(): void { if (self::$rtdbUrl === null) { $this->markTestSkipped('The HTTP client middleware extension test requires a database URL'); diff --git a/tests/Integration/Http/HttpClientOptionsTest.php b/tests/Integration/Http/HttpClientOptionsTest.php index 7be216a29..0d82e48a5 100644 --- a/tests/Integration/Http/HttpClientOptionsTest.php +++ b/tests/Integration/Http/HttpClientOptionsTest.php @@ -8,7 +8,6 @@ use Kreait\Firebase\Contract\Database; use Kreait\Firebase\Http\HttpClientOptions; use Kreait\Firebase\Tests\IntegrationTestCase; -use PHPUnit\Framework\Attributes\Test; use Psr\Http\Message\RequestInterface; /** @@ -16,8 +15,7 @@ */ final class HttpClientOptionsTest extends IntegrationTestCase { - #[Test] - public function itWorksWithAFunctionMiddleware(): void + public function testItWorksWithAFunctionMiddleware(): void { $check = false; @@ -37,8 +35,7 @@ public function itWorksWithAFunctionMiddleware(): void $this->assertTrue($check); } - #[Test] - public function itWorksWithAFunctionMiddlewareInsideAnArrayDefinition(): void + public function testItWorksWithAFunctionMiddlewareInsideAnArrayDefinition(): void { $check = false; @@ -63,8 +60,7 @@ public function itWorksWithAFunctionMiddlewareInsideAnArrayDefinition(): void $this->assertTrue($check); } - #[Test] - public function itWorksWithAMiddlewareClassWithAStaticMethod(): void + public function testItWorksWithAMiddlewareClassWithAStaticMethod(): void { $middleware = new class { public static bool $wasInvoked = false; @@ -93,8 +89,7 @@ public static function handle(callable $handler): Closure $this->assertTrue($middleware::$wasInvoked); } - #[Test] - public function itWorksWithAnInvokableMiddleware(): void + public function testItWorksWithAnInvokableMiddleware(): void { $middleware = new class { public bool $wasInvoked = false; diff --git a/tests/Integration/HttpLoggingTest.php b/tests/Integration/HttpLoggingTest.php index 898c69274..c66d2e777 100644 --- a/tests/Integration/HttpLoggingTest.php +++ b/tests/Integration/HttpLoggingTest.php @@ -10,7 +10,6 @@ use Kreait\Firebase\Exception\Auth\UserNotFound; use Kreait\Firebase\Http\HttpClientOptions; use Kreait\Firebase\Tests\IntegrationTestCase; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; @@ -53,8 +52,7 @@ protected function setUp(): void ->createAuth(); } - #[Test] - public function itLogsSuccesses(): void + public function testItLogsSuccesses(): void { $user = $this->auth->createAnonymousUser(); @@ -66,8 +64,7 @@ public function itLogsSuccesses(): void } } - #[Test] - public function itLogsFailures(): void + public function testItLogsFailures(): void { $this->debugLogger->expects($this->atLeastOnce())->method('log'); @@ -78,8 +75,7 @@ public function itLogsFailures(): void } } - #[Test] - public function itUsesAHttpDebugLogger(): void + public function testItUsesAHttpDebugLogger(): void { $user = $this->auth->createAnonymousUser(); diff --git a/tests/Integration/Messaging/AppInstanceTest.php b/tests/Integration/Messaging/AppInstanceTest.php index 3b7ea3879..912f1545f 100644 --- a/tests/Integration/Messaging/AppInstanceTest.php +++ b/tests/Integration/Messaging/AppInstanceTest.php @@ -8,7 +8,6 @@ use Kreait\Firebase\Messaging\AppInstance; use Kreait\Firebase\Messaging\RegistrationToken; use Kreait\Firebase\Tests\IntegrationTestCase; -use PHPUnit\Framework\Attributes\Test; use function bin2hex; use function random_bytes; @@ -25,8 +24,7 @@ protected function setUp(): void $this->messaging = self::$factory->createMessaging(); } - #[Test] - public function itIsSubscribedToTopics(): void + public function testItIsSubscribedToTopics(): void { $token = $this->getTestRegistrationToken(); diff --git a/tests/Integration/MessagingTest.php b/tests/Integration/MessagingTest.php index 8ec1f1342..b42e3274d 100644 --- a/tests/Integration/MessagingTest.php +++ b/tests/Integration/MessagingTest.php @@ -16,7 +16,6 @@ use Kreait\Firebase\Tests\IntegrationTestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; -use PHPUnit\Framework\Attributes\Test; /** * @internal @@ -107,8 +106,7 @@ public static function createFullMessageData(): array ]; } - #[Test] - public function sendMessage(): void + public function testSendMessage(): void { $message = self::createFullMessageData(); $message['condition'] = "'dogs' in topics || 'cats' in topics"; @@ -118,8 +116,7 @@ public function sendMessage(): void $this->assertArrayHasKey('name', $result); } - #[Test] - public function sendRawMessage(): void + public function testSendRawMessage(): void { $data = self::createFullMessageData(); $data['condition'] = "'dogs' in topics || 'cats' in topics"; @@ -132,8 +129,7 @@ public function sendRawMessage(): void /** * @see https://github.com/kreait/firebase-php/issues/591 */ - #[Test] - public function sendingAMessageWithEmptyMessageDataShouldNotFail(): void + public function testSendingAMessageWithEmptyMessageDataShouldNotFail(): void { $message = CloudMessage::new() ->withData([]) @@ -151,7 +147,6 @@ public function sendingAMessageWithEmptyMessageDataShouldNotFail(): void * @param non-empty-string $keyword */ #[DataProvider('reservedKeywordsThatStillAreAccepted')] - #[Test] public function sendMessageWithReservedKeywordInMessageDataThatIsStillAccepted(string $keyword): void { $message = CloudMessage::new() @@ -174,8 +169,7 @@ public static function reservedKeywordsThatStillAreAccepted(): Iterator yield 'notification' => ['notification']; } - #[Test] - public function validateValidMessage(): void + public function testValidateValidMessage(): void { $message = self::createFullMessageData(); $message['condition'] = "'dogs' in topics || 'cats' in topics"; @@ -185,8 +179,7 @@ public function validateValidMessage(): void $this->assertArrayHasKey('name', $result); } - #[Test] - public function validateInvalidMessage(): void + public function testValidateInvalidMessage(): void { $message = self::createFullMessageData(); $message['token'] = 'invalid-and-non-existing-device-token'; @@ -195,8 +188,7 @@ public function validateInvalidMessage(): void $this->messaging->validate($message); } - #[Test] - public function sendMulticastWithValidAndInvalidTarget(): void + public function testSendMulticastWithValidAndInvalidTarget(): void { $message = CloudMessage::fromArray([]); $tokens = [ @@ -227,8 +219,7 @@ public function sendMulticastWithValidAndInvalidTarget(): void /** * @see https://github.com/kreait/firebase-php/issues/436 */ - #[Test] - public function sendMulticastMessageToTwoInvalidRecipients(): void + public function testSendMulticastMessageToTwoInvalidRecipients(): void { $message = CloudMessage::fromArray([]); $tokens = [ @@ -251,16 +242,14 @@ public function sendMulticastMessageToTwoInvalidRecipients(): void /** * @see https://github.com/kreait/firebase-php/issues/317 */ - #[Test] - public function sendMulticastMessageToOneRecipientOnly(): void + public function testSendMulticastMessageToOneRecipientOnly(): void { $report = $this->messaging->sendMulticast(CloudMessage::new(), [$this->getTestRegistrationToken()]); $this->assertCount(1, $report->successes()); } - #[Test] - public function sendMessageToDifferentTargets(): void + public function testSendMessageToDifferentTargets(): void { $token = $this->getTestRegistrationToken(); $topic = __FUNCTION__; @@ -285,8 +274,7 @@ public function sendMessageToDifferentTargets(): void $this->assertCount(2, $report->failures()); } - #[Test] - public function validateRegistrationTokens(): void + public function testValidateRegistrationTokens(): void { $tokens = [ $valid = $this->getTestRegistrationToken(), @@ -300,8 +288,7 @@ public function validateRegistrationTokens(): void $this->assertSame($invalid, $result['invalid'][0]); } - #[Test] - public function subscribeToTopic(): void + public function testSubscribeToTopic(): void { $token = $this->getTestRegistrationToken(); $topicName = self::randomString(__FUNCTION__); @@ -315,8 +302,7 @@ public function subscribeToTopic(): void } } - #[Test] - public function subscribeToTopics(): void + public function testSubscribeToTopics(): void { $token = $this->getTestRegistrationToken(); @@ -335,8 +321,7 @@ public function subscribeToTopics(): void } } - #[Test] - public function unsubscribeFromTopic(): void + public function testUnsubscribeFromTopic(): void { $token = $this->getTestRegistrationToken(); $topicName = self::randomString(__FUNCTION__); @@ -347,8 +332,7 @@ public function unsubscribeFromTopic(): void ], $this->messaging->unsubscribeFromTopic($topicName, $token)); } - #[Test] - public function unsubscribeFromTopics(): void + public function testUnsubscribeFromTopics(): void { $token = $this->getTestRegistrationToken(); @@ -363,8 +347,7 @@ public function unsubscribeFromTopics(): void ], $this->messaging->unsubscribeFromTopics($topics, $token)); } - #[Test] - public function getAppInstance(): void + public function testGetAppInstance(): void { $token = $this->getTestRegistrationToken(); $appInstance = $this->messaging->getAppInstance($token); @@ -372,15 +355,13 @@ public function getAppInstance(): void $this->assertSame($token, $appInstance->registrationToken()->value()); } - #[Test] - public function getAppInstanceWithInvalidToken(): void + public function testGetAppInstanceWithInvalidToken(): void { $this->expectException(InvalidArgument::class); $this->messaging->getAppInstance('foo'); } - #[Test] - public function sendMessageToUnknownToken(): void + public function testSendMessageToUnknownToken(): void { $this->expectException(NotFound::class); @@ -393,8 +374,7 @@ public function sendMessageToUnknownToken(): void } } - #[Test] - public function getAppInstanceForUnknownToken(): void + public function testGetAppInstanceForUnknownToken(): void { $this->expectException(NotFound::class); @@ -407,9 +387,8 @@ public function getAppInstanceForUnknownToken(): void } } - #[Test] #[DoesNotPerformAssertions] - public function sendWebPushNotificationWithAnEmptyTitle(): void + public function testSendWebPushNotificationWithAnEmptyTitle(): void { $message = CloudMessage::new() ->withWebPushConfig(WebPushConfig::fromArray([ diff --git a/tests/Integration/RemoteConfigTest.php b/tests/Integration/RemoteConfigTest.php index abfe1360c..0273c4577 100644 --- a/tests/Integration/RemoteConfigTest.php +++ b/tests/Integration/RemoteConfigTest.php @@ -19,7 +19,6 @@ use Kreait\Firebase\RemoteConfig\VersionNumber; use Kreait\Firebase\Tests\IntegrationTestCase; use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; -use PHPUnit\Framework\Attributes\Test; use Throwable; /** @@ -27,10 +26,7 @@ */ final class RemoteConfigTest extends IntegrationTestCase { - /** - * @var string - */ - private const TEMPLATE_CONFIG = <<<'CONFIG' + private const string TEMPLATE_CONFIG = <<<'CONFIG' { "conditions": [ { @@ -150,8 +146,7 @@ protected function setUp(): void $this->template = Template::fromArray(Json::decode(self::TEMPLATE_CONFIG, true)); } - #[Test] - public function forcePublishAndGet(): void + public function testForcePublishAndGet(): void { $this->remoteConfig->publish($this->template); @@ -175,44 +170,40 @@ public function forcePublishAndGet(): void $this->assertSame(UpdateOrigin::REST_API, (string) $version?->updateOrigin()); } - #[Test] - public function getTemplateWithVersion(): void + public function testGetTemplateWithVersion(): void { $template = $this->remoteConfig->get(); $version = $template->version(); - assert($version !== null); + $this->assertInstanceOf(Version::class, $version); $check = $this->remoteConfig->get($version); $this->assertTrue($version->versionNumber()->equalsTo($check->version()?->versionNumber())); } - #[Test] - public function getTemplateWithVersionNumber(): void + public function testGetTemplateWithVersionNumber(): void { $template = $this->remoteConfig->get(); $version = $template->version(); - assert($version !== null); + $this->assertInstanceOf(Version::class, $version); $check = $this->remoteConfig->get($version->versionNumber()); $this->assertTrue($version->versionNumber()->equalsTo($check->version()?->versionNumber())); } - #[Test] - public function getTemplateWithVersionNumberString(): void + public function testGetTemplateWithVersionNumberString(): void { $template = $this->remoteConfig->get(); $version = $template->version(); - assert($version !== null); + $this->assertInstanceOf(Version::class, $version); $check = $this->remoteConfig->get((string) $version->versionNumber()); $this->assertTrue($version->versionNumber()->equalsTo($check->version()?->versionNumber())); } - #[Test] - public function publishOutdatedConfig(): void + public function testPublishOutdatedConfig(): void { $this->remoteConfig->publish($this->template); @@ -227,15 +218,13 @@ public function publishOutdatedConfig(): void } #[DoesNotPerformAssertions] - #[Test] - public function validateValidTemplate(): void + public function testValidateValidTemplate(): void { // This should not throw an exception $this->remoteConfig->validate($this->template); } - #[Test] - public function validateInvalidTemplate(): void + public function testValidateInvalidTemplate(): void { $template = $this->templateWithTooManyParameters(); @@ -243,8 +232,7 @@ public function validateInvalidTemplate(): void $this->remoteConfig->validate($template); } - #[Test] - public function publishInvalidTemplate(): void + public function testPublishInvalidTemplate(): void { $version = $this->remoteConfig->get()->version(); @@ -275,8 +263,7 @@ public function publishInvalidTemplate(): void ); } - #[Test] - public function rollback(): void + public function testRollback(): void { $initialVersion = $this->remoteConfig->get()->version(); @@ -324,8 +311,7 @@ public function rollback(): void $this->assertTrue($rollbackSource->equalsTo($targetVersionNumber)); } - #[Test] - public function listVersionsWithoutFilters(): void + public function testListVersionsWithoutFilters(): void { $count = 0; // We only need to know that the first returned value is a version, @@ -338,8 +324,7 @@ public function listVersionsWithoutFilters(): void $this->assertSame(1, $count); } - #[Test] - public function findVersionsWithFilters(): void + public function testFindVersionsWithFilters(): void { $currentVersion = $this->remoteConfig->get()->version(); @@ -371,8 +356,7 @@ public function findVersionsWithFilters(): void $this->assertLessThanOrEqual($limit, $counter); } - #[Test] - public function getVersion(): void + public function testGetVersion(): void { $currentVersion = $this->remoteConfig->get()->version(); @@ -387,8 +371,7 @@ public function getVersion(): void $this->assertTrue($check->versionNumber()->equalsTo($currentVersionNumber)); } - #[Test] - public function getNonExistingVersion(): void + public function testGetNonExistingVersion(): void { $currentVersion = $this->remoteConfig->get()->version(); @@ -409,8 +392,7 @@ public function getNonExistingVersion(): void } #[DoesNotPerformAssertions] - #[Test] - public function validateEmptyTemplate(): void + public function testValidateEmptyTemplate(): void { // This should not throw an exception $this->remoteConfig->validate(Template::new()); diff --git a/tests/Integration/Request/CreateUserTest.php b/tests/Integration/Request/CreateUserTest.php index 03ee892bf..186a2d4ad 100644 --- a/tests/Integration/Request/CreateUserTest.php +++ b/tests/Integration/Request/CreateUserTest.php @@ -7,7 +7,6 @@ use Kreait\Firebase\Contract\Auth; use Kreait\Firebase\Request\CreateUser; use Kreait\Firebase\Tests\IntegrationTestCase; -use PHPUnit\Framework\Attributes\Test; use function bin2hex; use function random_bytes; @@ -25,8 +24,7 @@ protected function setUp(): void $this->auth = self::$factory->createAuth(); } - #[Test] - public function createUser(): void + public function testCreateUser(): void { $request = CreateUser::new() ->withUid($uid = bin2hex(random_bytes(5))) @@ -51,8 +49,7 @@ public function createUser(): void $this->auth->deleteUser($user->uid); } - #[Test] - public function createUserWithoutEmailButMarkTheEmailAsUnverified(): void + public function testCreateUserWithoutEmailButMarkTheEmailAsUnverified(): void { $request = CreateUser::new() ->withUid($uid = bin2hex(random_bytes(5))) diff --git a/tests/Integration/Request/UpdateUserTest.php b/tests/Integration/Request/UpdateUserTest.php index bf94895eb..7f8127c7a 100644 --- a/tests/Integration/Request/UpdateUserTest.php +++ b/tests/Integration/Request/UpdateUserTest.php @@ -11,7 +11,6 @@ use Kreait\Firebase\Request\UpdateUser; use Kreait\Firebase\Tests\IntegrationTestCase; use Kreait\Firebase\Util\DT; -use PHPUnit\Framework\Attributes\Test; use function bin2hex; use function random_bytes; @@ -29,8 +28,7 @@ protected function setUp(): void $this->auth = self::$factory->createAuth(); } - #[Test] - public function removePhotoUrl(): void + public function testRemovePhotoUrl(): void { $photoUrl = 'https://example.com/a_photo.jpg'; @@ -44,8 +42,7 @@ public function removePhotoUrl(): void $this->auth->deleteUser($user->uid); } - #[Test] - public function removeDisplayName(): void + public function testRemoveDisplayName(): void { $displayName = 'A display name'; @@ -59,8 +56,7 @@ public function removeDisplayName(): void $this->auth->deleteUser($user->uid); } - #[Test] - public function markNonExistingEmailAsVerified(): void + public function testMarkNonExistingEmailAsVerified(): void { $user = $this->auth->createUser( CreateUser::new() @@ -79,8 +75,7 @@ public function markNonExistingEmailAsVerified(): void $this->auth->deleteUser($updatedUser->uid); } - #[Test] - public function markExistingUnverifiedEmailAsVerified(): void + public function testMarkExistingUnverifiedEmailAsVerified(): void { $user = $this->auth->createUser( CreateUser::new() @@ -99,8 +94,7 @@ public function markExistingUnverifiedEmailAsVerified(): void $this->auth->deleteUser($updatedUser->uid); } - #[Test] - public function markExistingVerifiedEmailAsUnverified(): void + public function testMarkExistingVerifiedEmailAsUnverified(): void { $user = $this->auth->createUser( CreateUser::new() @@ -119,8 +113,7 @@ public function markExistingVerifiedEmailAsUnverified(): void $this->auth->deleteUser($updatedUser->uid); } - #[Test] - public function updateUserWithCustomAttributes(): void + public function testUpdateUserWithCustomAttributes(): void { $request = CreateUser::new() ->withUid($uid = bin2hex(random_bytes(5))) @@ -149,8 +142,7 @@ public function updateUserWithCustomAttributes(): void $this->auth->deleteUser($uid); } - #[Test] - public function removePhoneNumber(): void + public function testRemovePhoneNumber(): void { $user = $this->auth->createUser( CreateUser::new() @@ -174,8 +166,7 @@ public function removePhoneNumber(): void /** * @see https://github.com/kreait/firebase-php/issues/196 */ - #[Test] - public function reEnable(): void + public function testReEnable(): void { $user = $this->auth->createUser([ 'disabled' => true, @@ -190,8 +181,7 @@ public function reEnable(): void $this->auth->deleteUser($user->uid); } - #[Test] - public function timeOfLastPasswordUpdateIsIncluded(): void + public function testTimeOfLastPasswordUpdateIsIncluded(): void { $user = $this->auth->createAnonymousUser(); @@ -206,8 +196,7 @@ public function timeOfLastPasswordUpdateIsIncluded(): void } } - #[Test] - public function setMultiFactor(): void + public function testSetMultiFactor(): void { $user = $this->auth->createUser( CreateUser::new()->withVerifiedEmail(self::randomEmail(__FUNCTION__)), @@ -235,8 +224,7 @@ public function setMultiFactor(): void } } - #[Test] - public function resetMultiFactor(): void + public function testResetMultiFactor(): void { $user = $this->auth->createUser( CreateUser::new()->withVerifiedEmail(self::randomEmail(__FUNCTION__)), diff --git a/tests/Integration/TenantAwareAuthTest.php b/tests/Integration/TenantAwareAuthTest.php index d1b7b886c..4c075ccb5 100644 --- a/tests/Integration/TenantAwareAuthTest.php +++ b/tests/Integration/TenantAwareAuthTest.php @@ -5,7 +5,6 @@ namespace Kreait\Firebase\Tests\Integration; use PHPUnit\Framework\Attributes\Group; -use PHPUnit\Framework\Attributes\Test; /** * @internal @@ -13,6 +12,7 @@ #[Group('emulator')] final class TenantAwareAuthTest extends AuthTestCase { + #[\Override] protected function setUp(): void { parent::setUp(); @@ -27,8 +27,7 @@ protected function setUp(): void ; } - #[Test] - public function newUsersAreScopedToATenant(): void + public function testNewUsersAreScopedToATenant(): void { $user = $this->auth->createUserWithEmailAndPassword( self::randomEmail(__FUNCTION__), @@ -42,8 +41,7 @@ public function newUsersAreScopedToATenant(): void } } - #[Test] - public function customTokensIncludeTheTenant(): void + public function testCustomTokensIncludeTheTenant(): void { $user = $this->auth->createAnonymousUser(); @@ -58,8 +56,7 @@ public function customTokensIncludeTheTenant(): void } } - #[Test] - public function itCanSignInAnonymously(): void + public function testItCanSignInAnonymously(): void { $user = $this->auth->createAnonymousUser(); $result = $this->auth->signInAsUser($user); @@ -71,8 +68,7 @@ public function itCanSignInAnonymously(): void } } - #[Test] - public function itCanSignInWithACustomToken(): void + public function testItCanSignInWithACustomToken(): void { $user = $this->auth->createAnonymousUser(); $result = $this->auth->signInAsUser($user); diff --git a/tests/Unit/AppCheck/AppCheckTokenOptionsTest.php b/tests/Unit/AppCheck/AppCheckTokenOptionsTest.php index 0e7809850..6076faf42 100644 --- a/tests/Unit/AppCheck/AppCheckTokenOptionsTest.php +++ b/tests/Unit/AppCheck/AppCheckTokenOptionsTest.php @@ -9,15 +9,13 @@ use Kreait\Firebase\Exception\AppCheck\InvalidAppCheckTokenOptions; use Kreait\Firebase\Tests\UnitTestCase; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; /** * @internal */ final class AppCheckTokenOptionsTest extends UnitTestCase { - #[Test] - public function fromArrayWithOmittedOptions(): void + public function testFromArrayWithOmittedOptions(): void { $options = AppCheckTokenOptions::fromArray([]); @@ -25,8 +23,7 @@ public function fromArrayWithOmittedOptions(): void } #[DataProvider('validOptions')] - #[Test] - public function fromArrayWithValidOptions(?int $ttl): void + public function testFromArrayWithValidOptions(?int $ttl): void { $options = AppCheckTokenOptions::fromArray([ 'ttl' => $ttl, @@ -36,8 +33,7 @@ public function fromArrayWithValidOptions(?int $ttl): void } #[DataProvider('invalidOptions')] - #[Test] - public function fromArrayWithInvalidOptions(int $ttl): void + public function testFromArrayWithInvalidOptions(int $ttl): void { $this->expectException(InvalidAppCheckTokenOptions::class); diff --git a/tests/Unit/AppCheck/AppCheckTokenTest.php b/tests/Unit/AppCheck/AppCheckTokenTest.php index b84fcd449..3c796f911 100644 --- a/tests/Unit/AppCheck/AppCheckTokenTest.php +++ b/tests/Unit/AppCheck/AppCheckTokenTest.php @@ -6,15 +6,13 @@ use Kreait\Firebase\AppCheck\AppCheckToken; use Kreait\Firebase\Tests\UnitTestCase; -use PHPUnit\Framework\Attributes\Test; /** * @internal */ final class AppCheckTokenTest extends UnitTestCase { - #[Test] - public function createFromValidArray(): void + public function testCreateFromValidArray(): void { $options = AppCheckToken::fromArray([ 'ttl' => $ttl = '300', diff --git a/tests/Unit/AppCheck/DecodedAppCheckTokenTest.php b/tests/Unit/AppCheck/DecodedAppCheckTokenTest.php index eb42d6035..f0fedef7b 100644 --- a/tests/Unit/AppCheck/DecodedAppCheckTokenTest.php +++ b/tests/Unit/AppCheck/DecodedAppCheckTokenTest.php @@ -6,15 +6,13 @@ use Kreait\Firebase\AppCheck\DecodedAppCheckToken; use Kreait\Firebase\Tests\UnitTestCase; -use PHPUnit\Framework\Attributes\Test; /** * @internal */ final class DecodedAppCheckTokenTest extends UnitTestCase { - #[Test] - public function createFromValidArray(): void + public function testCreateFromValidArray(): void { $options = DecodedAppCheckToken::fromArray([ 'aud' => $aud = ['111111111111', 'project-id'], diff --git a/tests/Unit/Auth/ActionCodeSettings/ValidatedActionSettingsTest.php b/tests/Unit/Auth/ActionCodeSettings/ValidatedActionSettingsTest.php index 4eb837d1f..27cf2ef8b 100644 --- a/tests/Unit/Auth/ActionCodeSettings/ValidatedActionSettingsTest.php +++ b/tests/Unit/Auth/ActionCodeSettings/ValidatedActionSettingsTest.php @@ -8,7 +8,6 @@ use Iterator; use Kreait\Firebase\Auth\ActionCodeSettings\ValidatedActionCodeSettings; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -21,21 +20,18 @@ final class ValidatedActionSettingsTest extends TestCase * @param array $expected */ #[DataProvider('validInputs')] - #[Test] - public function itWorksValidSettings(array $input, array $expected): void + public function testItWorksValidSettings(array $input, array $expected): void { $this->assertEqualsCanonicalizing($expected, ValidatedActionCodeSettings::fromArray($input)->toArray()); } - #[Test] - public function itRejectsInvalidSettings(): void + public function testItRejectsInvalidSettings(): void { $this->expectException(InvalidArgumentException::class); ValidatedActionCodeSettings::fromArray(['foo' => 'bar']); } - #[Test] - public function itCanBeEmpty(): void + public function testItCanBeEmpty(): void { $this->assertEmpty(ValidatedActionCodeSettings::empty()->toArray()); } @@ -47,7 +43,6 @@ public static function validInputs(): Iterator [ 'continueUrl' => $continueUrl, 'handleCodeInApp' => true, - 'dynamicLinkDomain' => 'https://dynamic.example.com', 'androidPackageName' => 'locale.vendor.name', 'androidMinimumVersion' => '1.0', 'androidInstallApp' => true, @@ -56,7 +51,6 @@ public static function validInputs(): Iterator [ 'continueUrl' => $continueUrl, 'canHandleCodeInApp' => true, - 'dynamicLinkDomain' => 'https://dynamic.example.com', 'androidPackageName' => 'locale.vendor.name', 'androidMinimumVersion' => '1.0', 'androidInstallApp' => true, diff --git a/tests/Unit/Auth/AuthResourceUrlBuilderTest.php b/tests/Unit/Auth/AuthResourceUrlBuilderTest.php index 507905e20..65caf1ea2 100644 --- a/tests/Unit/Auth/AuthResourceUrlBuilderTest.php +++ b/tests/Unit/Auth/AuthResourceUrlBuilderTest.php @@ -6,7 +6,6 @@ use Kreait\Firebase\Auth\AuthResourceUrlBuilder; use Kreait\Firebase\Util; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use function putenv; @@ -26,8 +25,7 @@ protected function setUp(): void $this->builder = AuthResourceUrlBuilder::create(); } - #[Test] - public function itUsesAnEmulatorHostIfProvidedByEnvironmentVariable(): void + public function testItUsesAnEmulatorHostIfProvidedByEnvironmentVariable(): void { putenv('FIREBASE_AUTH_EMULATOR_HOST=localhost:1234'); @@ -36,8 +34,7 @@ public function itUsesAnEmulatorHostIfProvidedByEnvironmentVariable(): void $this->assertStringContainsString('localhost:1234', $builder->getUrl()); } - #[Test] - public function itDoesNotUseTheEmulatorHostWhenItIsEmpty(): void + public function testItDoesNotUseTheEmulatorHostWhenItIsEmpty(): void { putenv('FIREBASE_AUTH_EMULATOR_HOST='); @@ -46,29 +43,25 @@ public function itDoesNotUseTheEmulatorHostWhenItIsEmpty(): void $this->assertStringNotContainsString('{host}', $builder->getUrl()); } - #[Test] - public function itReplacesTheApiWithAnEmptyStringWhenItIsNotProvided(): void + public function testItReplacesTheApiWithAnEmptyStringWhenItIsNotProvided(): void { $this->assertStringNotContainsString('{api}', $this->builder->getUrl()); } - #[Test] - public function itUsesTheRequestedApi(): void + public function testItUsesTheRequestedApi(): void { $url = $this->builder->getUrl('foo'); $this->assertStringNotContainsString('{api}', $url); $this->assertStringContainsString('foo', $url); } - #[Test] - public function itUsesTheGivenParameters(): void + public function testItUsesTheGivenParameters(): void { $url = $this->builder->getUrl('', ['first' => 'value', 'second' => 'value']); $this->assertStringContainsString('?first=value&second=value', $url); } - #[Test] - public function itDoesNotHaveQueryParamsWhenNoneAreProvided(): void + public function testItDoesNotHaveQueryParamsWhenNoneAreProvided(): void { $url = $this->builder->getUrl(); $this->assertStringNotContainsString('?', $url); diff --git a/tests/Unit/Auth/DeleteUsersRequestTest.php b/tests/Unit/Auth/DeleteUsersRequestTest.php index 347612e65..c7cf8b417 100644 --- a/tests/Unit/Auth/DeleteUsersRequestTest.php +++ b/tests/Unit/Auth/DeleteUsersRequestTest.php @@ -6,7 +6,6 @@ use Kreait\Firebase\Auth\DeleteUsersRequest; use Kreait\Firebase\Exception\InvalidArgumentException; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use function array_map; @@ -17,17 +16,15 @@ */ final class DeleteUsersRequestTest extends TestCase { - #[Test] - public function itRejectsTooManyUids(): void + public function testItRejectsTooManyUids(): void { - $uids = array_map('strval', range(0, 1001)); + $uids = array_map(strval(...), range(0, 1001)); $this->expectException(InvalidArgumentException::class); DeleteUsersRequest::withUids($uids); } - #[Test] - public function itRejectsInvalidUids(): void + public function testItRejectsInvalidUids(): void { $this->expectException(InvalidArgumentException::class); DeleteUsersRequest::withUids(['']); diff --git a/tests/Unit/Auth/GuzzleHandlerTest.php b/tests/Unit/Auth/GuzzleHandlerTest.php index 3eab660ad..75f8dba2c 100644 --- a/tests/Unit/Auth/GuzzleHandlerTest.php +++ b/tests/Unit/Auth/GuzzleHandlerTest.php @@ -15,7 +15,6 @@ use Kreait\Firebase\Auth\SignIn\GuzzleHandler; use Kreait\Firebase\Auth\SignInAnonymously; use Kreait\Firebase\Tests\UnitTestCase; -use PHPUnit\Framework\Attributes\Test; use const JSON_FORCE_OBJECT; @@ -38,15 +37,13 @@ protected function setUp(): void $this->handler = new GuzzleHandler('my-project', new Client(['handler' => $this->httpResponses])); } - #[Test] - public function itFailsOnAnUnsupportedAction(): void + public function testItFailsOnAnUnsupportedAction(): void { $this->expectException(FailedToSignIn::class); $this->handler->handle($this->createMock(SignIn::class)); } - #[Test] - public function itFailsWhenGuzzleFails(): void + public function testItFailsWhenGuzzleFails(): void { $client = $this->createMock(ClientInterface::class); $client->method('send')->willThrowException($this->createMock(ConnectException::class)); @@ -57,8 +54,7 @@ public function itFailsWhenGuzzleFails(): void $handler->handle($this->action); } - #[Test] - public function itFailsOnAnUnsuccessfulResponse(): void + public function testItFailsOnAnUnsuccessfulResponse(): void { $this->httpResponses->append($response = new Response(400, [], '""')); @@ -70,8 +66,7 @@ public function itFailsOnAnUnsuccessfulResponse(): void } } - #[Test] - public function itFailsOnASuccessfulResponseWithInvalidJson(): void + public function testItFailsOnASuccessfulResponseWithInvalidJson(): void { $this->httpResponses->append(new Response(200, [], '{')); @@ -79,8 +74,7 @@ public function itFailsOnASuccessfulResponseWithInvalidJson(): void $this->handler->handle($this->action); } - #[Test] - public function itWorks(): void + public function testItWorks(): void { $this->httpResponses->append(new Response(200, [], Json::encode([ 'id_token' => 'id_token', diff --git a/tests/Unit/Auth/ProjectAwareAuthResourceUrlBuilderTest.php b/tests/Unit/Auth/ProjectAwareAuthResourceUrlBuilderTest.php index 57973498c..1dd1d3375 100644 --- a/tests/Unit/Auth/ProjectAwareAuthResourceUrlBuilderTest.php +++ b/tests/Unit/Auth/ProjectAwareAuthResourceUrlBuilderTest.php @@ -5,7 +5,6 @@ namespace Kreait\Firebase\Tests\Unit\Auth; use Kreait\Firebase\Auth\ProjectAwareAuthResourceUrlBuilder; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use function putenv; @@ -28,14 +27,12 @@ protected function setUp(): void $this->builder = ProjectAwareAuthResourceUrlBuilder::forProject($this->projectId); } - #[Test] - public function itUsesTheGivenProjectId(): void + public function testItUsesTheGivenProjectId(): void { $this->assertStringContainsString($this->projectId, $this->builder->getUrl()); } - #[Test] - public function itUsesAnEmulatorHostIfProvidedByEnvironmentVariable(): void + public function testItUsesAnEmulatorHostIfProvidedByEnvironmentVariable(): void { putenv('FIREBASE_AUTH_EMULATOR_HOST=localhost:1234'); @@ -44,8 +41,7 @@ public function itUsesAnEmulatorHostIfProvidedByEnvironmentVariable(): void $this->assertStringContainsString('localhost:1234', $builder->getUrl()); } - #[Test] - public function itDoesNotUseTheEmulatorHostWhenItIsEmpty(): void + public function testItDoesNotUseTheEmulatorHostWhenItIsEmpty(): void { putenv('FIREBASE_AUTH_EMULATOR_HOST='); @@ -54,29 +50,25 @@ public function itDoesNotUseTheEmulatorHostWhenItIsEmpty(): void $this->assertStringNotContainsString('{host}', $builder->getUrl()); } - #[Test] - public function itReplacesTheApiWithAnEmptyStringWhenItIsNotProvided(): void + public function testItReplacesTheApiWithAnEmptyStringWhenItIsNotProvided(): void { $this->assertStringNotContainsString('{api}', $this->builder->getUrl()); } - #[Test] - public function itUsesTheRequestedApi(): void + public function testItUsesTheRequestedApi(): void { $url = $this->builder->getUrl('foo'); $this->assertStringNotContainsString('{api}', $url); $this->assertStringContainsString('foo', $url); } - #[Test] - public function itUsesTheGivenParameters(): void + public function testItUsesTheGivenParameters(): void { $url = $this->builder->getUrl('', ['first' => 'value', 'second' => 'value']); $this->assertStringContainsString('?first=value&second=value', $url); } - #[Test] - public function itDoesNotHaveQueryParamsWhenNoneAreProvided(): void + public function testItDoesNotHaveQueryParamsWhenNoneAreProvided(): void { $url = $this->builder->getUrl(); $this->assertStringNotContainsString('?', $url); diff --git a/tests/Unit/Auth/SignInResultTest.php b/tests/Unit/Auth/SignInResultTest.php index 8c4d3e2bb..f7b588540 100644 --- a/tests/Unit/Auth/SignInResultTest.php +++ b/tests/Unit/Auth/SignInResultTest.php @@ -8,7 +8,6 @@ use Kreait\Firebase\Auth\SignInResult; use Kreait\Firebase\Tests\UnitTestCase; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; /** * @internal @@ -19,8 +18,7 @@ final class SignInResultTest extends UnitTestCase * @param array $input */ #[DataProvider('fullResponse')] - #[Test] - public function itCanBeCreated(array $input): void + public function testItCanBeCreated(array $input): void { $result = SignInResult::fromData($input); @@ -40,8 +38,7 @@ public function itCanBeCreated(array $input): void ], $result->asTokenResponse()); } - #[Test] - public function itUsesTheLocalIdWhenTheFirebaseUidIsNotPresent(): void + public function testItUsesTheLocalIdWhenTheFirebaseUidIsNotPresent(): void { $result = SignInResult::fromData(['localId' => 'some-id']); diff --git a/tests/Unit/Auth/TenantAwareAuthResourceUrlBuilderTest.php b/tests/Unit/Auth/TenantAwareAuthResourceUrlBuilderTest.php index b75fe9a1f..789e7149b 100644 --- a/tests/Unit/Auth/TenantAwareAuthResourceUrlBuilderTest.php +++ b/tests/Unit/Auth/TenantAwareAuthResourceUrlBuilderTest.php @@ -5,7 +5,6 @@ namespace Kreait\Firebase\Tests\Unit\Auth; use Kreait\Firebase\Auth\TenantAwareAuthResourceUrlBuilder; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use function putenv; @@ -35,8 +34,7 @@ protected function setUp(): void ); } - #[Test] - public function itUsesTheGivenProjectAndTenant(): void + public function testItUsesTheGivenProjectAndTenant(): void { $url = $this->builder->getUrl(); @@ -46,8 +44,7 @@ public function itUsesTheGivenProjectAndTenant(): void $this->assertStringContainsString($this->tenantId, $url); } - #[Test] - public function itUsesAnEmulatorHostIfProvidedByEnvironmentVariable(): void + public function testItUsesAnEmulatorHostIfProvidedByEnvironmentVariable(): void { putenv('FIREBASE_AUTH_EMULATOR_HOST=localhost:1234'); @@ -59,8 +56,7 @@ public function itUsesAnEmulatorHostIfProvidedByEnvironmentVariable(): void $this->assertStringContainsString('localhost:1234', $builder->getUrl()); } - #[Test] - public function itDoesNotUseTheEmulatorHostWhenItIsEmpty(): void + public function testItDoesNotUseTheEmulatorHostWhenItIsEmpty(): void { putenv('FIREBASE_AUTH_EMULATOR_HOST='); @@ -72,29 +68,25 @@ public function itDoesNotUseTheEmulatorHostWhenItIsEmpty(): void $this->assertStringNotContainsString('{host}', $builder->getUrl()); } - #[Test] - public function itReplacesTheApiWithAnEmptyStringWhenItIsNotProvided(): void + public function testItReplacesTheApiWithAnEmptyStringWhenItIsNotProvided(): void { $this->assertStringNotContainsString('{api}', $this->builder->getUrl()); } - #[Test] - public function itUsesTheRequestedApi(): void + public function testItUsesTheRequestedApi(): void { $url = $this->builder->getUrl('foo'); $this->assertStringNotContainsString('{api}', $url); $this->assertStringContainsString('foo', $url); } - #[Test] - public function itUsesTheGivenParameters(): void + public function testItUsesTheGivenParameters(): void { $url = $this->builder->getUrl('', ['first' => 'value', 'second' => 'value']); $this->assertStringContainsString('?first=value&second=value', $url); } - #[Test] - public function itDoesNotHaveQueryParamsWhenNoneAreProvided(): void + public function testItDoesNotHaveQueryParamsWhenNoneAreProvided(): void { $url = $this->builder->getUrl(); $this->assertStringNotContainsString('?', $url); diff --git a/tests/Unit/Auth/UserQueryTest.php b/tests/Unit/Auth/UserQueryTest.php index d3a1adab3..333012628 100644 --- a/tests/Unit/Auth/UserQueryTest.php +++ b/tests/Unit/Auth/UserQueryTest.php @@ -6,7 +6,6 @@ use Beste\Json; use Kreait\Firebase\Auth\UserQuery; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -14,8 +13,7 @@ */ final class UserQueryTest extends TestCase { - #[Test] - public function itCanBeComposed(): void + public function testItCanBeComposed(): void { $expected = [ 'returnUserInfo' => true, @@ -35,8 +33,7 @@ public function itCanBeComposed(): void $this->assertJsonStringEqualsJsonString(Json::encode($expected), Json::encode($query)); } - #[Test] - public function itCanSortInAscendingOrder(): void + public function testItCanSortInAscendingOrder(): void { $expected = [ 'returnUserInfo' => true, @@ -48,8 +45,7 @@ public function itCanSortInAscendingOrder(): void $this->assertJsonStringEqualsJsonString(Json::encode($expected), Json::encode($query)); } - #[Test] - public function itCanSortInDescendingOrder(): void + public function testItCanSortInDescendingOrder(): void { $expected = [ 'returnUserInfo' => true, @@ -61,8 +57,7 @@ public function itCanSortInDescendingOrder(): void $this->assertJsonStringEqualsJsonString(Json::encode($expected), Json::encode($query)); } - #[Test] - public function itCanBeCreatedFromAnArray(): void + public function testItCanBeCreatedFromAnArray(): void { $data = [ 'returnUserInfo' => true, diff --git a/tests/Unit/Database/Query/Filter/EndAtTest.php b/tests/Unit/Database/Query/Filter/EndAtTest.php index e6e9a445f..d3295f0e3 100644 --- a/tests/Unit/Database/Query/Filter/EndAtTest.php +++ b/tests/Unit/Database/Query/Filter/EndAtTest.php @@ -9,7 +9,6 @@ use Kreait\Firebase\Database\Query\Filter\EndAt; use Kreait\Firebase\Tests\UnitTestCase; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; /** * @internal @@ -17,8 +16,7 @@ final class EndAtTest extends UnitTestCase { #[DataProvider('valueProvider')] - #[Test] - public function modifyUri(mixed $given, string $expected): void + public function testModifyUri(mixed $given, string $expected): void { $filter = new EndAt($given); diff --git a/tests/Unit/Database/Query/Filter/EndBeforeTest.php b/tests/Unit/Database/Query/Filter/EndBeforeTest.php index 50cba9cec..461f129e3 100644 --- a/tests/Unit/Database/Query/Filter/EndBeforeTest.php +++ b/tests/Unit/Database/Query/Filter/EndBeforeTest.php @@ -9,7 +9,6 @@ use Kreait\Firebase\Database\Query\Filter\EndBefore; use Kreait\Firebase\Tests\UnitTestCase; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; /** * @internal @@ -17,8 +16,7 @@ final class EndBeforeTest extends UnitTestCase { #[DataProvider('valueProvider')] - #[Test] - public function modifyUri(mixed $given, string $expected): void + public function testModifyUri(mixed $given, string $expected): void { $filter = new EndBefore($given); diff --git a/tests/Unit/Database/Query/Filter/EqualToTest.php b/tests/Unit/Database/Query/Filter/EqualToTest.php index cd08fccad..9601b0e26 100644 --- a/tests/Unit/Database/Query/Filter/EqualToTest.php +++ b/tests/Unit/Database/Query/Filter/EqualToTest.php @@ -9,7 +9,6 @@ use Kreait\Firebase\Database\Query\Filter\EqualTo; use Kreait\Firebase\Tests\UnitTestCase; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; /** * @internal @@ -17,8 +16,7 @@ final class EqualToTest extends UnitTestCase { #[DataProvider('valueProvider')] - #[Test] - public function modifyUri(mixed $given, string $expected): void + public function testModifyUri(mixed $given, string $expected): void { $filter = new EqualTo($given); diff --git a/tests/Unit/Database/Query/Filter/LimitToFirstTest.php b/tests/Unit/Database/Query/Filter/LimitToFirstTest.php index 9d1673735..08fe18617 100644 --- a/tests/Unit/Database/Query/Filter/LimitToFirstTest.php +++ b/tests/Unit/Database/Query/Filter/LimitToFirstTest.php @@ -8,23 +8,20 @@ use Kreait\Firebase\Database\Query\Filter\LimitToFirst; use Kreait\Firebase\Exception\InvalidArgumentException; use Kreait\Firebase\Tests\UnitTestCase; -use PHPUnit\Framework\Attributes\Test; /** * @internal */ final class LimitToFirstTest extends UnitTestCase { - #[Test] - public function createWithInvalidValue(): void + public function testCreateWithInvalidValue(): void { $this->expectException(InvalidArgumentException::class); new LimitToFirst(0); } - #[Test] - public function modifyUri(): void + public function testModifyUri(): void { $filter = new LimitToFirst(3); diff --git a/tests/Unit/Database/Query/Filter/LimitToLastTest.php b/tests/Unit/Database/Query/Filter/LimitToLastTest.php index 3a9b53679..89c43946d 100644 --- a/tests/Unit/Database/Query/Filter/LimitToLastTest.php +++ b/tests/Unit/Database/Query/Filter/LimitToLastTest.php @@ -8,23 +8,20 @@ use Kreait\Firebase\Database\Query\Filter\LimitToLast; use Kreait\Firebase\Exception\InvalidArgumentException; use Kreait\Firebase\Tests\UnitTestCase; -use PHPUnit\Framework\Attributes\Test; /** * @internal */ final class LimitToLastTest extends UnitTestCase { - #[Test] - public function createWithInvalidValue(): void + public function testCreateWithInvalidValue(): void { $this->expectException(InvalidArgumentException::class); new LimitToLast(0); } - #[Test] - public function modifyUri(): void + public function testModifyUri(): void { $filter = new LimitToLast(3); diff --git a/tests/Unit/Database/Query/Filter/ShallowTest.php b/tests/Unit/Database/Query/Filter/ShallowTest.php index 81339392c..e908e9916 100644 --- a/tests/Unit/Database/Query/Filter/ShallowTest.php +++ b/tests/Unit/Database/Query/Filter/ShallowTest.php @@ -7,15 +7,13 @@ use GuzzleHttp\Psr7\Uri; use Kreait\Firebase\Database\Query\Filter\Shallow; use Kreait\Firebase\Tests\UnitTestCase; -use PHPUnit\Framework\Attributes\Test; /** * @internal */ final class ShallowTest extends UnitTestCase { - #[Test] - public function modifyUri(): void + public function testModifyUri(): void { $filter = new Shallow(); diff --git a/tests/Unit/Database/Query/Filter/StartAfterTest.php b/tests/Unit/Database/Query/Filter/StartAfterTest.php index 02c7454a5..1b75a88b8 100644 --- a/tests/Unit/Database/Query/Filter/StartAfterTest.php +++ b/tests/Unit/Database/Query/Filter/StartAfterTest.php @@ -9,7 +9,6 @@ use Kreait\Firebase\Database\Query\Filter\StartAfter; use Kreait\Firebase\Tests\UnitTestCase; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; /** * @internal @@ -17,8 +16,7 @@ final class StartAfterTest extends UnitTestCase { #[DataProvider('valueProvider')] - #[Test] - public function modifyUri(mixed $given, mixed $expected): void + public function testModifyUri(mixed $given, mixed $expected): void { $filter = new StartAfter($given); diff --git a/tests/Unit/Database/Query/Filter/StartAtTest.php b/tests/Unit/Database/Query/Filter/StartAtTest.php index 89a521938..cd9740731 100644 --- a/tests/Unit/Database/Query/Filter/StartAtTest.php +++ b/tests/Unit/Database/Query/Filter/StartAtTest.php @@ -9,7 +9,6 @@ use Kreait\Firebase\Database\Query\Filter\StartAt; use Kreait\Firebase\Tests\UnitTestCase; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; /** * @internal @@ -17,8 +16,7 @@ final class StartAtTest extends UnitTestCase { #[DataProvider('valueProvider')] - #[Test] - public function modifyUri(mixed $given, string $expected): void + public function testModifyUri(mixed $given, string $expected): void { $filter = new StartAt($given); diff --git a/tests/Unit/Database/Query/Sorter/OrderByChildTest.php b/tests/Unit/Database/Query/Sorter/OrderByChildTest.php index c27eec8aa..353d6e56a 100644 --- a/tests/Unit/Database/Query/Sorter/OrderByChildTest.php +++ b/tests/Unit/Database/Query/Sorter/OrderByChildTest.php @@ -9,7 +9,6 @@ use Kreait\Firebase\Database\Query\Sorter\OrderByChild; use Kreait\Firebase\Tests\UnitTestCase; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use function rawurlencode; use function sprintf; @@ -20,8 +19,7 @@ final class OrderByChildTest extends UnitTestCase { #[DataProvider('valueProvider')] - #[Test] - public function orderByChild(string $childKey, mixed $expected, mixed $given): void + public function testOrderByChild(string $childKey, mixed $expected, mixed $given): void { $sut = new OrderByChild($childKey); diff --git a/tests/Unit/Database/Query/Sorter/OrderByKeyTest.php b/tests/Unit/Database/Query/Sorter/OrderByKeyTest.php index 34a8ed640..b0be1703e 100644 --- a/tests/Unit/Database/Query/Sorter/OrderByKeyTest.php +++ b/tests/Unit/Database/Query/Sorter/OrderByKeyTest.php @@ -9,7 +9,6 @@ use Kreait\Firebase\Database\Query\Sorter\OrderByKey; use Kreait\Firebase\Tests\UnitTestCase; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use function rawurlencode; @@ -25,8 +24,7 @@ protected function setUp(): void $this->sorter = new OrderByKey(); } - #[Test] - public function modifyUri(): void + public function testModifyUri(): void { $this->assertStringContainsString( 'orderBy='.rawurlencode('"$key"'), @@ -35,8 +33,7 @@ public function modifyUri(): void } #[DataProvider('valueProvider')] - #[Test] - public function modifyValue(mixed $expected, mixed $given): void + public function testModifyValue(mixed $expected, mixed $given): void { $this->assertSame($expected, $this->sorter->modifyValue($given)); } diff --git a/tests/Unit/Database/Query/Sorter/OrderByValueTest.php b/tests/Unit/Database/Query/Sorter/OrderByValueTest.php index 20b685d37..34f50d7d3 100644 --- a/tests/Unit/Database/Query/Sorter/OrderByValueTest.php +++ b/tests/Unit/Database/Query/Sorter/OrderByValueTest.php @@ -9,7 +9,6 @@ use Kreait\Firebase\Database\Query\Sorter\OrderByValue; use Kreait\Firebase\Tests\UnitTestCase; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use function rawurlencode; @@ -25,8 +24,7 @@ protected function setUp(): void $this->sorter = new OrderByValue(); } - #[Test] - public function modifyUri(): void + public function testModifyUri(): void { $this->assertStringContainsString( 'orderBy='.rawurlencode('"$value"'), @@ -35,8 +33,7 @@ public function modifyUri(): void } #[DataProvider('valueProvider')] - #[Test] - public function modifyValue(mixed $expected, mixed $given): void + public function testModifyValue(mixed $expected, mixed $given): void { $this->assertSame($expected, $this->sorter->modifyValue($given)); } diff --git a/tests/Unit/Database/QueryTest.php b/tests/Unit/Database/QueryTest.php index f036dfc29..0780d1e05 100644 --- a/tests/Unit/Database/QueryTest.php +++ b/tests/Unit/Database/QueryTest.php @@ -12,7 +12,6 @@ use Kreait\Firebase\Exception\Database\DatabaseNotFound; use Kreait\Firebase\Exception\Database\UnsupportedQuery; use Kreait\Firebase\Tests\UnitTestCase; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use Throwable; @@ -41,14 +40,12 @@ protected function setUp(): void $this->query = new Query($this->reference, $this->apiClient); } - #[Test] - public function getReference(): void + public function testGetReference(): void { $this->assertSame($this->reference, $this->query->getReference()); } - #[Test] - public function getSnapshot(): void + public function testGetSnapshot(): void { $this->apiClient->method('get')->with($this->anything())->willReturn('value'); @@ -57,24 +54,21 @@ public function getSnapshot(): void $this->assertSame('value', $snapshot->getValue()); } - #[Test] - public function getValue(): void + public function testGetValue(): void { $this->apiClient->method('get')->with($this->anything())->willReturn('value'); $this->assertSame('value', $this->query->getValue()); } - #[Test] - public function getUri(): void + public function testGetUri(): void { $uri = $this->query->getUri(); $this->assertSame((string) $uri, (string) $this->query); } - #[Test] - public function onlyOneSorterIsAllowed(): void + public function testOnlyOneSorterIsAllowed(): void { try { $this->query->orderByKey()->orderByValue(); @@ -83,8 +77,7 @@ public function onlyOneSorterIsAllowed(): void } } - #[Test] - public function wrapsApiExceptions(): void + public function testWrapsApiExceptions(): void { $exception = new DatabaseError(); @@ -98,8 +91,7 @@ public function wrapsApiExceptions(): void $this->query->getSnapshot(); } - #[Test] - public function indexNotDefined(): void + public function testIndexNotDefined(): void { $this->apiClient ->method('get')->with($this->anything()) @@ -111,8 +103,7 @@ public function indexNotDefined(): void $this->query->getSnapshot(); } - #[Test] - public function withNonExistingDatabase(): void + public function testWithNonExistingDatabase(): void { $this->apiClient ->method('get')->with($this->anything()) diff --git a/tests/Unit/Database/ReferenceTest.php b/tests/Unit/Database/ReferenceTest.php index 496602b8a..add775e8b 100644 --- a/tests/Unit/Database/ReferenceTest.php +++ b/tests/Unit/Database/ReferenceTest.php @@ -9,7 +9,6 @@ use Kreait\Firebase\Database\Reference; use Kreait\Firebase\Exception\OutOfRangeException; use Kreait\Firebase\Tests\UnitTestCase; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; /** @@ -34,50 +33,43 @@ protected function setUp(): void ); } - #[Test] - public function getKey(): void + public function testGetKey(): void { $this->assertSame('key', $this->reference->getKey()); } - #[Test] - public function getPath(): void + public function testGetPath(): void { $this->assertSame('parent/key', $this->reference->getPath()); } - #[Test] - public function getParent(): void + public function testGetParent(): void { $this->assertSame('parent', $this->reference->getParent()->getPath()); } - #[Test] - public function getParentOfRoot(): void + public function testGetParentOfRoot(): void { $this->expectException(OutOfRangeException::class); $this->reference->getParent()->getParent(); } - #[Test] - public function getRoot(): void + public function testGetRoot(): void { $root = $this->reference->getRoot(); $this->assertSame('/', $root->getUri()->getPath()); } - #[Test] - public function getChild(): void + public function testGetChild(): void { $child = $this->reference->getChild('child'); $this->assertSame('parent/key/child', $child->getPath()); } - #[Test] - public function getChildKeys(): void + public function testGetChildKeys(): void { $this->apiClient ->method('get') @@ -88,8 +80,7 @@ public function getChildKeys(): void $this->assertSame(['a', 'b', 'c'], $this->reference->getChildKeys()); } - #[Test] - public function getChildKeysWhenNoChildrenAreSet(): void + public function testGetChildKeysWhenNoChildrenAreSet(): void { $this->apiClient ->method('get') @@ -102,48 +93,42 @@ public function getChildKeysWhenNoChildrenAreSet(): void $this->reference->getChildKeys(); } - #[Test] - public function getSnapshot(): void + public function testGetSnapshot(): void { $this->apiClient->method('get')->with($this->anything())->willReturn('value'); $this->assertSame('value', $this->reference->getSnapshot()->getValue()); } - #[Test] - public function getValue(): void + public function testGetValue(): void { $this->apiClient->method('get')->with($this->anything())->willReturn('value'); $this->assertSame('value', $this->reference->getValue()); } - #[Test] - public function set(): void + public function testSet(): void { $this->apiClient->expects($this->once())->method('set'); $this->assertSame($this->reference, $this->reference->set('value')); } - #[Test] - public function remove(): void + public function testRemove(): void { $this->apiClient->expects($this->once())->method('remove'); $this->assertSame($this->reference, $this->reference->remove()); } - #[Test] - public function update(): void + public function testUpdate(): void { $this->apiClient->expects($this->once())->method('update'); $this->assertSame($this->reference, $this->reference->update(['any' => 'thing'])); } - #[Test] - public function push(): void + public function testPush(): void { $this->apiClient->expects($this->once())->method('push')->willReturn('newChild'); @@ -151,8 +136,7 @@ public function push(): void $this->assertSame('newChild', $childReference->getKey()); } - #[Test] - public function getUri(): void + public function testGetUri(): void { $uri = $this->reference->getUri(); diff --git a/tests/Unit/Database/RuleSetTest.php b/tests/Unit/Database/RuleSetTest.php index 9ef92bef8..d64c320f4 100644 --- a/tests/Unit/Database/RuleSetTest.php +++ b/tests/Unit/Database/RuleSetTest.php @@ -6,15 +6,13 @@ use Kreait\Firebase\Database\RuleSet; use Kreait\Firebase\Tests\UnitTestCase; -use PHPUnit\Framework\Attributes\Test; /** * @internal */ final class RuleSetTest extends UnitTestCase { - #[Test] - public function customWithMissingRulesKey(): void + public function testCustomWithMissingRulesKey(): void { $data = ['rules' => [ '.read' => 'auth != null', diff --git a/tests/Unit/Database/SnapshotTest.php b/tests/Unit/Database/SnapshotTest.php index d92fc8b1e..2dbdc081b 100644 --- a/tests/Unit/Database/SnapshotTest.php +++ b/tests/Unit/Database/SnapshotTest.php @@ -7,7 +7,6 @@ use Kreait\Firebase\Database\Reference; use Kreait\Firebase\Database\Snapshot; use Kreait\Firebase\Tests\UnitTestCase; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; /** @@ -32,22 +31,19 @@ protected function setUp(): void $this->snapshotWithEmptyValue = new Snapshot($this->reference, null); } - #[Test] - public function getReference(): void + public function testGetReference(): void { $this->assertSame($this->reference, $this->snapshotWithArrayValue->getReference()); } - #[Test] - public function getKey(): void + public function testGetKey(): void { $this->reference->method('getKey')->willReturn('key'); $this->assertSame('key', $this->snapshotWithArrayValue->getKey()); } - #[Test] - public function getChildOnANonArrayValueReturnsAnEmptySnapshot(): void + public function testGetChildOnANonArrayValueReturnsAnEmptySnapshot(): void { $this->reference->expects($this->once()) ->method('getChild')->with('path/to/child') @@ -60,8 +56,7 @@ public function getChildOnANonArrayValueReturnsAnEmptySnapshot(): void $this->assertNull($childSnapshot->getValue()); } - #[Test] - public function getChildOnANonExistingChildReturnsAnEmptySnapshot(): void + public function testGetChildOnANonExistingChildReturnsAnEmptySnapshot(): void { $this->reference->expects($this->once()) ->method('getChild')->with('nonexisting/child') @@ -72,8 +67,7 @@ public function getChildOnANonExistingChildReturnsAnEmptySnapshot(): void $this->assertNull($this->snapshotWithArrayValue->getChild('nonexisting/child')->getValue()); } - #[Test] - public function getChild(): void + public function testGetChild(): void { $this->reference->expects($this->once()) ->method('getChild')->with('key/subkey') @@ -84,24 +78,21 @@ public function getChild(): void $this->assertSame('value', $this->snapshotWithArrayValue->getChild('key/subkey')->getValue()); } - #[Test] - public function exists(): void + public function testExists(): void { $this->assertTrue($this->snapshotWithArrayValue->exists()); $this->assertTrue($this->snapshotWithScalarValue->exists()); $this->assertFalse($this->snapshotWithEmptyValue->exists()); } - #[Test] - public function hasChildren(): void + public function testHasChildren(): void { $this->assertTrue($this->snapshotWithArrayValue->hasChildren()); $this->assertFalse($this->snapshotWithScalarValue->hasChildren()); $this->assertFalse($this->snapshotWithEmptyValue->hasChildren()); } - #[Test] - public function numChildren(): void + public function testNumChildren(): void { $this->assertSame(1, $this->snapshotWithArrayValue->numChildren()); $this->assertSame(0, $this->snapshotWithScalarValue->numChildren()); @@ -111,8 +102,7 @@ public function numChildren(): void /** * @see https://github.com/kreait/firebase-php/issues/212 */ - #[Test] - public function getChildWithKeyStartingWithANonAlphabeticalCharacter(): void + public function testGetChildWithKeyStartingWithANonAlphabeticalCharacter(): void { $snapshot = new Snapshot($this->reference, [ '123' => 'value', diff --git a/tests/Unit/Database/TransactionTest.php b/tests/Unit/Database/TransactionTest.php index 79f73b1f4..eee74b262 100644 --- a/tests/Unit/Database/TransactionTest.php +++ b/tests/Unit/Database/TransactionTest.php @@ -10,7 +10,6 @@ use Kreait\Firebase\Exception\Database\DatabaseError; use Kreait\Firebase\Exception\Database\ReferenceHasNotBeenSnapshotted; use Kreait\Firebase\Exception\Database\TransactionFailed; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Throwable; @@ -31,8 +30,7 @@ protected function setUp(): void $this->transaction = new Transaction($this->apiClient); } - #[Test] - public function aReferenceCanOnlyBeChangedIfItHasBeenSnapshotted(): void + public function testAReferenceCanOnlyBeChangedIfItHasBeenSnapshotted(): void { $reference = $this->createMock(Reference::class); @@ -45,8 +43,7 @@ public function aReferenceCanOnlyBeChangedIfItHasBeenSnapshotted(): void } } - #[Test] - public function aTransactionCanFail(): void + public function testATransactionCanFail(): void { $reference = $this->createMock(Reference::class); $reference->method('getPath')->willReturn('/foo'); diff --git a/tests/Unit/Database/UrlBuilderTest.php b/tests/Unit/Database/UrlBuilderTest.php index 9c03e4844..2c9d1f11d 100644 --- a/tests/Unit/Database/UrlBuilderTest.php +++ b/tests/Unit/Database/UrlBuilderTest.php @@ -10,7 +10,6 @@ use Kreait\Firebase\Tests\UnitTestCase; use Kreait\Firebase\Util; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; /** * @internal @@ -26,8 +25,7 @@ protected function tearDown(): void * @param non-empty-string $url */ #[DataProvider('invalidUrls')] - #[Test] - public function withInvalidUrl(string $url): void + public function testWithInvalidUrl(string $url): void { $this->expectException(InvalidArgumentException::class); UrlBuilder::create($url); @@ -45,8 +43,7 @@ public static function invalidUrls(): Iterator * @param non-empty-string $expected */ #[DataProvider('realUrls')] - #[Test] - public function getGetUrl(string $baseUrl, string $path, array $queryParams, string $expected): void + public function testGetGetUrl(string $baseUrl, string $path, array $queryParams, string $expected): void { $this->assertSame($expected, UrlBuilder::create($baseUrl)->getUrl($path, $queryParams)); } @@ -58,8 +55,7 @@ public function getGetUrl(string $baseUrl, string $path, array $queryParams, str * @param non-empty-string $expected */ #[DataProvider('emulatedUrls')] - #[Test] - public function emulated(string $emulatorHost, string $baseUrl, string $path, array $queryParams, string $expected): void + public function testEmulated(string $emulatorHost, string $baseUrl, string $path, array $queryParams, string $expected): void { Util::putenv('FIREBASE_DATABASE_EMULATOR_HOST', $emulatorHost); diff --git a/tests/Unit/DatabaseTest.php b/tests/Unit/DatabaseTest.php index 8eb11ec26..bbb176bdf 100644 --- a/tests/Unit/DatabaseTest.php +++ b/tests/Unit/DatabaseTest.php @@ -10,7 +10,6 @@ use Kreait\Firebase\Database\RuleSet; use Kreait\Firebase\Exception\InvalidArgumentException; use Kreait\Firebase\Tests\UnitTestCase; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; /** @@ -32,36 +31,31 @@ protected function setUp(): void $this->database = new Database(new Uri($this->url), $this->apiClient); } - #[Test] - public function getReference(): void + public function testGetReference(): void { $this->assertSame('any', $this->database->getReference('any')->getPath()); } - #[Test] - public function getRootReference(): void + public function testGetRootReference(): void { $this->assertSame('/', $this->database->getReference()->getUri()->getPath()); } - #[Test] - public function getReferenceFromUrl(): void + public function testGetReferenceFromUrl(): void { $url = $this->url.'/foo/bar'; $this->assertSame($url, (string) $this->database->getReferenceFromUrl($url)->getUri()); } - #[Test] - public function getReferenceFromNonMatchingUrl(): void + public function testGetReferenceFromNonMatchingUrl(): void { $this->expectException(InvalidArgumentException::class); $this->database->getReferenceFromUrl('https://example.com'); } - #[Test] - public function getRuleSet(): void + public function testGetRuleSet(): void { $this->apiClient ->method('get') diff --git a/tests/Unit/Exception/AppCheckApiExceptionConverterTest.php b/tests/Unit/Exception/AppCheckApiExceptionConverterTest.php index cd4c16b55..c878cae39 100644 --- a/tests/Unit/Exception/AppCheckApiExceptionConverterTest.php +++ b/tests/Unit/Exception/AppCheckApiExceptionConverterTest.php @@ -16,7 +16,6 @@ use Kreait\Firebase\Exception\AppCheckApiExceptionConverter; use Kreait\Firebase\Http\ErrorResponseParser; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; use RuntimeException; @@ -34,8 +33,7 @@ protected function setUp(): void $this->converter = new AppCheckApiExceptionConverter(new ErrorResponseParser()); } - #[Test] - public function itConvertsAConnectException(): void + public function testItConvertsAConnectException(): void { $connectException = new ConnectException( 'curl error xx', @@ -49,8 +47,7 @@ public function itConvertsAConnectException(): void * @param class-string $expectedClass */ #[DataProvider('exceptions')] - #[Test] - public function itConvertsExceptions(Throwable $e, string $expectedClass): void + public function testItConvertsExceptions(Throwable $e, string $expectedClass): void { $converted = $this->converter->convertException($e); diff --git a/tests/Unit/Exception/AuthApiExceptionConverterTest.php b/tests/Unit/Exception/AuthApiExceptionConverterTest.php index 1059ad6a2..df0ab3e09 100644 --- a/tests/Unit/Exception/AuthApiExceptionConverterTest.php +++ b/tests/Unit/Exception/AuthApiExceptionConverterTest.php @@ -30,7 +30,6 @@ use Kreait\Firebase\Http\ErrorResponseParser; use Kreait\Firebase\Tests\UnitTestCase; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use Psr\Http\Message\RequestInterface; use RuntimeException; @@ -46,8 +45,7 @@ protected function setUp(): void $this->converter = new AuthApiExceptionConverter(new ErrorResponseParser()); } - #[Test] - public function itConvertsARequestExceptionThatDoesNotIncludeValidJson(): void + public function testItConvertsARequestExceptionThatDoesNotIncludeValidJson(): void { $requestException = new RequestException( 'Error without valid json', @@ -61,8 +59,7 @@ public function itConvertsARequestExceptionThatDoesNotIncludeValidJson(): void $this->assertSame($responseBody, $convertedError->getMessage()); } - #[Test] - public function itConvertsAConnectException(): void + public function testItConvertsAConnectException(): void { $connectException = new ConnectException( 'curl error xx', @@ -72,8 +69,7 @@ public function itConvertsAConnectException(): void $this->assertInstanceOf(ApiConnectionFailed::class, $this->converter->convertException($connectException)); } - #[Test] - public function itCanHandleUnknownExceptions(): void + public function testItCanHandleUnknownExceptions(): void { $this->assertInstanceOf(AuthError::class, $this->converter->convertException(new RuntimeException())); } @@ -82,8 +78,7 @@ public function itCanHandleUnknownExceptions(): void * @param class-string $expectedClass */ #[DataProvider('requestErrors')] - #[Test] - public function itConvertsRequestExceptionsBecause(string $identifier, string $expectedClass): void + public function testItConvertsRequestExceptionsBecause(string $identifier, string $expectedClass): void { $requestException = new RequestException( 'Firebase Error Test', diff --git a/tests/Unit/Exception/DatabaseApiExceptionConverterTest.php b/tests/Unit/Exception/DatabaseApiExceptionConverterTest.php index 10825c36b..c56d78573 100644 --- a/tests/Unit/Exception/DatabaseApiExceptionConverterTest.php +++ b/tests/Unit/Exception/DatabaseApiExceptionConverterTest.php @@ -17,7 +17,6 @@ use Kreait\Firebase\Exception\DatabaseApiExceptionConverter; use Kreait\Firebase\Http\ErrorResponseParser; use Kreait\Firebase\Tests\UnitTestCase; -use PHPUnit\Framework\Attributes\Test; /** * @internal @@ -34,8 +33,7 @@ protected function setUp(): void $this->request = new Request('GET', 'https://my-project.firebaseio.com'); } - #[Test] - public function itConvertsARequestExceptionThatDoesNotIncludeValidJson(): void + public function testItConvertsARequestExceptionThatDoesNotIncludeValidJson(): void { $requestException = new RequestException( 'Error without valid json', @@ -49,8 +47,7 @@ public function itConvertsARequestExceptionThatDoesNotIncludeValidJson(): void $this->assertSame($responseBody, $convertedError->getMessage()); } - #[Test] - public function itConvertsAConnectException(): void + public function testItConvertsAConnectException(): void { $connectException = new ConnectException( 'curl error xx', @@ -63,8 +60,7 @@ public function itConvertsAConnectException(): void /** * @see https://github.com/kreait/firebase-php/issues/295 */ - #[Test] - public function itHandlesAnExtendedErrorFormatInAResponse(): void + public function testItHandlesAnExtendedErrorFormatInAResponse(): void { // see https://firebase.google.com/docs/reference/rest/auth/#section-error-response $e = new ClientException( @@ -79,8 +75,7 @@ public function itHandlesAnExtendedErrorFormatInAResponse(): void $this->assertSame($e, $result->getPrevious()); } - #[Test] - public function itConvertsA401ResponseToAPermissionDeniedError(): void + public function testItConvertsA401ResponseToAPermissionDeniedError(): void { $e = new ClientException( 'Foo', @@ -93,8 +88,7 @@ public function itConvertsA401ResponseToAPermissionDeniedError(): void $this->assertInstanceOf(PermissionDenied::class, $result); } - #[Test] - public function itConvertsA403ResponseToAPermissionDeniedError(): void + public function testItConvertsA403ResponseToAPermissionDeniedError(): void { $e = new ClientException( 'Foo', @@ -107,8 +101,7 @@ public function itConvertsA403ResponseToAPermissionDeniedError(): void $this->assertInstanceOf(PermissionDenied::class, $result); } - #[Test] - public function itConvertsA404ResponseToADatabaseNotFoundError(): void + public function testItConvertsA404ResponseToADatabaseNotFoundError(): void { $e = new ClientException( 'Foo', @@ -121,8 +114,7 @@ public function itConvertsA404ResponseToADatabaseNotFoundError(): void $this->assertInstanceOf(DatabaseNotFound::class, $result); } - #[Test] - public function itUsesTheResponseBodyAsMessageWhenNoJsonIsPresent(): void + public function testItUsesTheResponseBodyAsMessageWhenNoJsonIsPresent(): void { $e = new ClientException( 'Foo', diff --git a/tests/Unit/Exception/Messaging/NotFoundTest.php b/tests/Unit/Exception/Messaging/NotFoundTest.php index eb94ec31c..2d1c36f66 100644 --- a/tests/Unit/Exception/Messaging/NotFoundTest.php +++ b/tests/Unit/Exception/Messaging/NotFoundTest.php @@ -5,16 +5,14 @@ namespace Kreait\Firebase\Tests\Unit\Exception\Messaging; use Kreait\Firebase\Exception\Messaging\NotFound; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** * @internal */ -class NotFoundTest extends TestCase +final class NotFoundTest extends TestCase { - #[Test] - public function itProvidesTheToken(): void + public function testItProvidesTheToken(): void { $exception = NotFound::becauseTokenNotFound('token'); diff --git a/tests/Unit/Exception/MessagingApiExceptionConverterTest.php b/tests/Unit/Exception/MessagingApiExceptionConverterTest.php index b44ea8680..6cfef0280 100644 --- a/tests/Unit/Exception/MessagingApiExceptionConverterTest.php +++ b/tests/Unit/Exception/MessagingApiExceptionConverterTest.php @@ -22,7 +22,6 @@ use Kreait\Firebase\Exception\Messaging\ServerUnavailable; use Kreait\Firebase\Exception\MessagingApiExceptionConverter; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; use RuntimeException; @@ -45,8 +44,7 @@ protected function setUp(): void $this->converter = new MessagingApiExceptionConverter($this->clock); } - #[Test] - public function itConvertsAConnectException(): void + public function testItConvertsAConnectException(): void { $connectException = new ConnectException( 'curl error xx', @@ -60,8 +58,7 @@ public function itConvertsAConnectException(): void * @param class-string $expectedClass */ #[DataProvider('exceptions')] - #[Test] - public function itConvertsExceptions(Throwable $e, string $expectedClass): void + public function testItConvertsExceptions(Throwable $e, string $expectedClass): void { $converted = $this->converter->convertException($e); @@ -102,8 +99,7 @@ public static function createRequestException(int $code, string $identifier): Re ); } - #[Test] - public function itKnowsWhenToRetryAfterWithSeconds(): void + public function testItKnowsWhenToRetryAfterWithSeconds(): void { $response = new Response(429, ['Retry-After' => '60']); @@ -115,8 +111,7 @@ public function itKnowsWhenToRetryAfterWithSeconds(): void $this->assertSame($expected->getTimestamp(), $converted->retryAfter()->getTimestamp()); } - #[Test] - public function itUsesTheRetryAfterHeaderOfABadGatewayResponse(): void + public function testItUsesTheRetryAfterHeaderOfABadGatewayResponse(): void { $response = new Response(502, ['Retry-After' => '60']); @@ -128,8 +123,7 @@ public function itUsesTheRetryAfterHeaderOfABadGatewayResponse(): void $this->assertSame($expected->getTimestamp(), $converted->retryAfter()->getTimestamp()); } - #[Test] - public function itUsesAFallbackRetryAfterOfABadGatewayResponse(): void + public function testItUsesAFallbackRetryAfterOfABadGatewayResponse(): void { $response = new Response(status: 502); @@ -141,8 +135,7 @@ public function itUsesAFallbackRetryAfterOfABadGatewayResponse(): void $this->assertSame($expected->getTimestamp(), $converted->retryAfter()->getTimestamp()); } - #[Test] - public function itKnowsWhenToRetryAfterWithDateStrings(): void + public function testItKnowsWhenToRetryAfterWithDateStrings(): void { $expected = $this->clock->now()->modify('+60 seconds'); @@ -155,8 +148,7 @@ public function itKnowsWhenToRetryAfterWithDateStrings(): void $this->assertSame($expected->getTimestamp(), $converted->retryAfter()->getTimestamp()); } - #[Test] - public function itDoesNotKnowWhenToRetryWhenItDoesNotHaveTo(): void + public function testItDoesNotKnowWhenToRetryWhenItDoesNotHaveTo(): void { $response = new Response(503); // no Retry-After diff --git a/tests/Unit/Http/HttpClientOptionsTest.php b/tests/Unit/Http/HttpClientOptionsTest.php index b09044898..90689a2b3 100644 --- a/tests/Unit/Http/HttpClientOptionsTest.php +++ b/tests/Unit/Http/HttpClientOptionsTest.php @@ -7,7 +7,6 @@ use GuzzleHttp\Promise\PromiseInterface; use InvalidArgumentException; use Kreait\Firebase\Http\HttpClientOptions; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; @@ -16,8 +15,7 @@ */ final class HttpClientOptionsTest extends TestCase { - #[Test] - public function optionsCanBeSet(): void + public function testOptionsCanBeSet(): void { $options = HttpClientOptions::default() ->withConnectTimeout(1.1) @@ -32,37 +30,32 @@ public function optionsCanBeSet(): void $this->assertSame('https://proxy.example.com', $options->proxy()); } - #[Test] - public function connectTimeoutMustBePositive(): void + public function testConnectTimeoutMustBePositive(): void { $this->expectException(InvalidArgumentException::class); HttpClientOptions::default()->withConnectTimeout(-0.1); } - #[Test] - public function readTimeoutMustBePositive(): void + public function testReadTimeoutMustBePositive(): void { $this->expectException(InvalidArgumentException::class); HttpClientOptions::default()->withReadTimeout(-0.1); } - #[Test] - public function timeoutMustBePositive(): void + public function testTimeoutMustBePositive(): void { $this->expectException(InvalidArgumentException::class); HttpClientOptions::default()->withTimeout(-0.1); } - #[Test] - public function itAcceptsSingleGuzzleClientConfigOptions(): void + public function testItAcceptsSingleGuzzleClientConfigOptions(): void { $options = HttpClientOptions::default()->withGuzzleConfigOption('foo', 'bar'); $this->assertEqualsCanonicalizing(['foo' => 'bar'], $options->guzzleConfig()); } - #[Test] - public function itAcceptsMultipleGuzzleClientConfigOptions(): void + public function testItAcceptsMultipleGuzzleClientConfigOptions(): void { $options = HttpClientOptions::default()->withGuzzleConfigOptions([ 'first' => 'first value', @@ -78,8 +71,7 @@ public function itAcceptsMultipleGuzzleClientConfigOptions(): void ); } - #[Test] - public function itRetainsPreviouslySetGuzzleConfigOptions(): void + public function testItRetainsPreviouslySetGuzzleConfigOptions(): void { $options = HttpClientOptions::default() ->withGuzzleConfigOption('existing', 'existing') @@ -95,20 +87,16 @@ public function itRetainsPreviouslySetGuzzleConfigOptions(): void ); } - #[Test] - public function itAcceptsSingleCallableMiddlewares(): void + public function testItAcceptsSingleCallableMiddlewares(): void { $options = HttpClientOptions::default()->withGuzzleMiddleware(static fn(): string => 'Foo', 'name'); $middlewares = $options->guzzleMiddlewares(); $this->assertCount(1, $middlewares); - $this->assertIsCallable($middlewares[0]['middleware']); - $this->assertSame('name', $middlewares[0]['name']); } - #[Test] - public function itAcceptsMultipleMiddlewares(): void + public function testItAcceptsMultipleMiddlewares(): void { $middlewareClass = new class { public static function handle(): void @@ -128,18 +116,12 @@ public static function handle(): void $this->assertCount(3, $middlewares); - $this->assertIsCallable($middlewares[0]['middleware']); $this->assertSame('', $middlewares[0]['name']); - - $this->assertIsCallable($middlewares[1]['middleware']); $this->assertSame('Foo', $middlewares[1]['name']); - - $this->assertIsCallable($middlewares[2]['middleware']); $this->assertSame('Bar', $middlewares[2]['name']); } - #[Test] - public function itAcceptsACustomHandler(): void + public function testItAcceptsACustomHandler(): void { $handler = fn(RequestInterface $request, array $options): PromiseInterface => $this->createMock(PromiseInterface::class); diff --git a/tests/Unit/Http/MiddlewareTest.php b/tests/Unit/Http/MiddlewareTest.php index 68379253c..26c2ffca0 100644 --- a/tests/Unit/Http/MiddlewareTest.php +++ b/tests/Unit/Http/MiddlewareTest.php @@ -8,7 +8,6 @@ use GuzzleHttp\Psr7\Request; use Kreait\Firebase\Http\Middleware; use Kreait\Firebase\Tests\UnitTestCase; -use PHPUnit\Framework\Attributes\Test; use Psr\Http\Message\RequestInterface; /** @@ -26,8 +25,7 @@ protected function setUp(): void $this->handler = static fn(RequestInterface $request): RequestInterface => $request; } - #[Test] - public function ensureJsonSuffix(): void + public function testEnsureJsonSuffix(): void { $middleware = Middleware::ensureJsonSuffix(); $handlerClosure = $middleware($this->handler); diff --git a/tests/Unit/Messaging/AndroidConfigTest.php b/tests/Unit/Messaging/AndroidConfigTest.php index cacedf207..75742479a 100644 --- a/tests/Unit/Messaging/AndroidConfigTest.php +++ b/tests/Unit/Messaging/AndroidConfigTest.php @@ -11,7 +11,6 @@ use Kreait\Firebase\Tests\UnitTestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; -use PHPUnit\Framework\Attributes\Test; /** * @internal @@ -20,14 +19,12 @@ */ final class AndroidConfigTest extends UnitTestCase { - #[Test] - public function itIsEmptyWhenItIsEmpty(): void + public function testItIsEmptyWhenItIsEmpty(): void { $this->assertSame('[]', Json::encode(AndroidConfig::new())); } - #[Test] - public function itHasADefaultSound(): void + public function testItHasADefaultSound(): void { $expected = [ 'notification' => [ @@ -41,8 +38,7 @@ public function itHasADefaultSound(): void ); } - #[Test] - public function itCanHaveAPriority(): void + public function testItCanHaveAPriority(): void { $config = AndroidConfig::new()->withNormalMessagePriority(); $this->assertSame('normal', $config->jsonSerialize()['priority']); @@ -55,8 +51,7 @@ public function itCanHaveAPriority(): void * @param AndroidConfigShape $data */ #[DataProvider('validDataProvider')] - #[Test] - public function itCanBeCreatedFromAnArray(array $data): void + public function testItCanBeCreatedFromAnArray(array $data): void { $config = AndroidConfig::fromArray($data); @@ -65,8 +60,7 @@ public function itCanBeCreatedFromAnArray(array $data): void #[DoesNotPerformAssertions] #[DataProvider('validTtlValues')] - #[Test] - public function itAcceptsValidTTLs(int|string|null $ttl): void + public function testItAcceptsValidTTLs(int|string|null $ttl): void { AndroidConfig::fromArray([ 'ttl' => $ttl, @@ -74,8 +68,7 @@ public function itAcceptsValidTTLs(int|string|null $ttl): void } #[DataProvider('invalidTtlValues')] - #[Test] - public function itRejectsInvalidTTLs(mixed $ttl): void + public function testItRejectsInvalidTTLs(mixed $ttl): void { $this->expectException(InvalidArgument::class); diff --git a/tests/Unit/Messaging/ApnsConfigTest.php b/tests/Unit/Messaging/ApnsConfigTest.php index 1e1881bf5..05bd2bae0 100644 --- a/tests/Unit/Messaging/ApnsConfigTest.php +++ b/tests/Unit/Messaging/ApnsConfigTest.php @@ -9,21 +9,18 @@ use Kreait\Firebase\Messaging\ApnsConfig; use Kreait\Firebase\Tests\UnitTestCase; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; /** * @internal */ final class ApnsConfigTest extends UnitTestCase { - #[Test] - public function itIsEmptyWhenItIsEmpty(): void + public function testItIsEmptyWhenItIsEmpty(): void { $this->assertSame('[]', Json::encode(ApnsConfig::new())); } - #[Test] - public function itHasADefaultSound(): void + public function testItHasADefaultSound(): void { $config = ApnsConfig::fromArray([ 'payload' => [ @@ -39,8 +36,7 @@ public function itHasADefaultSound(): void ); } - #[Test] - public function itHasABadge(): void + public function testItHasABadge(): void { $config = ApnsConfig::fromArray([ 'payload' => [ @@ -60,8 +56,7 @@ public function itHasABadge(): void * @param array $data */ #[DataProvider('validDataProvider')] - #[Test] - public function itCanBeCreatedFromAnArray(array $data): void + public function testItCanBeCreatedFromAnArray(array $data): void { $this->assertJsonStringEqualsJsonString( Json::encode($data), @@ -69,9 +64,9 @@ public function itCanBeCreatedFromAnArray(array $data): void ); } - public function itCanBeGivenData(): void + public function testItCanBeGivenData(): void { - $config = ApnsConfig::fromArray(['data' => ['key' => 'value']]); + $config = ApnsConfig::fromArray(['payload' => ['key' => 'value']]); $this->assertJsonStringEqualsJsonString( Json::encode($config), @@ -79,8 +74,7 @@ public function itCanBeGivenData(): void ); } - #[Test] - public function itCanHaveAnImmediatePriority(): void + public function testItCanHaveAnImmediatePriority(): void { $config = ApnsConfig::fromArray(['headers' => ['apns-priority' => '10']]); @@ -90,8 +84,7 @@ public function itCanHaveAnImmediatePriority(): void ); } - #[Test] - public function itCanHaveAPowerConservingPriority(): void + public function testItCanHaveAPowerConservingPriority(): void { $config = ApnsConfig::fromArray(['headers' => ['apns-priority' => '5']]); @@ -101,8 +94,7 @@ public function itCanHaveAPowerConservingPriority(): void ); } - #[Test] - public function itCanBeGivenALiveActivityTokenInsideAnArray(): void + public function testItCanBeGivenALiveActivityTokenInsideAnArray(): void { $config = ApnsConfig::fromArray(['live_activity_token' => 'token']); @@ -112,8 +104,7 @@ public function itCanBeGivenALiveActivityTokenInsideAnArray(): void ); } - #[Test] - public function itHasASubtitle(): void + public function testItHasASubtitle(): void { $config = ApnsConfig::fromArray([ 'payload' => ['aps' => ['subtitle' => 'subtitle']], diff --git a/tests/Unit/Messaging/CloudMessageTest.php b/tests/Unit/Messaging/CloudMessageTest.php index d8d4b0464..981cc020b 100644 --- a/tests/Unit/Messaging/CloudMessageTest.php +++ b/tests/Unit/Messaging/CloudMessageTest.php @@ -12,7 +12,6 @@ use Kreait\Firebase\Messaging\MessageData; use Kreait\Firebase\Messaging\MessageTarget; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -20,14 +19,12 @@ */ final class CloudMessageTest extends TestCase { - #[Test] - public function emptyMessage(): void + public function testEmptyMessage(): void { $this->assertSame('[]', Json::encode(CloudMessage::new())); } - #[Test] - public function anEmptyMessageHasNoTarget(): void + public function testAnEmptyMessageHasNoTarget(): void { $message = CloudMessage::new(); $payload = Json::decode(Json::encode($message), true); @@ -37,8 +34,7 @@ public function anEmptyMessageHasNoTarget(): void $this->assertArrayNotHasKey('topic', $payload); } - #[Test] - public function withChangedFcmOptions(): void + public function testWithChangedFcmOptions(): void { $options = FcmOptions::create()->withAnalyticsLabel($label = 'my-label'); $message = CloudMessage::new()->withFcmOptions($options); @@ -54,15 +50,13 @@ public function withChangedFcmOptions(): void * @param array $data */ #[DataProvider('multipleTargets')] - #[Test] - public function aMessageCanOnlyHaveOneTarget(array $data): void + public function testAMessageCanOnlyHaveOneTarget(array $data): void { $this->expectException(InvalidArgument::class); CloudMessage::fromArray($data); } - #[Test] - public function withDefaultSounds(): void + public function testWithDefaultSounds(): void { $expected = [ 'android' => [ @@ -85,8 +79,7 @@ public function withDefaultSounds(): void ); } - #[Test] - public function withLowestPossiblePriority(): void + public function testWithLowestPossiblePriority(): void { $message = CloudMessage::new()->withLowestPossiblePriority(); @@ -107,8 +100,7 @@ public function withLowestPossiblePriority(): void $this->assertSame('very-low', $payload['webpush']['headers']['Urgency']); } - #[Test] - public function withHighestPossiblePriority(): void + public function testWithHighestPossiblePriority(): void { $message = CloudMessage::new()->withHighestPossiblePriority(); @@ -132,8 +124,7 @@ public function withHighestPossiblePriority(): void /** * @see https://github.com/kreait/firebase-php/issues/768 */ - #[Test] - public function messageDataCanBeSetWithAnObjectOrAnArray(): void + public function testMessageDataCanBeSetWithAnObjectOrAnArray(): void { $data = ['key' => 'value']; diff --git a/tests/Unit/Messaging/ConditionTest.php b/tests/Unit/Messaging/ConditionTest.php index 393aa14bd..ee7d635ad 100644 --- a/tests/Unit/Messaging/ConditionTest.php +++ b/tests/Unit/Messaging/ConditionTest.php @@ -8,7 +8,6 @@ use Kreait\Firebase\Exception\Messaging\InvalidArgument; use Kreait\Firebase\Messaging\Condition; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -17,22 +16,19 @@ final class ConditionTest extends TestCase { #[DataProvider('valueProvider')] - #[Test] - public function fromValue(string $expected, string $value): void + public function testFromValue(string $expected, string $value): void { $this->assertSame($expected, Condition::fromValue($value)->value()); } #[DataProvider('invalidValueProvider')] - #[Test] - public function fromInvalidValue(string $value): void + public function testFromInvalidValue(string $value): void { $this->expectException(InvalidArgument::class); Condition::fromValue($value); } - #[Test] - public function noMoreThanFiveTopics(): void + public function testNoMoreThanFiveTopics(): void { $valid = "'a' in topics && 'b' in topics || 'c' in topics || 'd' in topics || 'e' in topics"; $invalid = $valid." || 'f' in topics"; diff --git a/tests/Unit/Messaging/MessageDataTest.php b/tests/Unit/Messaging/MessageDataTest.php index de32a998b..89342d744 100644 --- a/tests/Unit/Messaging/MessageDataTest.php +++ b/tests/Unit/Messaging/MessageDataTest.php @@ -9,9 +9,7 @@ use Kreait\Firebase\Messaging\MessageData; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; -use Stringable; use function hex2bin; @@ -21,21 +19,19 @@ final class MessageDataTest extends TestCase { /** - * @param array $data + * @param array $data */ #[DoesNotPerformAssertions] #[DataProvider('validData')] - #[Test] public function itAcceptsValidData(array $data): void { MessageData::fromArray($data); } /** - * @param array $data + * @param array $data */ #[DataProvider('invalidData')] - #[Test] public function itRejectsInvalidData(array $data): void { $this->expectException(InvalidArgumentException::class); @@ -45,8 +41,7 @@ public function itRejectsInvalidData(array $data): void /** * @see https://github.com/kreait/firebase-php/issues/709 */ - #[Test] - public function itDoesNotLowerCaseKeys(): void + public function testItDoesNotLowerCaseKeys(): void { $input = $output = ['notificationType' => 'email']; @@ -57,29 +52,6 @@ public function itDoesNotLowerCaseKeys(): void public static function validData(): Iterator { - yield 'integer' => [ - ['key' => 1], - ]; - yield 'float' => [ - ['key' => 1.23], - ]; - yield 'true' => [ - ['key' => true], - ]; - yield 'false' => [ - ['key' => false], - ]; - yield 'null' => [ - ['key' => null], - ]; - yield 'object with __toString()' => [ - ['key' => new class { - public function __toString(): string - { - return 'value'; - } - }], - ]; yield 'UTF-8 string' => [ ['key' => 'Jérôme'], ]; diff --git a/tests/Unit/Messaging/NotificationTest.php b/tests/Unit/Messaging/NotificationTest.php index 57280cc90..ccb91a1b0 100644 --- a/tests/Unit/Messaging/NotificationTest.php +++ b/tests/Unit/Messaging/NotificationTest.php @@ -6,15 +6,13 @@ use Kreait\Firebase\Messaging\Notification; use Kreait\Firebase\Tests\UnitTestCase; -use PHPUnit\Framework\Attributes\Test; /** * @internal */ final class NotificationTest extends UnitTestCase { - #[Test] - public function createWithEmptyStrings(): void + public function testCreateWithEmptyStrings(): void { $notification = Notification::create('', '', ''); $this->assertSame('', $notification->title()); @@ -23,8 +21,7 @@ public function createWithEmptyStrings(): void $this->assertEqualsCanonicalizing(['title' => '', 'body' => '', 'image' => ''], $notification->jsonSerialize()); } - #[Test] - public function createWithValidFields(): void + public function testCreateWithValidFields(): void { $notification = Notification::create('title', 'body') ->withTitle($title = 'My Title') @@ -37,8 +34,7 @@ public function createWithValidFields(): void $this->assertSame($imageUrl, $notification->imageUrl()); } - #[Test] - public function createFromValidArray(): void + public function testCreateFromValidArray(): void { $notification = Notification::fromArray($array = [ 'title' => $title = 'My Title', diff --git a/tests/Unit/Messaging/Processor/SetApnsContentAvailableIfNeededTest.php b/tests/Unit/Messaging/Processor/SetApnsContentAvailableIfNeededTest.php index d1347c648..2da11a61c 100644 --- a/tests/Unit/Messaging/Processor/SetApnsContentAvailableIfNeededTest.php +++ b/tests/Unit/Messaging/Processor/SetApnsContentAvailableIfNeededTest.php @@ -9,7 +9,6 @@ use Kreait\Firebase\Messaging\CloudMessage; use Kreait\Firebase\Messaging\Processor\SetApnsContentAvailableIfNeeded; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -30,8 +29,7 @@ protected function setUp(): void * @see https://github.com/kreait/firebase-php/pull/762 */ #[DataProvider('provideMessagesWithExpectedContentAvailable')] - #[Test] - public function itSetsTheExpectedPushType(array $messageData): void + public function testItSetsTheExpectedPushType(array $messageData): void { $message = CloudMessage::fromArray($messageData); @@ -44,8 +42,7 @@ public function itSetsTheExpectedPushType(array $messageData): void $this->assertSame(1, $processed['apns']['payload']['aps']['content-available']); } - #[Test] - public function itDoesNotSetThePushType(): void + public function testItDoesNotSetThePushType(): void { $message = CloudMessage::fromArray($given = ['topic' => 'test']); diff --git a/tests/Unit/Messaging/Processor/SetApnsPushTypeIfNeededTest.php b/tests/Unit/Messaging/Processor/SetApnsPushTypeIfNeededTest.php index dc7cba796..555e1e9c9 100644 --- a/tests/Unit/Messaging/Processor/SetApnsPushTypeIfNeededTest.php +++ b/tests/Unit/Messaging/Processor/SetApnsPushTypeIfNeededTest.php @@ -9,7 +9,6 @@ use Kreait\Firebase\Messaging\CloudMessage; use Kreait\Firebase\Messaging\Processor\SetApnsPushTypeIfNeeded; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -29,8 +28,7 @@ protected function setUp(): void * @param array $messageData */ #[DataProvider('provideMessagesWithExpectedPushType')] - #[Test] - public function itSetsTheExpectedPushType(string $expected, array $messageData): void + public function testItSetsTheExpectedPushType(string $expected, array $messageData): void { $message = CloudMessage::fromArray($messageData); @@ -42,8 +40,7 @@ public function itSetsTheExpectedPushType(string $expected, array $messageData): $this->assertSame($expected, $processed['apns']['headers']['apns-push-type']); } - #[Test] - public function itDoesNotSetThePushType(): void + public function testItDoesNotSetThePushType(): void { $message = CloudMessage::fromArray($given = ['topic' => 'test']); diff --git a/tests/Unit/Messaging/RegistrationTokenTest.php b/tests/Unit/Messaging/RegistrationTokenTest.php index c770b9be3..660b7f020 100644 --- a/tests/Unit/Messaging/RegistrationTokenTest.php +++ b/tests/Unit/Messaging/RegistrationTokenTest.php @@ -8,7 +8,6 @@ use Iterator; use Kreait\Firebase\Messaging\RegistrationToken; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -17,8 +16,7 @@ final class RegistrationTokenTest extends TestCase { #[DataProvider('valueProvider')] - #[Test] - public function fromValue(string $expected, string $value): void + public function testFromValue(string $expected, string $value): void { $token = RegistrationToken::fromValue($value); diff --git a/tests/Unit/Messaging/RegistrationTokensTest.php b/tests/Unit/Messaging/RegistrationTokensTest.php index 51b4b7ad8..ec0f20fe2 100644 --- a/tests/Unit/Messaging/RegistrationTokensTest.php +++ b/tests/Unit/Messaging/RegistrationTokensTest.php @@ -9,7 +9,6 @@ use Kreait\Firebase\Messaging\RegistrationToken; use Kreait\Firebase\Messaging\RegistrationTokens; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use stdClass; @@ -19,8 +18,7 @@ final class RegistrationTokensTest extends TestCase { #[DataProvider('validValuesWithExpectedCounts')] - #[Test] - public function itCanBeCreatedFromValues(int $expectedCount, mixed $value): void + public function testItCanBeCreatedFromValues(int $expectedCount, mixed $value): void { $tokens = RegistrationTokens::fromValue($value); @@ -28,15 +26,13 @@ public function itCanBeCreatedFromValues(int $expectedCount, mixed $value): void } #[DataProvider('invalidValues')] - #[Test] - public function itRejectsInvalidValues(mixed $value): void + public function testItRejectsInvalidValues(mixed $value): void { $this->expectException(InvalidArgumentException::class); RegistrationTokens::fromValue($value); } - #[Test] - public function itReturnsStrings(): void + public function testItReturnsStrings(): void { $token = RegistrationToken::fromValue('foo'); diff --git a/tests/Unit/Messaging/TopicTest.php b/tests/Unit/Messaging/TopicTest.php index 54d7f5c48..cfb9986be 100644 --- a/tests/Unit/Messaging/TopicTest.php +++ b/tests/Unit/Messaging/TopicTest.php @@ -8,7 +8,6 @@ use Kreait\Firebase\Exception\Messaging\InvalidArgument; use Kreait\Firebase\Messaging\Topic; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -17,15 +16,13 @@ final class TopicTest extends TestCase { #[DataProvider('valueProvider')] - #[Test] - public function fromValue(string $expected, string $value): void + public function testFromValue(string $expected, string $value): void { $this->assertSame($expected, Topic::fromValue($value)->value()); } #[DataProvider('invalidValueProvider')] - #[Test] - public function fromInvalidValue(string $value): void + public function testFromInvalidValue(string $value): void { $this->expectException(InvalidArgument::class); Topic::fromValue($value); diff --git a/tests/Unit/Messaging/WebPushConfigTest.php b/tests/Unit/Messaging/WebPushConfigTest.php index 32a43d956..7e5b0e3eb 100644 --- a/tests/Unit/Messaging/WebPushConfigTest.php +++ b/tests/Unit/Messaging/WebPushConfigTest.php @@ -10,7 +10,6 @@ use Kreait\Firebase\Tests\UnitTestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; -use PHPUnit\Framework\Attributes\Test; /** * @internal @@ -24,16 +23,14 @@ final class WebPushConfigTest extends UnitTestCase * @param array $data */ #[DataProvider('validDataProvider')] - #[Test] - public function createFromValidPayload(array $data): void + public function testCreateFromValidPayload(array $data): void { $config = WebPushConfig::fromArray($data); $this->assertEqualsCanonicalizing($data, $config->jsonSerialize()); } - #[Test] - public function itCanHaveAPriority(): void + public function testItCanHaveAPriority(): void { $config = WebPushConfig::new()->withVeryLowUrgency(); $this->assertSame('very-low', $config->jsonSerialize()['headers']['Urgency'] ?? null); @@ -53,8 +50,7 @@ public function itCanHaveAPriority(): void */ #[DoesNotPerformAssertions] #[DataProvider('validHeaders')] - #[Test] - public function itAcceptsValidHeaders(array $headers): void + public function testItAcceptsValidHeaders(array $headers): void { WebPushConfig::fromArray(['headers' => $headers]); } @@ -63,8 +59,7 @@ public function itAcceptsValidHeaders(array $headers): void * @param WebPushHeadersShape $headers */ #[DataProvider('invalidHeaders')] - #[Test] - public function itRejectsInvalidHeaders(array $headers): void + public function testItRejectsInvalidHeaders(array $headers): void { $this->expectException(InvalidArgument::class); diff --git a/tests/Unit/MessagingTest.php b/tests/Unit/MessagingTest.php index 2ab83f5f1..20e3beb2a 100644 --- a/tests/Unit/MessagingTest.php +++ b/tests/Unit/MessagingTest.php @@ -12,7 +12,6 @@ use Kreait\Firebase\Messaging\AppInstanceApiClient; use Kreait\Firebase\Messaging\CloudMessage; use Kreait\Firebase\Tests\UnitTestCase; -use PHPUnit\Framework\Attributes\Test; /** * @internal @@ -30,29 +29,25 @@ protected function setUp(): void $this->messaging = new Messaging($messagingApi, $appInstanceApi, $exceptionConverter); } - #[Test] - public function sendInvalidArray(): void + public function testSendInvalidArray(): void { $this->expectException(InvalidArgumentException::class); $this->messaging->send([]); } - #[Test] - public function subscribeToTopicWithEmptyTokenList(): void + public function testSubscribeToTopicWithEmptyTokenList(): void { $this->expectException(InvalidArgument::class); $this->messaging->subscribeToTopic('topic', []); } - #[Test] - public function unsubscribeFromTopicWithEmptyTokenList(): void + public function testUnsubscribeFromTopicWithEmptyTokenList(): void { $this->expectException(InvalidArgument::class); $this->messaging->unsubscribeFromTopic('topic', []); } - #[Test] - public function itWillNotSendAMessageWithoutATarget(): void + public function testItWillNotSendAMessageWithoutATarget(): void { $message = CloudMessage::new(); diff --git a/tests/Unit/RemoteConfig/ConditionTest.php b/tests/Unit/RemoteConfig/ConditionTest.php index f0236e701..d5aead573 100644 --- a/tests/Unit/RemoteConfig/ConditionTest.php +++ b/tests/Unit/RemoteConfig/ConditionTest.php @@ -8,36 +8,31 @@ use Kreait\Firebase\RemoteConfig\TagColor; use Kreait\Firebase\Tests\UnitTestCase; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; /** * @internal */ final class ConditionTest extends UnitTestCase { - #[Test] - public function itCanBeNamed(): void + public function testItCanBeNamed(): void { $condition = Condition::named('name'); $this->assertSame('name', $condition->name()); } - #[Test] - public function itsDefaultExpressionIsFalseAsString(): void + public function testItsDefaultExpressionIsFalseAsString(): void { $condition = Condition::named('name'); $this->assertSame('false', $condition->expression()); } - #[Test] - public function itsDefaultTagColorIsNotSet(): void + public function testItsDefaultTagColorIsNotSet(): void { $condition = Condition::named('name'); $this->assertNotInstanceOf(TagColor::class, $condition->tagColor()); } - #[Test] - public function itsTagColorCanBeSetWithAString(): void + public function testItsTagColorCanBeSetWithAString(): void { $condition = Condition::named('name')->withTagColor('ORANGE'); $expectedColor = new TagColor('ORANGE'); @@ -50,8 +45,7 @@ public function itsTagColorCanBeSetWithAString(): void * @param array $conditionData */ #[DataProvider('valueProvider')] - #[Test] - public function itCanBeCreatedFromAnArray(string $expectedName, string $expectedExpression, ?TagColor $expectedTagColor, array $conditionData): void + public function testItCanBeCreatedFromAnArray(string $expectedName, string $expectedExpression, ?TagColor $expectedTagColor, array $conditionData): void { $condition = Condition::fromArray($conditionData); diff --git a/tests/Unit/RemoteConfig/ConditionalValueTest.php b/tests/Unit/RemoteConfig/ConditionalValueTest.php index 44b5bf2d0..6b516e4d9 100644 --- a/tests/Unit/RemoteConfig/ConditionalValueTest.php +++ b/tests/Unit/RemoteConfig/ConditionalValueTest.php @@ -7,15 +7,13 @@ use Kreait\Firebase\RemoteConfig\Condition; use Kreait\Firebase\RemoteConfig\ConditionalValue; use Kreait\Firebase\Tests\UnitTestCase; -use PHPUnit\Framework\Attributes\Test; /** * @internal */ final class ConditionalValueTest extends UnitTestCase { - #[Test] - public function create(): void + public function testCreate(): void { $condition = Condition::named('my_condition'); @@ -28,8 +26,7 @@ public function create(): void $this->assertEqualsCanonicalizing(['value' => 'foo'], $conditionalValue->jsonSerialize()); } - #[Test] - public function createWithString(): void + public function testCreateWithString(): void { $value = ConditionalValue::basedOn('foo'); diff --git a/tests/Unit/RemoteConfig/DefaultValueTest.php b/tests/Unit/RemoteConfig/DefaultValueTest.php index 857e96804..807a454a6 100644 --- a/tests/Unit/RemoteConfig/DefaultValueTest.php +++ b/tests/Unit/RemoteConfig/DefaultValueTest.php @@ -7,7 +7,6 @@ use Kreait\Firebase\RemoteConfig\DefaultValue; use Kreait\Firebase\RemoteConfig\ParameterValue; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -17,16 +16,14 @@ */ final class DefaultValueTest extends TestCase { - #[Test] - public function createInAppDefaultValue(): void + public function testCreateInAppDefaultValue(): void { $defaultValue = DefaultValue::useInAppDefault(); $this->assertEqualsCanonicalizing(['useInAppDefault' => true], $defaultValue->jsonSerialize()); } - #[Test] - public function create(): void + public function testCreate(): void { $defaultValue = DefaultValue::with('foo'); @@ -38,8 +35,7 @@ public function create(): void * @param RemoteConfigParameterValueShape $data */ #[DataProvider('arrayValueProvider')] - #[Test] - public function createFromArray(array $expected, array $data): void + public function testCreateFromArray(array $expected, array $data): void { $defaultValue = DefaultValue::fromArray($data); diff --git a/tests/Unit/RemoteConfig/ParameterGroupTest.php b/tests/Unit/RemoteConfig/ParameterGroupTest.php index 0cfb39267..52858b99d 100644 --- a/tests/Unit/RemoteConfig/ParameterGroupTest.php +++ b/tests/Unit/RemoteConfig/ParameterGroupTest.php @@ -6,7 +6,6 @@ use Kreait\Firebase\RemoteConfig\Parameter; use Kreait\Firebase\RemoteConfig\ParameterGroup; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -14,8 +13,7 @@ */ final class ParameterGroupTest extends TestCase { - #[Test] - public function itCanBeCreated(): void + public function testItCanBeCreated(): void { $group = ParameterGroup::named($name = 'name') ->withDescription($description = 'description') diff --git a/tests/Unit/RemoteConfig/ParameterTest.php b/tests/Unit/RemoteConfig/ParameterTest.php index 2bf6d8ba4..c0f3f1880 100644 --- a/tests/Unit/RemoteConfig/ParameterTest.php +++ b/tests/Unit/RemoteConfig/ParameterTest.php @@ -7,31 +7,27 @@ use Kreait\Firebase\RemoteConfig\DefaultValue; use Kreait\Firebase\RemoteConfig\Parameter; use Kreait\Firebase\Tests\UnitTestCase; -use PHPUnit\Framework\Attributes\Test; /** * @internal */ final class ParameterTest extends UnitTestCase { - #[Test] - public function createWithImplicitDefaultValue(): void + public function testCreateWithImplicitDefaultValue(): void { $parameter = Parameter::named('empty'); $this->assertNotInstanceOf(DefaultValue::class, $parameter->defaultValue()); } - #[Test] - public function createWithDefaultValue(): void + public function testCreateWithDefaultValue(): void { $parameter = Parameter::named('with_default_foo', 'foo'); $this->assertEqualsCanonicalizing(DefaultValue::with('foo')->toArray(), $parameter->defaultValue()?->toArray()); } - #[Test] - public function createWithDescription(): void + public function testCreateWithDescription(): void { $parameter = Parameter::named('something')->withDescription('description'); diff --git a/tests/Unit/RemoteConfig/TagColorTest.php b/tests/Unit/RemoteConfig/TagColorTest.php index aa65db6f7..7c8d5aa31 100644 --- a/tests/Unit/RemoteConfig/TagColorTest.php +++ b/tests/Unit/RemoteConfig/TagColorTest.php @@ -7,15 +7,13 @@ use Kreait\Firebase\Exception\InvalidArgumentException; use Kreait\Firebase\RemoteConfig\TagColor; use Kreait\Firebase\Tests\UnitTestCase; -use PHPUnit\Framework\Attributes\Test; /** * @internal */ final class TagColorTest extends UnitTestCase { - #[Test] - public function createWithInvalidValue(): void + public function testCreateWithInvalidValue(): void { $this->expectException(InvalidArgumentException::class); new TagColor('foo'); diff --git a/tests/Unit/RemoteConfig/TemplateTest.php b/tests/Unit/RemoteConfig/TemplateTest.php index 508b76bdb..30d1c4334 100644 --- a/tests/Unit/RemoteConfig/TemplateTest.php +++ b/tests/Unit/RemoteConfig/TemplateTest.php @@ -14,7 +14,6 @@ use Kreait\Firebase\RemoteConfig\Template; use Kreait\Firebase\RemoteConfig\Version; use Kreait\Firebase\Tests\UnitTestCase; -use PHPUnit\Framework\Attributes\Test; use function array_map; @@ -23,20 +22,17 @@ */ final class TemplateTest extends UnitTestCase { - #[Test] - public function getDefaultEtag(): void + public function testGetDefaultEtag(): void { $this->assertSame('*', Template::new()->etag()); } - #[Test] - public function defaultVersionIsNull(): void + public function testDefaultVersionIsNull(): void { $this->assertNotInstanceOf(Version::class, Template::new()->version()); } - #[Test] - public function createWithInvalidConditionalValue(): void + public function testCreateWithInvalidConditionalValue(): void { $parameter = Parameter::named('foo') ->withConditionalValue(ConditionalValue::basedOn('non_existing_condition')) @@ -49,8 +45,7 @@ public function createWithInvalidConditionalValue(): void /** * @see https://github.com/kreait/firebase-php/issues/218 */ - #[Test] - public function conditionNamesAreImportedCorrectlyWhenUsingFromArray(): void + public function testConditionNamesAreImportedCorrectlyWhenUsingFromArray(): void { $given = ['conditions' => [['name' => 'foo', 'expression' => '"true"']]]; @@ -67,8 +62,7 @@ public function conditionNamesAreImportedCorrectlyWhenUsingFromArray(): void $this->assertSame('foo', $template->parameters()['param']->conditionalValues()[0]->conditionName()); } - #[Test] - public function withFluidConfiguration(): void + public function testWithFluidConfiguration(): void { $german = Condition::named('lang_german') ->withExpression("device.language in ['de', 'de_AT', 'de_CH']") @@ -111,8 +105,7 @@ public function withFluidConfiguration(): void $this->assertSame($uiColors, $template->parameterGroups()['ui_colors']); } - #[Test] - public function parametersCanBeRemoved(): void + public function testParametersCanBeRemoved(): void { $template = Template::new() ->withParameter(Parameter::named('foo')) @@ -122,8 +115,7 @@ public function parametersCanBeRemoved(): void $this->assertEmpty($template->parameters()); } - #[Test] - public function parameterGroupsCanBeRemoved(): void + public function testParameterGroupsCanBeRemoved(): void { $template = Template::new() ->withParameterGroup(ParameterGroup::named('group')) @@ -133,8 +125,7 @@ public function parameterGroupsCanBeRemoved(): void $this->assertEmpty($template->parameterGroups()); } - #[Test] - public function personalizationValuesAreImportedInDefaultValues(): void + public function testPersonalizationValuesAreImportedInDefaultValues(): void { $data = [ 'parameters' => [ @@ -156,8 +147,7 @@ public function personalizationValuesAreImportedInDefaultValues(): void $this->assertSame('id', $array['personalizationValue']['personalizationId']); } - #[Test] - public function personalizationValuesAreImportedInConditionalValues(): void + public function testPersonalizationValuesAreImportedInConditionalValues(): void { $data = [ 'conditions' => [ @@ -189,8 +179,7 @@ public function personalizationValuesAreImportedInConditionalValues(): void $this->assertSame('id', $array['personalizationValue']['personalizationId']); } - #[Test] - public function itProvidesConditionNames(): void + public function testItProvidesConditionNames(): void { $this->assertEqualsCanonicalizing( ['first', 'second', 'third'], @@ -202,8 +191,7 @@ public function itProvidesConditionNames(): void ); } - #[Test] - public function conditionsCanBeRemoved(): void + public function testConditionsCanBeRemoved(): void { $this->assertEqualsCanonicalizing( ['first', 'third'], diff --git a/tests/Unit/Request/CreateUserTest.php b/tests/Unit/Request/CreateUserTest.php index a6538a3a1..8feaad98d 100644 --- a/tests/Unit/Request/CreateUserTest.php +++ b/tests/Unit/Request/CreateUserTest.php @@ -8,7 +8,6 @@ use Kreait\Firebase\Request\CreateUser; use Kreait\Firebase\Value\ClearTextPassword; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -16,8 +15,7 @@ */ final class CreateUserTest extends TestCase { - #[Test] - public function createNew(): void + public function testCreateNew(): void { $request = CreateUser::new(); $this->assertEmpty($request->jsonSerialize()); @@ -28,8 +26,7 @@ public function createNew(): void * @param array> $expected */ #[DataProvider('propertiesProvider')] - #[Test] - public function withProperties(array $properties, array $expected): void + public function testWithProperties(array $properties, array $expected): void { $request = CreateUser::withProperties($properties); diff --git a/tests/Unit/Request/UpdateUserTest.php b/tests/Unit/Request/UpdateUserTest.php index 83df95cc0..0a89663a4 100644 --- a/tests/Unit/Request/UpdateUserTest.php +++ b/tests/Unit/Request/UpdateUserTest.php @@ -9,7 +9,6 @@ use Kreait\Firebase\Exception\InvalidArgumentException; use Kreait\Firebase\Request\UpdateUser; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -22,16 +21,14 @@ final class UpdateUserTest extends TestCase * @param array> $expected */ #[DataProvider('propertiesProvider')] - #[Test] - public function withProperties(array $properties, array $expected): void + public function testWithProperties(array $properties, array $expected): void { $request = UpdateUser::withProperties($properties); $this->assertEqualsCanonicalizing($expected, $request->jsonSerialize()); } - #[Test] - public function withMissingUid(): void + public function testWithMissingUid(): void { $this->expectException(InvalidArgumentException::class); UpdateUser::withProperties([])->jsonSerialize(); diff --git a/tests/Unit/ServiceAccountTest.php b/tests/Unit/ServiceAccountTest.php index 8c877819e..b5fa26a68 100644 --- a/tests/Unit/ServiceAccountTest.php +++ b/tests/Unit/ServiceAccountTest.php @@ -6,6 +6,7 @@ use Kreait\Firebase\ServiceAccount; use Kreait\Firebase\Valinor\Mapper; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; use PHPUnit\Framework\TestCase; final class ServiceAccountTest extends TestCase @@ -13,6 +14,7 @@ final class ServiceAccountTest extends TestCase /** * @see https://github.com/kreait/firebase-php/pull/1034 */ + #[DoesNotPerformAssertions] public function testItCanBeMapped(): void { $mapper = (new Mapper())->allowSuperfluousKeys()->snakeToCamelCase(); @@ -24,8 +26,6 @@ public function testItCanBeMapped(): void 'private_key' => 'private-key', ]; - $serviceAccount = $mapper->map(ServiceAccount::class, $input); - - $this->assertInstanceOf(ServiceAccount::class, $serviceAccount); + $mapper->map(ServiceAccount::class, $input); } } diff --git a/tests/Unit/StorageTest.php b/tests/Unit/StorageTest.php index eb188a208..9f8a1e263 100644 --- a/tests/Unit/StorageTest.php +++ b/tests/Unit/StorageTest.php @@ -6,7 +6,6 @@ use Google\Cloud\Storage\StorageClient; use Kreait\Firebase\Storage; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use RuntimeException; @@ -15,8 +14,7 @@ */ final class StorageTest extends TestCase { - #[Test] - public function itReturnsTheSameClientItWasGiven(): void + public function testItReturnsTheSameClientItWasGiven(): void { $client = $this->createMock(StorageClient::class); $storage = new Storage($client); @@ -24,8 +22,7 @@ public function itReturnsTheSameClientItWasGiven(): void $this->assertSame($client, $storage->getStorageClient()); } - #[Test] - public function itComplainsWhenNoDefaultBucketWasProvided(): void + public function testItComplainsWhenNoDefaultBucketWasProvided(): void { $client = $this->createMock(StorageClient::class); $storage = new Storage($client); diff --git a/tests/Unit/Util/DTTest.php b/tests/Unit/Util/DTTest.php index 391af9acb..7728b079d 100644 --- a/tests/Unit/Util/DTTest.php +++ b/tests/Unit/Util/DTTest.php @@ -10,7 +10,6 @@ use Iterator; use Kreait\Firebase\Util\DT; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use stdClass; @@ -23,8 +22,7 @@ final class DTTest extends TestCase { #[DataProvider('validFixedValues')] - #[Test] - public function convertWithFixedValues(string $expected, mixed $value): void + public function testConvertWithFixedValues(string $expected, mixed $value): void { $dt = DT::toUTCDateTimeImmutable($value); @@ -33,8 +31,7 @@ public function convertWithFixedValues(string $expected, mixed $value): void } #[DataProvider('validVariableValues')] - #[Test] - public function convertWithVariableValues(mixed $value): void + public function testConvertWithVariableValues(mixed $value): void { $dt = DT::toUTCDateTimeImmutable($value); @@ -42,8 +39,7 @@ public function convertWithVariableValues(mixed $value): void } #[DataProvider('invalidValues')] - #[Test] - public function convertInvalid(mixed $value): void + public function testConvertInvalid(mixed $value): void { $this->expectException(InvalidArgumentException::class); diff --git a/tests/Unit/Valinor/SourceTest.php b/tests/Unit/Valinor/SourceTest.php index caa1f1c7c..f3d9aa810 100644 --- a/tests/Unit/Valinor/SourceTest.php +++ b/tests/Unit/Valinor/SourceTest.php @@ -6,29 +6,25 @@ use Kreait\Firebase\Exception\InvalidArgumentException; use Kreait\Firebase\Valinor\Source; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; -class SourceTest extends TestCase +final class SourceTest extends TestCase { - #[Test] - public function itSupportsJsonObjectStrings(): void + public function testItSupportsJsonObjectStrings(): void { $source = Source::parse('{"foo": "bar"}'); $this->assertSame(['foo' => 'bar'], iterator_to_array($source)); } - #[Test] - public function itSupportsJsonArrayStrings(): void + public function testItSupportsJsonArrayStrings(): void { $source = Source::parse('[{"foo": "bar"}]'); $this->assertSame([['foo' => 'bar']], iterator_to_array($source)); } - #[Test] - public function itRejectsInvalidJsonStrings(): void + public function testItRejectsInvalidJsonStrings(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid JSON source'); @@ -36,8 +32,7 @@ public function itRejectsInvalidJsonStrings(): void Source::parse('{'); } - #[Test] - public function itSupportsJsonFiles(): void + public function testItSupportsJsonFiles(): void { $path = sys_get_temp_dir().'/'.uniqid(base64_encode(__METHOD__), true).'.json'; file_put_contents($path, '{"foo": "bar"}'); @@ -51,16 +46,14 @@ public function itSupportsJsonFiles(): void } } - #[Test] - public function itSupportsJsonFilesWithFileExtensionsNotSuggestingJson(): void + public function testItSupportsJsonFilesWithFileExtensionsNotSuggestingJson(): void { $source = Source::parse(__DIR__.'/valid.txt'); $this->assertSame(['foo' => 'bar'], iterator_to_array($source)); } - #[Test] - public function itRejectsInvalidFiles(): void + public function testItRejectsInvalidFiles(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessageMatches('/no such file/i'); @@ -68,16 +61,14 @@ public function itRejectsInvalidFiles(): void Source::parse(sys_get_temp_dir().'/'.uniqid(base64_encode(__METHOD__), true).'.json'); } - #[Test] - public function itSupportsArrays(): void + public function testItSupportsArrays(): void { $source = Source::parse(['foo' => 'bar']); $this->assertSame(['foo' => 'bar'], iterator_to_array($source)); } - #[Test] - public function itSupportsIterables(): void + public function testItSupportsIterables(): void { $iterable = fn() => yield ['foo' => 'bar']; diff --git a/tests/Unit/Value/ClearTextPasswordTest.php b/tests/Unit/Value/ClearTextPasswordTest.php index 0ae6b988d..c8ca44a9f 100644 --- a/tests/Unit/Value/ClearTextPasswordTest.php +++ b/tests/Unit/Value/ClearTextPasswordTest.php @@ -8,7 +8,6 @@ use Kreait\Firebase\Exception\InvalidArgumentException; use Kreait\Firebase\Value\ClearTextPassword; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -17,8 +16,7 @@ final class ClearTextPasswordTest extends TestCase { #[DataProvider('validValues')] - #[Test] - public function withValidValue(mixed $value): void + public function testWithValidValue(mixed $value): void { $password = ClearTextPassword::fromString($value)->value; @@ -26,8 +24,7 @@ public function withValidValue(mixed $value): void } #[DataProvider('invalidValues')] - #[Test] - public function withInvalidValue(mixed $value): void + public function testWithInvalidValue(mixed $value): void { $this->expectException(InvalidArgumentException::class); ClearTextPassword::fromString($value); diff --git a/tests/Unit/Value/EmailTest.php b/tests/Unit/Value/EmailTest.php index 16eeeff24..a2fcc1e80 100644 --- a/tests/Unit/Value/EmailTest.php +++ b/tests/Unit/Value/EmailTest.php @@ -8,7 +8,6 @@ use Kreait\Firebase\Exception\InvalidArgumentException; use Kreait\Firebase\Value\Email; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -17,8 +16,7 @@ final class EmailTest extends TestCase { #[DataProvider('validValues')] - #[Test] - public function withValidValue(string $value): void + public function testWithValidValue(string $value): void { $email = Email::fromString($value)->value; @@ -26,8 +24,7 @@ public function withValidValue(string $value): void } #[DataProvider('invalidValues')] - #[Test] - public function withInvalidValue(string $value): void + public function testWithInvalidValue(string $value): void { $this->expectException(InvalidArgumentException::class); Email::fromString($value); diff --git a/tests/Unit/Value/UidTest.php b/tests/Unit/Value/UidTest.php index 56d88f4cc..e8b0277d4 100644 --- a/tests/Unit/Value/UidTest.php +++ b/tests/Unit/Value/UidTest.php @@ -8,7 +8,6 @@ use Kreait\Firebase\Exception\InvalidArgumentException; use Kreait\Firebase\Value\Uid; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use function str_repeat; @@ -19,15 +18,13 @@ final class UidTest extends TestCase { #[DataProvider('validValues')] - #[Test] - public function withValidValue(string $uid): void + public function testWithValidValue(string $uid): void { $this->assertSame($uid, Uid::fromString($uid)->value); } #[DataProvider('invalidValues')] - #[Test] - public function withInvalidValue(string $uid): void + public function testWithInvalidValue(string $uid): void { $this->expectException(InvalidArgumentException::class); Uid::fromString($uid); diff --git a/tests/Unit/Value/UrlTest.php b/tests/Unit/Value/UrlTest.php index 4424f8c1d..2975250a3 100644 --- a/tests/Unit/Value/UrlTest.php +++ b/tests/Unit/Value/UrlTest.php @@ -8,9 +8,7 @@ use Kreait\Firebase\Exception\InvalidArgumentException; use Kreait\Firebase\Value\Url; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; -use Stringable; /** * @internal @@ -18,19 +16,17 @@ final class UrlTest extends TestCase { #[DataProvider('validValues')] - #[Test] - public function withValidValue(Stringable|string $value): void + public function testWithValidValue(string $value): void { $url = Url::fromString($value)->value; - $check = (string) $value; + $check = $value; $this->assertSame($check, $url); } #[DataProvider('invalidValues')] - #[Test] - public function withInvalidValue(string $value): void + public function testWithInvalidValue(string $value): void { $this->expectException(InvalidArgumentException::class); Url::fromString($value);