Skip to content
Closed

8.4 #36

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ phpunit.xml
composer.lock
build/
/.phpunit.result.cache
/docker/
/.idea/
/Makefile
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
8 changes: 3 additions & 5 deletions src/FioApi/Downloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
Expand Down Expand Up @@ -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(),
Expand Down
4 changes: 3 additions & 1 deletion tests/FioApi/DownloaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public function testDownloaderDownloadsLast(): void

public function testDownloaderSetsLastId(): void
{
/** @var array<int, array{request: \Psr\Http\Message\RequestInterface}> $container */
$container = [];
$history = Middleware::history($container);

Expand All @@ -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());
Expand Down