diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d1dd269..f2f21b5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: fail-fast: false matrix: operating-system: [ ubuntu-latest ] - php-versions: [ '7.4', '8.0', '8.1' ] + php-versions: [ '7.4', '8.0', '8.1', '8.4' ] composer-dependencies: [ '', '--prefer-lowest' ] extra-label: [ '' ] include: @@ -28,6 +28,11 @@ jobs: operating-system: windows-latest coverage: xdebug + # Windows + - php-versions: '8.4' + operating-system: windows-latest + coverage: xdebug + steps: # see https://github.com/actions/checkout/issues/226#issue-606867805 - name: Prepare git diff --git a/.gitignore b/.gitignore index c8002c6..a46912d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ phpunit.xml composer.lock build/ /.phpunit.result.cache +/docker/ +/.idea/ +/Makefile diff --git a/composer.json b/composer.json index 5fd13dd..347414a 100644 --- a/composer.json +++ b/composer.json @@ -25,11 +25,11 @@ "composer/ca-bundle": "^1.5" }, "require-dev": { - "phpunit/phpunit": "9.5.10", + "phpunit/phpunit": "^9.6", "squizlabs/php_codesniffer": "3.6.1", - "phpstan/phpstan": "1.11.5", - "phpstan/phpstan-phpunit": "1.4.0", - "phpstan/phpstan-strict-rules": "1.6.0" + "phpstan/phpstan": "^2.1", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0" }, "autoload": { "psr-4": { diff --git a/src/FioApi/Downloader.php b/src/FioApi/Downloader.php index 89682e3..0ab7783 100644 --- a/src/FioApi/Downloader.php +++ b/src/FioApi/Downloader.php @@ -9,9 +9,7 @@ use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\BadResponseException; -use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\RequestOptions; -use Psr\Http\Message\ResponseInterface; class Downloader { @@ -21,7 +19,7 @@ class Downloader /** @var ?ClientInterface */ protected $client; - public function __construct(string $token, ClientInterface $client = null) + public function __construct(string $token, ?ClientInterface $client = null) { $this->urlBuilder = new UrlBuilder($token); $this->client = $client; @@ -84,10 +82,10 @@ private function downloadTransactionsList(string $url): TransactionList private function handleException(BadResponseException $e): void { - if ($e->getCode() == 409) { + if ($e->getCode() === 409) { throw new TooGreedyException('You can use one token for API call every 30 seconds', $e->getCode(), $e); } - if ($e->getCode() == 500) { + if ($e->getCode() === 500) { throw new InternalErrorException( 'Server returned 500 Internal Error (probably invalid token?)', $e->getCode(), diff --git a/tests/FioApi/DownloaderTest.php b/tests/FioApi/DownloaderTest.php index d07eb76..f557ec7 100644 --- a/tests/FioApi/DownloaderTest.php +++ b/tests/FioApi/DownloaderTest.php @@ -75,6 +75,7 @@ public function testDownloaderDownloadsLast(): void public function testDownloaderSetsLastId(): void { + /** @var array $container */ $container = []; $history = Middleware::history($container); @@ -86,9 +87,10 @@ public function testDownloaderSetsLastId(): void $downloader->setLastId('123456'); + Assert::assertIsArray($container); Assert::assertCount(1, $container); - /** @var \GuzzleHttp\Psr7\Request $request */ + /** @var \Psr\Http\Message\RequestInterface $request */ $request = $container[0]['request']; Assert::assertSame('https://fioapi.fio.cz/v1/rest/set-last-id/validToken/123456/', (string) $request->getUri());