Skip to content

Commit

Permalink
Import names
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegamez committed Aug 19, 2024
1 parent 82062f6 commit 1492a99
Show file tree
Hide file tree
Showing 39 changed files with 98 additions and 56 deletions.
1 change: 1 addition & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
phpunitCodeQuality: true,
phpunit: true,
)
->withImportNames(removeUnusedImports: true)
;
9 changes: 6 additions & 3 deletions src/Firebase/Contract/AppCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Kreait\Firebase\AppCheck\AppCheckTokenOptions;
use Kreait\Firebase\AppCheck\VerifyAppCheckTokenResponse;
use Kreait\Firebase\Exception;
use Kreait\Firebase\Exception\AppCheck\FailedToVerifyAppCheckToken;
use Kreait\Firebase\Exception\AppCheck\InvalidAppCheckToken;
use Kreait\Firebase\Exception\AppCheck\InvalidAppCheckTokenOptions;

/**
* @phpstan-import-type AppCheckTokenOptionsShape from AppCheckTokenOptions
Expand All @@ -18,7 +21,7 @@ interface AppCheck
* @param non-empty-string $appId
* @param AppCheckTokenOptions|AppCheckTokenOptionsShape|null $options
*
* @throws Exception\AppCheck\InvalidAppCheckTokenOptions
* @throws InvalidAppCheckTokenOptions
* @throws Exception\AppCheckException
* @throws Exception\FirebaseException
*/
Expand All @@ -27,8 +30,8 @@ public function createToken(string $appId, $options = null): AppCheckToken;
/**
* @param non-empty-string $appCheckToken
*
* @throws Exception\AppCheck\InvalidAppCheckToken
* @throws Exception\AppCheck\FailedToVerifyAppCheckToken
* @throws InvalidAppCheckToken
* @throws FailedToVerifyAppCheckToken
* @throws Exception\AppCheckException
* @throws Exception\FirebaseException
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Firebase/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use Kreait\Firebase\JWT\IdTokenVerifier;
use Kreait\Firebase\JWT\SessionCookieVerifier;
use Kreait\Firebase\Messaging\AppInstanceApiClient;
use Kreait\Firebase\Messaging\RequestFactory;
use Psr\Cache\CacheItemPoolInterface;
use Psr\Clock\ClockInterface;
use Psr\Http\Message\UriInterface;
Expand Down Expand Up @@ -406,7 +407,7 @@ public function createMessaging(): Contract\Messaging
$projectId = $this->getProjectId();

$errorHandler = new MessagingApiExceptionConverter($this->clock);
$requestFactory = new Messaging\RequestFactory(
$requestFactory = new RequestFactory(
requestFactory: $this->httpFactory,
streamFactory: $this->httpFactory,
);
Expand Down
3 changes: 2 additions & 1 deletion tests/Integration/Database/ReferenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Kreait\Firebase\Tests\Integration\Database;

use Iterator;
use Kreait\Firebase\Contract\Database;
use Kreait\Firebase\Database\Reference;
use Kreait\Firebase\Tests\Integration\DatabaseTestCase;
Expand Down Expand Up @@ -150,7 +151,7 @@ public function setServerTimestamp(): void
$this->assertIsInt($value['updatedAt']);
}

public static function validValues(): \Iterator
public static function validValues(): Iterator
{
yield 'string' => ['string', 'value'];
yield 'int' => ['int', 1];
Expand Down
3 changes: 2 additions & 1 deletion tests/Integration/MessagingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Kreait\Firebase\Tests\Integration;

use Iterator;
use Kreait\Firebase\Contract\Messaging;
use Kreait\Firebase\Exception\Messaging\InvalidArgument;
use Kreait\Firebase\Exception\Messaging\InvalidMessage;
Expand Down Expand Up @@ -154,7 +155,7 @@ public function sendMessageWithReservedKeywordInMessageDataThatIsStillAccepted(s
$this->addToAssertionCount(1);
}

public static function reservedKeywordsThatStillAreAccepted(): \Iterator
public static function reservedKeywordsThatStillAreAccepted(): Iterator
{
yield 'notification' => ['notification'];
}
Expand Down
5 changes: 3 additions & 2 deletions tests/Unit/AppCheck/AppCheckTokenOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Kreait\Firebase\Tests\Unit\AppCheck;

use Iterator;
use Kreait\Firebase\AppCheck\AppCheckTokenOptions;
use Kreait\Firebase\Exception\AppCheck\InvalidAppCheckTokenOptions;
use Kreait\Firebase\Tests\UnitTestCase;
Expand Down Expand Up @@ -45,15 +46,15 @@ public function fromArrayWithInvalidOptions(int $ttl): void
]);
}

public static function validOptions(): \Iterator
public static function validOptions(): Iterator
{
yield 'null' => [null];
yield 'min-boundary' => [1800];
yield 'mid-range' => [30240];
yield 'max-boundary' => [60480];
}

public static function invalidOptions(): \Iterator
public static function invalidOptions(): Iterator
{
yield 'too-small' => [1799];
yield 'too-large' => [604801];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Kreait\Firebase\Tests\Unit\Auth\ActionCodeSettings;

use InvalidArgumentException;
use Iterator;
use Kreait\Firebase\Auth\ActionCodeSettings\ValidatedActionCodeSettings;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
Expand Down Expand Up @@ -39,7 +40,7 @@ public function itCanBeEmpty(): void
$this->assertEmpty(ValidatedActionCodeSettings::empty()->toArray());
}

public static function validInputs(): \Iterator
public static function validInputs(): Iterator
{
$continueUrl = 'https://example.com';
yield 'full' => [
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Auth/SignInResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Kreait\Firebase\Tests\Unit\Auth;

use Iterator;
use Kreait\Firebase\Auth\SignInResult;
use Kreait\Firebase\Tests\UnitTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
Expand Down Expand Up @@ -47,7 +48,7 @@ public function itUsesTheLocalIdWhenTheFirebaseUidIsNotPresent(): void
$this->assertSame('some-id', $result->firebaseUserId());
}

public static function fullResponse(): \Iterator
public static function fullResponse(): Iterator
{
yield 'snake_cased' => [[
'idToken' => 'idToken',
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Database/Query/Filter/EndAtTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Kreait\Firebase\Tests\Unit\Database\Query\Filter;

use GuzzleHttp\Psr7\Uri;
use Iterator;
use Kreait\Firebase\Database\Query\Filter\EndAt;
use Kreait\Firebase\Tests\UnitTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
Expand All @@ -24,7 +25,7 @@ public function modifyUri(mixed $given, string $expected): void
$this->assertStringContainsString($expected, (string) $filter->modifyUri(new Uri('http://example.com')));
}

public static function valueProvider(): \Iterator
public static function valueProvider(): Iterator
{
yield 'int' => [1, 'endAt=1'];
yield 'string' => ['value', 'endAt=%22value%22'];
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Database/Query/Filter/EndBeforeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Kreait\Firebase\Tests\Unit\Database\Query\Filter;

use GuzzleHttp\Psr7\Uri;
use Iterator;
use Kreait\Firebase\Database\Query\Filter\EndBefore;
use Kreait\Firebase\Tests\UnitTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
Expand All @@ -24,7 +25,7 @@ public function modifyUri(mixed $given, string $expected): void
$this->assertStringContainsString($expected, (string) $filter->modifyUri(new Uri('http://example.com')));
}

public static function valueProvider(): \Iterator
public static function valueProvider(): Iterator
{
yield 'int' => [1, 'endBefore=1'];
yield 'string' => ['value', 'endBefore=%22value%22'];
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Database/Query/Filter/EqualToTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Kreait\Firebase\Tests\Unit\Database\Query\Filter;

use GuzzleHttp\Psr7\Uri;
use Iterator;
use Kreait\Firebase\Database\Query\Filter\EqualTo;
use Kreait\Firebase\Tests\UnitTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
Expand All @@ -24,7 +25,7 @@ public function modifyUri(mixed $given, string $expected): void
$this->assertStringContainsString($expected, (string) $filter->modifyUri(new Uri('http://example.com')));
}

public static function valueProvider(): \Iterator
public static function valueProvider(): Iterator
{
yield 'int' => [1, 'equalTo=1'];
yield 'string' => ['value', 'equalTo=%22value%22'];
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Database/Query/Filter/StartAfterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Kreait\Firebase\Tests\Unit\Database\Query\Filter;

use GuzzleHttp\Psr7\Uri;
use Iterator;
use Kreait\Firebase\Database\Query\Filter\StartAfter;
use Kreait\Firebase\Tests\UnitTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
Expand All @@ -24,7 +25,7 @@ public function modifyUri(mixed $given, mixed $expected): void
$this->assertStringContainsString($expected, (string) $filter->modifyUri(new Uri('http://example.com')));
}

public static function valueProvider(): \Iterator
public static function valueProvider(): Iterator
{
yield 'int' => [1, 'startAfter=1'];
yield 'string' => ['value', 'startAfter=%22value%22'];
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Database/Query/Filter/StartAtTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Kreait\Firebase\Tests\Unit\Database\Query\Filter;

use GuzzleHttp\Psr7\Uri;
use Iterator;
use Kreait\Firebase\Database\Query\Filter\StartAt;
use Kreait\Firebase\Tests\UnitTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
Expand All @@ -24,7 +25,7 @@ public function modifyUri(mixed $given, string $expected): void
$this->assertStringContainsString($expected, (string) $filter->modifyUri(new Uri('http://example.com')));
}

public static function valueProvider(): \Iterator
public static function valueProvider(): Iterator
{
yield 'int' => [1, 'startAt=1'];
yield 'string' => ['value', 'startAt=%22value%22'];
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Database/Query/Sorter/OrderByChildTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Kreait\Firebase\Tests\Unit\Database\Query\Sorter;

use GuzzleHttp\Psr7\Uri;
use Iterator;
use Kreait\Firebase\Database\Query\Sorter\OrderByChild;
use Kreait\Firebase\Tests\UnitTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
Expand Down Expand Up @@ -32,7 +33,7 @@ public function orderByChild(string $childKey, mixed $expected, mixed $given): v
$this->assertSame($expected, $sut->modifyValue($given));
}

public static function valueProvider(): \Iterator
public static function valueProvider(): Iterator
{
yield 'scalar' => [
'childKey' => 'key',
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Database/Query/Sorter/OrderByKeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Kreait\Firebase\Tests\Unit\Database\Query\Sorter;

use GuzzleHttp\Psr7\Uri;
use Iterator;
use Kreait\Firebase\Database\Query\Sorter\OrderByKey;
use Kreait\Firebase\Tests\UnitTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
Expand Down Expand Up @@ -40,7 +41,7 @@ public function modifyValue(mixed $expected, mixed $given): void
$this->assertSame($expected, $this->sorter->modifyValue($given));
}

public static function valueProvider(): \Iterator
public static function valueProvider(): Iterator
{
yield 'scalar' => [
'expected' => 'scalar',
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Database/Query/Sorter/OrderByValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Kreait\Firebase\Tests\Unit\Database\Query\Sorter;

use GuzzleHttp\Psr7\Uri;
use Iterator;
use Kreait\Firebase\Database\Query\Sorter\OrderByValue;
use Kreait\Firebase\Tests\UnitTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
Expand Down Expand Up @@ -40,7 +41,7 @@ public function modifyValue(mixed $expected, mixed $given): void
$this->assertSame($expected, $this->sorter->modifyValue($given));
}

public static function valueProvider(): \Iterator
public static function valueProvider(): Iterator
{
yield 'scalar' => [
'expected' => 'scalar',
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Database/Reference/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Kreait\Firebase\Tests\Unit\Database\Reference;

use GuzzleHttp\Psr7\Uri;
use Iterator;
use Kreait\Firebase\Database\Reference\Validator;
use Kreait\Firebase\Exception\InvalidArgumentException;
use Kreait\Firebase\Tests\UnitTestCase;
Expand Down Expand Up @@ -59,7 +60,7 @@ public function validateChars(string $value): void
$this->validator->validateUri($uri);
}

public static function invalidChars(): \Iterator
public static function invalidChars(): Iterator
{
yield '.' => ['.'];
yield '$' => ['$'];
Expand Down
7 changes: 4 additions & 3 deletions tests/Unit/Database/UrlBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Kreait\Firebase\Tests\Unit\Database;

use InvalidArgumentException;
use Iterator;
use Kreait\Firebase\Database\UrlBuilder;
use Kreait\Firebase\Tests\UnitTestCase;
use Kreait\Firebase\Util;
Expand Down Expand Up @@ -32,7 +33,7 @@ public function withInvalidUrl(string $url): void
UrlBuilder::create($url);
}

public static function invalidUrls(): \Iterator
public static function invalidUrls(): Iterator
{
yield 'wrong scheme' => ['http://example.com'];
yield 'no scheme' => ['example.com'];
Expand Down Expand Up @@ -67,7 +68,7 @@ public function emulated(string $emulatorHost, string $baseUrl, string $path, ar
$this->assertSame($expected, $url);
}

public static function realUrls(): \Iterator
public static function realUrls(): Iterator
{
$baseUrl = 'https://project.region.example.com';
yield 'empty path, empty query' => [
Expand Down Expand Up @@ -108,7 +109,7 @@ public static function realUrls(): \Iterator
];
}

public static function emulatedUrls(): \Iterator
public static function emulatedUrls(): Iterator
{
$namespace = 'namespace';
$baseUrl = 'https://'.$namespace.'.example.com';
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Exception/AppCheckApiExceptionConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use Iterator;
use Kreait\Firebase\Exception\AppCheck\ApiConnectionFailed;
use Kreait\Firebase\Exception\AppCheck\AppCheckError;
use Kreait\Firebase\Exception\AppCheck\PermissionDenied;
Expand Down Expand Up @@ -55,7 +56,7 @@ public function itConvertsExceptions(Throwable $e, string $expectedClass): void
$this->assertInstanceOf($expectedClass, $converted);
}

public static function exceptions(): \Iterator
public static function exceptions(): Iterator
{
yield 'connection error' => [new ConnectException('Connection Failed', new Request('GET', 'https://example.com')), ApiConnectionFailed::class];
yield '401' => [self::createRequestException(401, 'Unauthenticated'), PermissionDenied::class];
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Exception/AuthApiExceptionConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use Iterator;
use Kreait\Firebase\Exception\Auth\ApiConnectionFailed;
use Kreait\Firebase\Exception\Auth\AuthError;
use Kreait\Firebase\Exception\Auth\CredentialsMismatch;
Expand Down Expand Up @@ -104,7 +105,7 @@ public function itConvertsRequestExceptionsBecause(string $identifier, string $e
$this->assertInstanceOf($expectedClass, $convertedError);
}

public static function requestErrors(): \Iterator
public static function requestErrors(): Iterator
{
yield 'credentials mismatch' => ['CREDENTIALS_MISMATCH', CredentialsMismatch::class];
yield 'an email already exists' => ['EMAIL_EXISTS', EmailExists::class];
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Exception/MessagingApiExceptionConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use Iterator;
use Kreait\Firebase\Exception\Messaging\ApiConnectionFailed;
use Kreait\Firebase\Exception\Messaging\AuthenticationError;
use Kreait\Firebase\Exception\Messaging\InvalidMessage;
Expand Down Expand Up @@ -66,7 +67,7 @@ public function itConvertsExceptions(Throwable $e, string $expectedClass): void
$this->assertInstanceOf($expectedClass, $converted);
}

public static function exceptions(): \Iterator
public static function exceptions(): Iterator
{
yield 'connection error' => [new ConnectException('Connection Failed', new Request('GET', 'https://example.com')), ApiConnectionFailed::class];
yield '400' => [self::createRequestException(400, 'Bad request'), InvalidMessage::class];
Expand Down
Loading

0 comments on commit 1492a99

Please sign in to comment.