Skip to content

Commit b19c167

Browse files
committed
Move getUserByProviderUid() method into the Auth contract
1 parent 4c2b167 commit b19c167

File tree

7 files changed

+15
-65
lines changed

7 files changed

+15
-65
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ If it saves you or your team time, please consider [sponsoring its development](
1313
and has been removed from the SDK.
1414
* Deprecated classes, methods and class constants have been removed.
1515
* Type declarations have been simplified to reduce runtime overhead (e.g., `Stringable|string` to `string`).
16+
* The transitional `Kreait\Firebase\Contract\Transitional\FederatedUserFetcher::getUserByProviderUid()` method
17+
has been moved into the `Kreait\Firebase\Contract\Auth` interface
1618

1719
See **[UPGRADE-8.0](UPGRADE-8.0.md) for more details on the changes between 7.x and 8.0.**
1820

UPGRADE-8.0.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ be trivial (e.g., passing `$user->uid` instead of `$user`). Run your test suite
2828
The following list has been generated with [roave/backward-compatibility-check](https://github.com/Roave/BackwardCompatibilityCheck).
2929

3030
```
31+
[BC] ADDED: Method getUserByProviderUid() was added to interface Kreait\Firebase\Contract\Auth
3132
[BC] CHANGED: Default parameter value for parameter $code of Kreait\Firebase\Exception\Database\TransactionFailed#__construct() changed from 0 to NULL
3233
[BC] CHANGED: Default parameter value for parameter $code of Kreait\Firebase\Exception\Database\UnsupportedQuery#__construct() changed from 0 to NULL
3334
[BC] CHANGED: The number of required arguments for Kreait\Firebase\Exception\Database\UnsupportedQuery#__construct() increased from 1 to 2
@@ -99,10 +100,6 @@ The following list has been generated with [roave/backward-compatibility-check](
99100
[BC] CHANGED: The parameter $provider of Kreait\Firebase\Contract\Auth#unlinkProvider() changed from array|Stringable|string to a non-contravariant array|string
100101
[BC] CHANGED: The parameter $provider of Kreait\Firebase\Contract\Auth#unlinkProvider() changed from array|Stringable|string to array|string
101102
[BC] CHANGED: The parameter $provider of Kreait\Firebase\Request\UpdateUser#withRemovedProvider() changed from no type to a non-contravariant string
102-
[BC] CHANGED: The parameter $providerId of Kreait\Firebase\Contract\Transitional\FederatedUserFetcher#getUserByProviderUid() changed from Stringable|string to a non-contravariant string
103-
[BC] CHANGED: The parameter $providerId of Kreait\Firebase\Contract\Transitional\FederatedUserFetcher#getUserByProviderUid() changed from Stringable|string to string
104-
[BC] CHANGED: The parameter $providerUid of Kreait\Firebase\Contract\Transitional\FederatedUserFetcher#getUserByProviderUid() changed from Stringable|string to a non-contravariant string
105-
[BC] CHANGED: The parameter $providerUid of Kreait\Firebase\Contract\Transitional\FederatedUserFetcher#getUserByProviderUid() changed from Stringable|string to string
106103
[BC] CHANGED: The parameter $redirectUrl of Kreait\Firebase\Contract\Auth#signInWithIdpAccessToken() changed from no type to a non-contravariant string|null
107104
[BC] CHANGED: The parameter $redirectUrl of Kreait\Firebase\Contract\Auth#signInWithIdpAccessToken() changed from no type to string|null
108105
[BC] CHANGED: The parameter $redirectUrl of Kreait\Firebase\Contract\Auth#signInWithIdpIdToken() changed from no type to a non-contravariant string|null
@@ -145,6 +142,7 @@ The following list has been generated with [roave/backward-compatibility-check](
145142
[BC] CHANGED: The return type of Kreait\Firebase\RemoteConfig\ConditionalValue#value() changed from no type to string|array
146143
[BC] CHANGED: The return type of Kreait\Firebase\RemoteConfig\TagColor#__toString() changed from no type to string
147144
[BC] REMOVED: Class Kreait\Firebase\Contract\DynamicLinks has been deleted
145+
[BC] REMOVED: Class Kreait\Firebase\Contract\Transitional\FederatedUserFetcher has been deleted
148146
[BC] REMOVED: Class Kreait\Firebase\DynamicLink has been deleted
149147
[BC] REMOVED: Class Kreait\Firebase\DynamicLink\AnalyticsInfo has been deleted
150148
[BC] REMOVED: Class Kreait\Firebase\DynamicLink\AnalyticsInfo\GooglePlayAnalytics has been deleted

docs/user-management.rst

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -165,32 +165,6 @@ You can retrieve a user by their federated identity provider UID (e.g. Google, F
165165
echo $e->getMessage();
166166
}
167167
168-
.. note::
169-
Since this method couldn't be added to the ``Kreait\Firebase\Contract\Auth`` interface without causing a breaking
170-
change, a new transitional interface/contract named ``Kreait\Firebase\Contract\Transitional\FederatedUserFetcher``
171-
was added. This interface will be removed in the next major version of the SDK.
172-
173-
There are several ways to check if you can use the ``getUserByProviderUid()`` method:
174-
175-
.. code-block:: php
176-
177-
use Kreait\Firebase\Contract\Transitional\FederatedUserFetcher;
178-
use Kreait\Firebase\Factory;
179-
180-
$auth = (new Factory())->createAuth();
181-
182-
if (method_exists($auth, 'getUserByProviderUid')) {
183-
$user = $auth->getUserByProviderUid('google.com', 'google-uid');
184-
}
185-
186-
if ($auth instanceof \Kreait\Firebase\Auth) { // This is the implementation, not the interface
187-
$user = $auth->getUserByProviderUid('google.com', 'google-uid');
188-
}
189-
190-
if ($auth instanceof FederatedUserFetcher) {
191-
$user = $auth->getUserByProviderUid('google.com', 'google-uid');
192-
}
193-
194168
************************************
195169
Get information about multiple users
196170
************************************

src/Firebase/Auth.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use Kreait\Firebase\Auth\SignInWithRefreshToken;
2525
use Kreait\Firebase\Auth\UserQuery;
2626
use Kreait\Firebase\Auth\UserRecord;
27-
use Kreait\Firebase\Contract\Transitional\FederatedUserFetcher;
2827
use Kreait\Firebase\Exception\Auth\AuthError;
2928
use Kreait\Firebase\Exception\Auth\FailedToVerifySessionCookie;
3029
use Kreait\Firebase\Exception\Auth\FailedToVerifyToken;
@@ -61,7 +60,7 @@
6160
*
6261
* @phpstan-import-type UserRecordResponseShape from UserRecord
6362
*/
64-
final readonly class Auth implements Contract\Auth, FederatedUserFetcher
63+
final readonly class Auth implements Contract\Auth
6564
{
6665
private Parser $jwtParser;
6766

src/Firebase/Contract/Auth.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,16 @@ public function getUserByEmail(string $email): UserRecord;
123123
*/
124124
public function getUserByPhoneNumber(string $phoneNumber): UserRecord;
125125

126+
/**
127+
* @param non-empty-string $providerId
128+
* @param non-empty-string $providerUid
129+
*
130+
* @throws UserNotFound
131+
* @throws Exception\AuthException
132+
* @throws Exception\FirebaseException
133+
*/
134+
public function getUserByProviderUid(string $providerId, string $providerUid): UserRecord;
135+
126136
/**
127137
* @throws Exception\AuthException
128138
* @throws Exception\FirebaseException

src/Firebase/Contract/Transitional/FederatedUserFetcher.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/Integration/AuthTestCase.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Kreait\Firebase\Auth\SignIn\FailedToSignIn;
1414
use Kreait\Firebase\Auth\UserRecord;
1515
use Kreait\Firebase\Contract\Auth;
16-
use Kreait\Firebase\Contract\Transitional\FederatedUserFetcher;
1716
use Kreait\Firebase\Exception\Auth\InvalidOobCode;
1817
use Kreait\Firebase\Exception\Auth\RevokedIdToken;
1918
use Kreait\Firebase\Exception\Auth\RevokedSessionCookie;
@@ -496,10 +495,6 @@ public function testGetUserByProviderUid(): void
496495
}
497496

498497
$auth = $this->auth;
499-
if (!($auth instanceof FederatedUserFetcher)) {
500-
$this->markTestSkipped('This test requires a FederatedUserFetcher implementation.');
501-
}
502-
503498
$phoneNumber = '+1234567'.random_int(1000, 9999);
504499

505500
$user = $this->auth->createUser([
@@ -523,9 +518,6 @@ public function testGetUserByNonExistingProviderUid(): void
523518
}
524519

525520
$auth = $this->auth;
526-
if (!($auth instanceof FederatedUserFetcher)) {
527-
$this->markTestSkipped('This test requires a FederatedUserFetcher implementation.');
528-
}
529521

530522
$this->expectException(UserNotFound::class);
531523
$auth->getUserByProviderUid('phone', '+192837465');

0 commit comments

Comments
 (0)