From 35e4dbd657b81ded7bdfd73b036e649f478a85e6 Mon Sep 17 00:00:00 2001 From: Paramtamtam Date: Wed, 22 Jan 2020 12:01:48 +0500 Subject: [PATCH 1/5] Changes made --- .codecov.yml | 1 - .gitattributes | 15 ++-- .github/PULL_REQUEST_TEMPLATE.md | 25 ------ .github/stale.yml | 17 ---- .github/workflows/execute-tests.yml | 92 ++++++++++++++++++++ .gitignore | 7 +- .styleci.yml | 2 + .travis.yml | 16 ++-- CHANGELOG.md | 17 ++++ CODE_OF_CONDUCT.md | 47 ---------- CONTRIBUTING.md | 15 ---- Dockerfile | 4 +- LICENSE | 2 +- composer.json | 6 +- docker-compose.yml | 6 -- phpstan.neon.dist | 6 ++ phpunit.xml.dist | 4 +- src/Client.php | 22 ++--- src/Exceptions/BadResponseException.php | 2 +- src/Exceptions/TokenParserException.php | 2 +- src/Responses/DevPingResponse.php | 6 +- src/Responses/DevTokenResponse.php | 6 +- src/Responses/Entities/Balance.php | 4 +- src/Responses/Entities/CleanOptions.php | 4 +- src/Responses/Entities/Domain.php | 4 +- src/Responses/Entities/Report.php | 4 +- src/Responses/Entities/ReportContent.php | 2 +- src/Responses/Entities/ReportMade.php | 4 +- src/Responses/Entities/ReportQuery.php | 4 +- src/Responses/Entities/ReportSourceState.php | 4 +- src/Responses/Entities/ReportState.php | 6 +- src/Responses/Entities/ReportType.php | 4 +- src/Responses/Entities/ReportTypeContent.php | 4 +- src/Responses/Entities/User.php | 4 +- src/Responses/UserBalanceResponse.php | 14 +-- src/Responses/UserReportMakeResponse.php | 12 +-- src/Responses/UserReportRefreshResponse.php | 12 +-- src/Responses/UserReportResponse.php | 12 +-- src/Responses/UserReportTypesResponse.php | 14 +-- src/Responses/UserReportsResponse.php | 12 +-- src/Responses/UserResponse.php | 14 +-- src/Settings.php | 10 +-- src/Tokens/Auth/TokenInfo.php | 15 ++-- src/WithEventsHandlerSetterInterface.php | 2 + tests/AbstractTestCase.php | 2 +- tests/Feature/ClientTest.php | 2 +- tests/Unit/ClientTest.php | 2 +- tests/Unit/SettingsTest.php | 2 +- 48 files changed, 245 insertions(+), 248 deletions(-) delete mode 100644 .codecov.yml delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/stale.yml create mode 100644 .github/workflows/execute-tests.yml delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md create mode 100644 phpstan.neon.dist diff --git a/.codecov.yml b/.codecov.yml deleted file mode 100644 index db24720..0000000 --- a/.codecov.yml +++ /dev/null @@ -1 +0,0 @@ -comment: off diff --git a/.gitattributes b/.gitattributes index 91a18fe..b35bb1f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,10 +1,9 @@ * text=auto -/.github export-ignore -/tests export-ignore -/[Dd]ocker* export-ignore -/CODE_OF_CONDUCT.md export-ignore -/CONTRIBUTING.md export-ignore -/.* export-ignore -/phpunit.xml* export-ignore -/Makefile export-ignore +/.github export-ignore +/tests export-ignore +/[Dd]ocker* export-ignore +/.* export-ignore +/phpunit.xml* export-ignore +/phpstan.* export-ignore +/Makefile export-ignore diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 26b9c0d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,25 +0,0 @@ -| Q | A -| ------------- | --- -| Bug fix? | Yes or No -| New feature? | Yes or No - -## Description - -> Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. - -Fixes # (issue) - -## Checklist - -- [ ] My code follows the style guidelines of this project -- [ ] I have performed a self-review of my own code -- [ ] I have commented my code, particularly in hard-to-understand areas -- [ ] I wrote unit tests for my code -- [ ] I have made changes in [CHANGELOG.md](https://github.com/avtocod/b2b-api-php/blob/master/CHANGELOG.md) file - -> About your changes in `CHANGELOG.md`: -> -> * Add new version header like `## UNRELEASED`, if it does not exists -> * Add description under `added`/`changed`/`fixed` sections -> * Add reference to closed issues `[#000]` -> * Add link to issue in the end of document diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index 97f2f80..0000000 --- a/.github/stale.yml +++ /dev/null @@ -1,17 +0,0 @@ -# Number of days of inactivity before an issue becomes stale -daysUntilStale: 80 -# Number of days of inactivity before a stale issue is closed -daysUntilClose: 30 -# Issues with these labels will never be considered stale -exemptLabels: -- pinned -- security -# Label to use when marking an issue as stale -staleLabel: wontfix -# Comment to post when marking an issue as stale. Set to `false` to disable -markComment: > - This issue has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. Thank you - for your contributions. -# Comment to post when closing a stale issue. Set to `false` to disable -closeComment: true diff --git a/.github/workflows/execute-tests.yml b/.github/workflows/execute-tests.yml new file mode 100644 index 0000000..3873b7a --- /dev/null +++ b/.github/workflows/execute-tests.yml @@ -0,0 +1,92 @@ +name: Execute tests + +on: + push: + branches: + - master + tags-ignore: + - '**' + pull_request: + +jobs: # Docs: + tests: + name: PHP ${{ matrix.php }}, ${{ matrix.setup }} setup + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + fail-fast: false + matrix: + setup: ['basic', 'lowest'] + php: ['7.1', '7.2', '7.3', '7.4'] + include: + - php: '7.1' + setup: 'basic' + coverage: 'true' + - php: '7.4' + setup: 'basic' + coverage: 'true' + steps: + - name: Check out code + uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@master # Action page: + with: + php-version: ${{ matrix.php }} + extensions: mbstring, pdo, pdo_sqlite, sqlite3 # definition is required for php 7.4 + + - name: Get Composer Cache Directory # Docs: + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies # Docs: + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install Composer 'hirak/prestissimo' package + run: composer global require hirak/prestissimo --update-no-dev + + - name: Install lowest Composer dependencies + if: matrix.setup == 'lowest' + run: composer update --prefer-dist --no-interaction --no-suggest --prefer-lowest + + - name: Install basic Composer dependencies + if: matrix.setup == 'basic' + run: composer update --prefer-dist --no-interaction --no-suggest + + - name: Show most important packages versions + run: composer info | grep -e laravel/laravel -e phpunit/phpunit -e phpstan/phpstan + + - name: Execute tests + if: matrix.coverage != 'true' + run: composer test + + - name: Execute tests with code coverage + if: matrix.coverage == 'true' + run: composer test-cover + + - uses: codecov/codecov-action@v1 # Docs: + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./coverage/clover.xml + + lint-changelog: + name: Lint changelog file + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: Lint changelog file + uses: docker://avtodev/markdown-lint:v1 # Action page: + with: + rules: '/lint/rules/changelog.js' + config: '/lint/config/changelog.yml' + args: './CHANGELOG.md' diff --git a/.gitignore b/.gitignore index 34fb07b..68a6147 100644 --- a/.gitignore +++ b/.gitignore @@ -14,12 +14,7 @@ composer.lock ## Temp dirs & trash /temp /tmp -/tests/temp -/tests/tmp -/install -/build /coverage /phpunit.xml -clover-file .DS_Store -.php_cs.cache +*.cache diff --git a/.styleci.yml b/.styleci.yml index 6c7409e..2a8aef0 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -17,8 +17,10 @@ enabled: - phpdoc_return_self_reference - align_equals - concat_with_spaces + - length_ordered_imports disabled: - unalign_equals - concat_without_spaces - declare_equal_normalize + - alpha_ordered_imports diff --git a/.travis.yml b/.travis.yml index b4361a8..871518a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: php +os: linux cache: directories: @@ -9,8 +10,6 @@ env: - setup=basic - coverage=false -sudo: false - branches: except: - /analysis-.*/ @@ -31,27 +30,24 @@ script: after_success: - if [[ $coverage = 'true' ]]; then bash <(curl -s https://codecov.io/bash); fi -matrix: +jobs: include: - - php: 7.1.3 - php: 7.1.3 env: setup=lowest - php: 7.1.3 env: coverage=true - - php: 7.2 - php: 7.2 env: setup=lowest - php: 7.2 env: coverage=true - - php: 7.3 - php: 7.3 env: setup=lowest - php: 7.3 env: coverage=true - - php: nightly - - allow_failures: - - php: nightly + - php: 7.4 + env: setup=lowest + - php: 7.4 + env: coverage=true diff --git a/CHANGELOG.md b/CHANGELOG.md index 51e5759..1e78774 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog][keepachangelog] and this project adheres to [Semantic Versioning][semver]. +## v3.2.1 + +### Added + +- Tests running using GitHub Actions +- `phpstan` configuration file with disabled `checkGenericClassInNonGenericObjectType` and `checkMissingIterableValueType` + +### Changed + +- StyleCI rules. Enabled: `length_ordered_imports`, disabled: `alpha_ordered_imports` +- Updated dev-dependency versions +- Anonymous functions now static (where this is possible) +- `BadResponseException::wrongJson` now returns `self` instead `static` +- `TokenParserException::cannotParseToken` now returns `self` instead `static` +- Method `::fromHttpResponse` in all response classes now returns `self` instead `static` +- Method `::fromArray` in all entity classes now returns `self` instead `static` + ## v3.2.0 ### Added diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index 5fca7e7..0000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,47 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team [here][project_team]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] - -[project_team]:https://github.com/avtocod/b2b-api-php -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 5ea03b1..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,15 +0,0 @@ -# Contribution Guidelines - -Please ensure your pull request adheres to the following guidelines: - -- Search previous suggestions before making a new one, as yours may be a duplicate. -- Suggested packages should be tested and documented. -- Make an individual pull request for each suggestion. -- Use the following format: `[service](link) - Description.` -- New categories, or improvements to the existing categorization are welcome. -- Keep descriptions short and simple, but descriptive. -- End all descriptions with a full stop/period. -- Check your spelling and grammar. -- Make sure your text editor is set to remove trailing whitespace. - -Thank you for your suggestions! diff --git a/Dockerfile b/Dockerfile index 4c0079f..c95fea8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,8 +11,8 @@ COPY --from=composer /usr/bin/composer /usr/bin/composer RUN set -xe \ && apk add --no-cache binutils git curl \ && apk add --no-cache --virtual .build-deps autoconf pkgconf make g++ gcc \ - # install xdebug (for testing with code coverage), but not enable it - && pecl install xdebug-2.7.2 \ + # install xdebug (for testing with code coverage), but do not enable it + && pecl install xdebug-2.9.1 \ && apk del .build-deps \ && mkdir /src ${COMPOSER_HOME} \ && composer global require 'hirak/prestissimo' --no-interaction --no-suggest --prefer-dist \ diff --git a/LICENSE b/LICENSE index 683e764..251e6e8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 avto-dev +Copyright (c) 2020 avtocod Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/composer.json b/composer.json index a1adb2e..8edecbc 100644 --- a/composer.json +++ b/composer.json @@ -24,8 +24,8 @@ }, "require-dev": { "fzaninotto/faker": "^1.8", - "mockery/mockery": "^1.0", - "phpstan/phpstan": "^0.11", + "mockery/mockery": "^1.3", + "phpstan/phpstan": "~0.12", "phpunit/phpunit": "^7.5", "symfony/var-dumper": "^4.2", "tarampampam/guzzle-url-mock": "^1.1", @@ -48,7 +48,7 @@ "phpunit": "@php ./vendor/bin/phpunit --no-coverage --colors=always --testsuite=Unit", "phpunit-feature": "@php ./vendor/bin/phpunit --no-coverage --colors=always --testsuite=Feature", "phpunit-cover": "@php ./vendor/bin/phpunit --coverage-html='./coverage/html' --testsuite=Unit", - "phpstan": "@php ./vendor/bin/phpstan analyze --no-progress --ansi --level=max ./src", + "phpstan": "@php ./vendor/bin/phpstan analyze -c ./phpstan.neon.dist --no-progress --ansi", "test": [ "@phpstan", "@phpunit" diff --git a/docker-compose.yml b/docker-compose.yml index c69660d..782efd0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,5 @@ version: '3.2' -networks: - app-network: - driver: bridge - volumes: composer-data: @@ -17,5 +13,3 @@ services: - /etc/group:/etc/group:ro - .:/src:cached - composer-data:/tmp/composer:cached - networks: - - app-network diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..887e214 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,6 @@ +parameters: + level: 'max' + paths: + - src + checkGenericClassInNonGenericObjectType: false + checkMissingIterableValueType: false diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 680a5e3..4daf69a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,7 @@ -getMessage(), $e); } - return new static( + return new self( $raw_response, $as_array['value'], $as_array['in'], diff --git a/src/Responses/DevTokenResponse.php b/src/Responses/DevTokenResponse.php index 8336578..3376dda 100644 --- a/src/Responses/DevTokenResponse.php +++ b/src/Responses/DevTokenResponse.php @@ -117,7 +117,7 @@ private function __construct(string $raw_response, } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getRawResponseContent(): string { @@ -125,7 +125,7 @@ public function getRawResponseContent(): string } /** - * {@inheritdoc} + * {@inheritDoc} * * @throws BadResponseException */ @@ -137,7 +137,7 @@ public static function fromHttpResponse(HttpResponseInterface $response): self throw BadResponseException::wrongJson($response, $e->getMessage(), $e); } - return new static( + return new self( $raw_response, $as_array['user'], $as_array['pass'], diff --git a/src/Responses/Entities/Balance.php b/src/Responses/Entities/Balance.php index ef7fbd8..81826e8 100644 --- a/src/Responses/Entities/Balance.php +++ b/src/Responses/Entities/Balance.php @@ -88,11 +88,11 @@ public function __construct(string $report_type_uid, } /** - * {@inheritdoc} + * {@inheritDoc} */ public static function fromArray(array $data): self { - return new static( + return new self( $data['report_type_uid'], $data['balance_type'], $data['quote_init'], diff --git a/src/Responses/Entities/CleanOptions.php b/src/Responses/Entities/CleanOptions.php index 92eaeb7..e8fcb74 100644 --- a/src/Responses/Entities/CleanOptions.php +++ b/src/Responses/Entities/CleanOptions.php @@ -36,11 +36,11 @@ public function __construct(?int $process_response, ?int $process_request, ?int } /** - * {@inheritdoc} + * {@inheritDoc} */ public static function fromArray(array $data): self { - return new static( + return new self( $data['Process_Response'] ?? null, $data['Process_Request'] ?? null, $data['ReportLog'] ?? null diff --git a/src/Responses/Entities/Domain.php b/src/Responses/Entities/Domain.php index ab481a8..460e3cd 100644 --- a/src/Responses/Entities/Domain.php +++ b/src/Responses/Entities/Domain.php @@ -129,11 +129,11 @@ public function __construct(string $uid, } /** - * {@inheritdoc} + * {@inheritDoc} */ public static function fromArray(array $data): self { - return new static( + return new self( $data['uid'], $data['comment'], $data['name'], diff --git a/src/Responses/Entities/Report.php b/src/Responses/Entities/Report.php index dd3dc82..bd6ea98 100644 --- a/src/Responses/Entities/Report.php +++ b/src/Responses/Entities/Report.php @@ -185,11 +185,11 @@ public function __construct(string $uid, } /** - * {@inheritdoc} + * {@inheritDoc} */ public static function fromArray(array $data): self { - return new static( + return new self( $data['uid'], $data['comment'], $data['name'], diff --git a/src/Responses/Entities/ReportContent.php b/src/Responses/Entities/ReportContent.php index 4172963..4cf0a43 100644 --- a/src/Responses/Entities/ReportContent.php +++ b/src/Responses/Entities/ReportContent.php @@ -42,7 +42,7 @@ public function getContent(): array */ public function getByPath(string $path, $default = null, string $delimiter = '.') { - return \array_reduce((array) \explode($delimiter, $path), function ($carry, $item) use (&$default) { + return \array_reduce((array) \explode($delimiter, $path), static function ($carry, $item) use (&$default) { return \is_numeric($item) || \is_array($carry) ? ($carry[$item] ?? $default) : ($carry->$item ?? $default); diff --git a/src/Responses/Entities/ReportMade.php b/src/Responses/Entities/ReportMade.php index a927496..47dc2f3 100644 --- a/src/Responses/Entities/ReportMade.php +++ b/src/Responses/Entities/ReportMade.php @@ -46,11 +46,11 @@ public function __construct(string $report_uid, bool $is_new, ?string $process_r } /** - * {@inheritdoc} + * {@inheritDoc} */ public static function fromArray(array $data): self { - return new static( + return new self( $data['uid'], $data['isnew'], $data['process_request_uid'] ?? null, diff --git a/src/Responses/Entities/ReportQuery.php b/src/Responses/Entities/ReportQuery.php index 62cfb0b..8bc77c5 100644 --- a/src/Responses/Entities/ReportQuery.php +++ b/src/Responses/Entities/ReportQuery.php @@ -36,11 +36,11 @@ public function __construct(?string $type, ?string $body, ?array $data) } /** - * {@inheritdoc} + * {@inheritDoc} */ public static function fromArray(array $data): self { - return new static( + return new self( $data['type'] ?? null, $data['body'] ?? null, $data['data'] ?? null diff --git a/src/Responses/Entities/ReportSourceState.php b/src/Responses/Entities/ReportSourceState.php index 61380f3..afcad6a 100644 --- a/src/Responses/Entities/ReportSourceState.php +++ b/src/Responses/Entities/ReportSourceState.php @@ -51,11 +51,11 @@ public function __construct(string $name, string $state, ?array $data) } /** - * {@inheritdoc} + * {@inheritDoc} */ public static function fromArray(array $data): self { - return new static( + return new self( $data['_id'] ?? $data['id'] ?? $data['name'], $data['state'], $data['data'] ?? null diff --git a/src/Responses/Entities/ReportState.php b/src/Responses/Entities/ReportState.php index e9d745e..3ba3e71 100644 --- a/src/Responses/Entities/ReportState.php +++ b/src/Responses/Entities/ReportState.php @@ -22,12 +22,12 @@ public function __construct(array $source_states) } /** - * {@inheritdoc} + * {@inheritDoc} */ public static function fromArray(array $data): self { - return new static( - \array_map(function (array $report_data): ReportSourceState { + return new self( + \array_map(static function (array $report_data): ReportSourceState { return ReportSourceState::fromArray($report_data); }, $data['sources']) ); diff --git a/src/Responses/Entities/ReportType.php b/src/Responses/Entities/ReportType.php index c1ee155..4bd9659 100644 --- a/src/Responses/Entities/ReportType.php +++ b/src/Responses/Entities/ReportType.php @@ -249,11 +249,11 @@ public function __construct(string $uid, } /** - * {@inheritdoc} + * {@inheritDoc} */ public static function fromArray(array $data): self { - return new static( + return new self( $data['uid'], $data['comment'], $data['name'], diff --git a/src/Responses/Entities/ReportTypeContent.php b/src/Responses/Entities/ReportTypeContent.php index c24610a..57034a6 100644 --- a/src/Responses/Entities/ReportTypeContent.php +++ b/src/Responses/Entities/ReportTypeContent.php @@ -29,11 +29,11 @@ public function __construct(array $sources, array $fields) } /** - * {@inheritdoc} + * {@inheritDoc} */ public static function fromArray(array $data): self { - return new static( + return new self( $data['sources'], $data['fields'] ); diff --git a/src/Responses/Entities/User.php b/src/Responses/Entities/User.php index 6f064af..375a1c6 100644 --- a/src/Responses/Entities/User.php +++ b/src/Responses/Entities/User.php @@ -192,11 +192,11 @@ public function __construct(string $uid, } /** - * {@inheritdoc} + * {@inheritDoc} */ public static function fromArray(array $data): self { - return new static( + return new self( $data['uid'], $data['comment'], $data['contacts'], diff --git a/src/Responses/UserBalanceResponse.php b/src/Responses/UserBalanceResponse.php index 876631c..5594bfb 100644 --- a/src/Responses/UserBalanceResponse.php +++ b/src/Responses/UserBalanceResponse.php @@ -61,7 +61,7 @@ private function __construct(string $raw_response, string $state, int $size, Dat } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getRawResponseContent(): string { @@ -69,7 +69,7 @@ public function getRawResponseContent(): string } /** - * {@inheritdoc} + * {@inheritDoc} * * @throws BadResponseException */ @@ -81,11 +81,11 @@ public static function fromHttpResponse(HttpResponseInterface $response): self throw BadResponseException::wrongJson($response, $e->getMessage(), $e); } - $as_array['data'] = \array_map(function (array $balance_data): Balance { + $as_array['data'] = \array_map(static function (array $balance_data): Balance { return Balance::fromArray($balance_data); }, $as_array['data']); - return new static( + return new self( $raw_response, $as_array['state'], $as_array['size'], @@ -143,7 +143,7 @@ public function getData(): array */ public function getByType(string $balance_type): ?Balance { - $result = \array_values(\array_filter($this->data, function (Balance $balance) use (&$balance_type): bool { + $result = \array_values(\array_filter($this->data, static function (Balance $balance) use (&$balance_type): bool { return $balance->getBalanceType() === $balance_type; })); @@ -153,7 +153,7 @@ public function getByType(string $balance_type): ?Balance } /** - * {@inheritdoc} + * {@inheritDoc} */ public function count(): int { @@ -161,7 +161,7 @@ public function count(): int } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getIterator(): ArrayIterator { diff --git a/src/Responses/UserReportMakeResponse.php b/src/Responses/UserReportMakeResponse.php index 608dca5..dee4e67 100644 --- a/src/Responses/UserReportMakeResponse.php +++ b/src/Responses/UserReportMakeResponse.php @@ -61,7 +61,7 @@ private function __construct(string $raw_response, string $state, int $size, Dat } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getRawResponseContent(): string { @@ -69,7 +69,7 @@ public function getRawResponseContent(): string } /** - * {@inheritdoc} + * {@inheritDoc} * * @throws BadResponseException */ @@ -81,11 +81,11 @@ public static function fromHttpResponse(HttpResponseInterface $response): self throw BadResponseException::wrongJson($response, $e->getMessage(), $e); } - $as_array['data'] = \array_map(function (array $data): ReportMade { + $as_array['data'] = \array_map(static function (array $data): ReportMade { return ReportMade::fromArray($data); }, $as_array['data']); - return new static( + return new self( $raw_response, $as_array['state'], $as_array['size'], @@ -145,7 +145,7 @@ public function first(): ?ReportMade } /** - * {@inheritdoc} + * {@inheritDoc} */ public function count(): int { @@ -153,7 +153,7 @@ public function count(): int } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getIterator(): ArrayIterator { diff --git a/src/Responses/UserReportRefreshResponse.php b/src/Responses/UserReportRefreshResponse.php index 6f443c5..ecf4ad6 100644 --- a/src/Responses/UserReportRefreshResponse.php +++ b/src/Responses/UserReportRefreshResponse.php @@ -61,7 +61,7 @@ private function __construct(string $raw_response, string $state, int $size, Dat } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getRawResponseContent(): string { @@ -69,7 +69,7 @@ public function getRawResponseContent(): string } /** - * {@inheritdoc} + * {@inheritDoc} * * @throws BadResponseException */ @@ -81,11 +81,11 @@ public static function fromHttpResponse(HttpResponseInterface $response): self throw BadResponseException::wrongJson($response, $e->getMessage(), $e); } - $as_array['data'] = \array_map(function (array $data): ReportMade { + $as_array['data'] = \array_map(static function (array $data): ReportMade { return ReportMade::fromArray($data); }, $as_array['data']); - return new static( + return new self( $raw_response, $as_array['state'], $as_array['size'], @@ -145,7 +145,7 @@ public function first(): ?ReportMade } /** - * {@inheritdoc} + * {@inheritDoc} */ public function count(): int { @@ -153,7 +153,7 @@ public function count(): int } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getIterator(): ArrayIterator { diff --git a/src/Responses/UserReportResponse.php b/src/Responses/UserReportResponse.php index b623e4e..a0bc4b0 100644 --- a/src/Responses/UserReportResponse.php +++ b/src/Responses/UserReportResponse.php @@ -61,7 +61,7 @@ private function __construct(string $raw_response, string $state, int $size, Dat } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getRawResponseContent(): string { @@ -69,7 +69,7 @@ public function getRawResponseContent(): string } /** - * {@inheritdoc} + * {@inheritDoc} * * @throws BadResponseException */ @@ -81,11 +81,11 @@ public static function fromHttpResponse(HttpResponseInterface $response): self throw BadResponseException::wrongJson($response, $e->getMessage(), $e); } - $as_array['data'] = \array_map(function (array $data): Report { + $as_array['data'] = \array_map(static function (array $data): Report { return Report::fromArray($data); }, $as_array['data']); - return new static( + return new self( $raw_response, $as_array['state'], $as_array['size'], @@ -145,7 +145,7 @@ public function first(): ?Report } /** - * {@inheritdoc} + * {@inheritDoc} */ public function count(): int { @@ -153,7 +153,7 @@ public function count(): int } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getIterator(): ArrayIterator { diff --git a/src/Responses/UserReportTypesResponse.php b/src/Responses/UserReportTypesResponse.php index f452c4c..af62c72 100644 --- a/src/Responses/UserReportTypesResponse.php +++ b/src/Responses/UserReportTypesResponse.php @@ -73,7 +73,7 @@ private function __construct(string $raw_response, } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getRawResponseContent(): string { @@ -81,7 +81,7 @@ public function getRawResponseContent(): string } /** - * {@inheritdoc} + * {@inheritDoc} * * @throws BadResponseException */ @@ -93,11 +93,11 @@ public static function fromHttpResponse(HttpResponseInterface $response): self throw BadResponseException::wrongJson($response, $e->getMessage(), $e); } - $as_array['data'] = \array_map(function (array $report_type_data): ReportType { + $as_array['data'] = \array_map(static function (array $report_type_data): ReportType { return ReportType::fromArray($report_type_data); }, $as_array['data']); - return new static( + return new self( $raw_response, $as_array['state'], $as_array['size'], @@ -166,7 +166,7 @@ public function getTotal(): ?int */ public function getByUid(string $uid): ?ReportType { - $result = \array_values(\array_filter($this->data, function (ReportType $report_type) use (&$uid): bool { + $result = \array_values(\array_filter($this->data, static function (ReportType $report_type) use (&$uid): bool { return $report_type->getUid() === $uid; })); @@ -176,7 +176,7 @@ public function getByUid(string $uid): ?ReportType } /** - * {@inheritdoc} + * {@inheritDoc} */ public function count(): int { @@ -184,7 +184,7 @@ public function count(): int } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getIterator(): ArrayIterator { diff --git a/src/Responses/UserReportsResponse.php b/src/Responses/UserReportsResponse.php index 0a503e8..6ac3c8d 100644 --- a/src/Responses/UserReportsResponse.php +++ b/src/Responses/UserReportsResponse.php @@ -73,7 +73,7 @@ private function __construct(string $raw_response, } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getRawResponseContent(): string { @@ -81,7 +81,7 @@ public function getRawResponseContent(): string } /** - * {@inheritdoc} + * {@inheritDoc} * * @throws BadResponseException */ @@ -93,11 +93,11 @@ public static function fromHttpResponse(HttpResponseInterface $response): self throw BadResponseException::wrongJson($response, $e->getMessage(), $e); } - $as_array['data'] = \array_map(function (array $report_data): Report { + $as_array['data'] = \array_map(static function (array $report_data): Report { return Report::fromArray($report_data); }, $as_array['data']); - return new static( + return new self( $raw_response, $as_array['state'], $as_array['size'], @@ -168,7 +168,7 @@ public function first(): ?Report } /** - * {@inheritdoc} + * {@inheritDoc} */ public function count(): int { @@ -176,7 +176,7 @@ public function count(): int } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getIterator(): ArrayIterator { diff --git a/src/Responses/UserResponse.php b/src/Responses/UserResponse.php index 6d4987f..23aaedc 100644 --- a/src/Responses/UserResponse.php +++ b/src/Responses/UserResponse.php @@ -61,7 +61,7 @@ private function __construct(string $raw_response, string $state, int $size, Dat } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getRawResponseContent(): string { @@ -69,7 +69,7 @@ public function getRawResponseContent(): string } /** - * {@inheritdoc} + * {@inheritDoc} * * @throws BadResponseException */ @@ -81,11 +81,11 @@ public static function fromHttpResponse(HttpResponseInterface $response): self throw BadResponseException::wrongJson($response, $e->getMessage(), $e); } - $as_array['data'] = \array_map(function (array $user_data): User { + $as_array['data'] = \array_map(static function (array $user_data): User { return User::fromArray($user_data); }, $as_array['data']); - return new static( + return new self( $raw_response, $as_array['state'], $as_array['size'], @@ -143,7 +143,7 @@ public function getData(): array */ public function getByUid(string $uid): ?User { - $result = \array_values(\array_filter($this->data, function (User $user) use (&$uid): bool { + $result = \array_values(\array_filter($this->data, static function (User $user) use (&$uid): bool { return $user->getUid() === $uid; })); @@ -153,7 +153,7 @@ public function getByUid(string $uid): ?User } /** - * {@inheritdoc} + * {@inheritDoc} */ public function count(): int { @@ -161,7 +161,7 @@ public function count(): int } /** - * {@inheritdoc} + * {@inheritDoc} */ public function getIterator(): ArrayIterator { diff --git a/src/Settings.php b/src/Settings.php index 8b1d76f..65c9f27 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -19,7 +19,7 @@ class Settings protected $base_uri = 'https://b2bapi.avtocod.ru/b2b/api/v1/'; /** - * @var array + * @var mixed[] */ protected $guzzle_options = [ GuzzleHttpOptions::VERIFY => true, @@ -29,9 +29,9 @@ class Settings /** * Create a new Settings instance. * - * @param string $auth_token For token generation you can use `AuthToken::generate()` - * @param string|null $base_uri - * @param array|null $guzzle_options + * @param string $auth_token For token generation you can use `AuthToken::generate()` + * @param string|null $base_uri + * @param mixed[]|null $guzzle_options */ public function __construct(string $auth_token, ?string $base_uri = null, @@ -61,7 +61,7 @@ public function getBaseUri(): string /** * Get guzzle options array. * - * @return array + * @return mixed[] */ public function getGuzzleOptions(): array { diff --git a/src/Tokens/Auth/TokenInfo.php b/src/Tokens/Auth/TokenInfo.php index f5304e3..4c089d4 100644 --- a/src/Tokens/Auth/TokenInfo.php +++ b/src/Tokens/Auth/TokenInfo.php @@ -4,9 +4,6 @@ namespace Avtocod\B2BApi\Tokens\Auth; -use function mb_strpos; -use function mb_substr; - class TokenInfo { protected const USERNAME_AND_DOMAIN_DELIMITER = '@'; @@ -64,10 +61,10 @@ public function getUser(): string */ public function getDomainName(): ?string { - if (mb_strpos($this->user, static::USERNAME_AND_DOMAIN_DELIMITER) !== false) { - $domain = (string) mb_substr( + if (\mb_strpos($this->user, static::USERNAME_AND_DOMAIN_DELIMITER) !== false) { + $domain = (string) \mb_substr( $this->user, - mb_strpos($this->user, static::USERNAME_AND_DOMAIN_DELIMITER) + 1, + \mb_strpos($this->user, static::USERNAME_AND_DOMAIN_DELIMITER) + 1, null ); @@ -86,11 +83,11 @@ public function getDomainName(): ?string */ public function getUsername(): ?string { - if (mb_strpos($this->user, static::USERNAME_AND_DOMAIN_DELIMITER) !== false) { - $username = (string) mb_substr( + if (\mb_strpos($this->user, static::USERNAME_AND_DOMAIN_DELIMITER) !== false) { + $username = (string) \mb_substr( $this->user, 0, - mb_strpos($this->user, static::USERNAME_AND_DOMAIN_DELIMITER) + \mb_strpos($this->user, static::USERNAME_AND_DOMAIN_DELIMITER) ); if ($username !== '') { diff --git a/src/WithEventsHandlerSetterInterface.php b/src/WithEventsHandlerSetterInterface.php index 63deb73..53e1dbe 100644 --- a/src/WithEventsHandlerSetterInterface.php +++ b/src/WithEventsHandlerSetterInterface.php @@ -10,6 +10,8 @@ interface WithEventsHandlerSetterInterface * Set events handler. * * @param Closure $events_handler + * + * @return mixed|void */ public function setEventsHandler(Closure $events_handler); } diff --git a/tests/AbstractTestCase.php b/tests/AbstractTestCase.php index 542e504..f8d29bf 100644 --- a/tests/AbstractTestCase.php +++ b/tests/AbstractTestCase.php @@ -22,7 +22,7 @@ abstract class AbstractTestCase extends TestCase protected $guzzle_handler; /** - * {@inheritdoc} + * {@inheritDoc} */ protected function setUp(): void { diff --git a/tests/Feature/ClientTest.php b/tests/Feature/ClientTest.php index fef86d1..e4f068f 100644 --- a/tests/Feature/ClientTest.php +++ b/tests/Feature/ClientTest.php @@ -43,7 +43,7 @@ class ClientTest extends AbstractTestCase protected $report_type; /** - * {@inheritdoc} + * {@inheritDoc} */ protected function setUp(): void { diff --git a/tests/Unit/ClientTest.php b/tests/Unit/ClientTest.php index 7ca1719..c0e6609 100644 --- a/tests/Unit/ClientTest.php +++ b/tests/Unit/ClientTest.php @@ -50,7 +50,7 @@ class ClientTest extends AbstractTestCase protected $settings; /** - * {@inheritdoc} + * {@inheritDoc} */ protected function setUp(): void { diff --git a/tests/Unit/SettingsTest.php b/tests/Unit/SettingsTest.php index 7537553..58b3a1b 100644 --- a/tests/Unit/SettingsTest.php +++ b/tests/Unit/SettingsTest.php @@ -23,7 +23,7 @@ class SettingsTest extends AbstractTestCase protected $auth_token; /** - * {@inheritdoc} + * {@inheritDoc} */ protected function setUp(): void { From 59550cec9d0291f90096d34c323ea4d31813c3d9 Mon Sep 17 00:00:00 2001 From: Paramtamtam Date: Wed, 22 Jan 2020 07:02:26 +0000 Subject: [PATCH 2/5] Apply fixes from StyleCI --- src/Client.php | 22 +++---- src/Responses/DevPingResponse.php | 4 +- src/Responses/DevTokenResponse.php | 4 +- src/Responses/Entities/Balance.php | 2 +- src/Responses/Entities/CleanOptions.php | 2 +- src/Responses/Entities/Domain.php | 2 +- src/Responses/Entities/Report.php | 2 +- src/Responses/Entities/ReportMade.php | 2 +- src/Responses/Entities/ReportQuery.php | 2 +- src/Responses/Entities/ReportSourceState.php | 2 +- src/Responses/Entities/ReportState.php | 2 +- src/Responses/Entities/ReportType.php | 2 +- src/Responses/Entities/ReportTypeContent.php | 2 +- src/Responses/Entities/User.php | 2 +- src/Responses/UserBalanceResponse.php | 8 +-- src/Responses/UserReportMakeResponse.php | 8 +-- src/Responses/UserReportRefreshResponse.php | 8 +-- src/Responses/UserReportResponse.php | 8 +-- src/Responses/UserReportTypesResponse.php | 8 +-- src/Responses/UserReportsResponse.php | 8 +-- src/Responses/UserResponse.php | 8 +-- src/Settings.php | 2 +- tests/AbstractTestCase.php | 2 +- tests/Feature/ClientTest.php | 2 +- tests/Unit/ClientTest.php | 60 ++++++++++---------- tests/Unit/SettingsTest.php | 2 +- 26 files changed, 88 insertions(+), 88 deletions(-) diff --git a/src/Client.php b/src/Client.php index 0237ef5..cd13132 100644 --- a/src/Client.php +++ b/src/Client.php @@ -61,7 +61,7 @@ public function __construct(Settings $settings, } /** - * {@inheritDoc} + * {@inheritdoc} * * @return $this */ @@ -73,7 +73,7 @@ public function setEventsHandler(Closure $events_handler): self } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getSettings(): Settings { @@ -81,7 +81,7 @@ public function getSettings(): Settings } /** - * {@inheritDoc} + * {@inheritdoc} */ public function devPing(?string $value = null): DevPingResponse { @@ -113,7 +113,7 @@ public function getVersion(bool $without_hash = true): string } /** - * {@inheritDoc} + * {@inheritdoc} */ public function devToken(string $username, string $password, @@ -137,7 +137,7 @@ public function devToken(string $username, } /** - * {@inheritDoc} + * {@inheritdoc} */ public function user(bool $detailed = false): UserResponse { @@ -153,7 +153,7 @@ public function user(bool $detailed = false): UserResponse } /** - * {@inheritDoc} + * {@inheritdoc} */ public function userBalance(string $report_type_uid, bool $detailed = false): UserBalanceResponse { @@ -169,7 +169,7 @@ public function userBalance(string $report_type_uid, bool $detailed = false): Us } /** - * {@inheritDoc} + * {@inheritdoc} */ public function userReportTypes(bool $can_generate = false, bool $content = false, @@ -203,7 +203,7 @@ public function userReportTypes(bool $can_generate = false, } /** - * {@inheritDoc} + * {@inheritdoc} */ public function userReports(bool $content = false, string $query = '_all', @@ -237,7 +237,7 @@ public function userReports(bool $content = false, } /** - * {@inheritDoc} + * {@inheritdoc} */ public function userReport(string $report_uid, bool $content = true, @@ -258,7 +258,7 @@ public function userReport(string $report_uid, } /** - * {@inheritDoc} + * {@inheritdoc} */ public function userReportMake(string $report_type_uid, string $type, @@ -294,7 +294,7 @@ public function userReportMake(string $report_type_uid, } /** - * {@inheritDoc} + * {@inheritdoc} */ public function userReportRefresh(string $report_uid, ?array $options = []): UserReportRefreshResponse { diff --git a/src/Responses/DevPingResponse.php b/src/Responses/DevPingResponse.php index 918312b..229171d 100644 --- a/src/Responses/DevPingResponse.php +++ b/src/Responses/DevPingResponse.php @@ -55,7 +55,7 @@ private function __construct(string $raw_response, string $value, int $in, int $ } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getRawResponseContent(): string { @@ -63,7 +63,7 @@ public function getRawResponseContent(): string } /** - * {@inheritDoc} + * {@inheritdoc} * * @throws BadResponseException */ diff --git a/src/Responses/DevTokenResponse.php b/src/Responses/DevTokenResponse.php index 3376dda..60029fd 100644 --- a/src/Responses/DevTokenResponse.php +++ b/src/Responses/DevTokenResponse.php @@ -117,7 +117,7 @@ private function __construct(string $raw_response, } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getRawResponseContent(): string { @@ -125,7 +125,7 @@ public function getRawResponseContent(): string } /** - * {@inheritDoc} + * {@inheritdoc} * * @throws BadResponseException */ diff --git a/src/Responses/Entities/Balance.php b/src/Responses/Entities/Balance.php index 81826e8..1ac6acb 100644 --- a/src/Responses/Entities/Balance.php +++ b/src/Responses/Entities/Balance.php @@ -88,7 +88,7 @@ public function __construct(string $report_type_uid, } /** - * {@inheritDoc} + * {@inheritdoc} */ public static function fromArray(array $data): self { diff --git a/src/Responses/Entities/CleanOptions.php b/src/Responses/Entities/CleanOptions.php index e8fcb74..13b89d7 100644 --- a/src/Responses/Entities/CleanOptions.php +++ b/src/Responses/Entities/CleanOptions.php @@ -36,7 +36,7 @@ public function __construct(?int $process_response, ?int $process_request, ?int } /** - * {@inheritDoc} + * {@inheritdoc} */ public static function fromArray(array $data): self { diff --git a/src/Responses/Entities/Domain.php b/src/Responses/Entities/Domain.php index 460e3cd..4ca1af5 100644 --- a/src/Responses/Entities/Domain.php +++ b/src/Responses/Entities/Domain.php @@ -129,7 +129,7 @@ public function __construct(string $uid, } /** - * {@inheritDoc} + * {@inheritdoc} */ public static function fromArray(array $data): self { diff --git a/src/Responses/Entities/Report.php b/src/Responses/Entities/Report.php index bd6ea98..0302d07 100644 --- a/src/Responses/Entities/Report.php +++ b/src/Responses/Entities/Report.php @@ -185,7 +185,7 @@ public function __construct(string $uid, } /** - * {@inheritDoc} + * {@inheritdoc} */ public static function fromArray(array $data): self { diff --git a/src/Responses/Entities/ReportMade.php b/src/Responses/Entities/ReportMade.php index 47dc2f3..2783a27 100644 --- a/src/Responses/Entities/ReportMade.php +++ b/src/Responses/Entities/ReportMade.php @@ -46,7 +46,7 @@ public function __construct(string $report_uid, bool $is_new, ?string $process_r } /** - * {@inheritDoc} + * {@inheritdoc} */ public static function fromArray(array $data): self { diff --git a/src/Responses/Entities/ReportQuery.php b/src/Responses/Entities/ReportQuery.php index 8bc77c5..23fbbc2 100644 --- a/src/Responses/Entities/ReportQuery.php +++ b/src/Responses/Entities/ReportQuery.php @@ -36,7 +36,7 @@ public function __construct(?string $type, ?string $body, ?array $data) } /** - * {@inheritDoc} + * {@inheritdoc} */ public static function fromArray(array $data): self { diff --git a/src/Responses/Entities/ReportSourceState.php b/src/Responses/Entities/ReportSourceState.php index afcad6a..46c4f05 100644 --- a/src/Responses/Entities/ReportSourceState.php +++ b/src/Responses/Entities/ReportSourceState.php @@ -51,7 +51,7 @@ public function __construct(string $name, string $state, ?array $data) } /** - * {@inheritDoc} + * {@inheritdoc} */ public static function fromArray(array $data): self { diff --git a/src/Responses/Entities/ReportState.php b/src/Responses/Entities/ReportState.php index 3ba3e71..16ac7c2 100644 --- a/src/Responses/Entities/ReportState.php +++ b/src/Responses/Entities/ReportState.php @@ -22,7 +22,7 @@ public function __construct(array $source_states) } /** - * {@inheritDoc} + * {@inheritdoc} */ public static function fromArray(array $data): self { diff --git a/src/Responses/Entities/ReportType.php b/src/Responses/Entities/ReportType.php index 4bd9659..316cb41 100644 --- a/src/Responses/Entities/ReportType.php +++ b/src/Responses/Entities/ReportType.php @@ -249,7 +249,7 @@ public function __construct(string $uid, } /** - * {@inheritDoc} + * {@inheritdoc} */ public static function fromArray(array $data): self { diff --git a/src/Responses/Entities/ReportTypeContent.php b/src/Responses/Entities/ReportTypeContent.php index 57034a6..d985f65 100644 --- a/src/Responses/Entities/ReportTypeContent.php +++ b/src/Responses/Entities/ReportTypeContent.php @@ -29,7 +29,7 @@ public function __construct(array $sources, array $fields) } /** - * {@inheritDoc} + * {@inheritdoc} */ public static function fromArray(array $data): self { diff --git a/src/Responses/Entities/User.php b/src/Responses/Entities/User.php index 375a1c6..8b8d417 100644 --- a/src/Responses/Entities/User.php +++ b/src/Responses/Entities/User.php @@ -192,7 +192,7 @@ public function __construct(string $uid, } /** - * {@inheritDoc} + * {@inheritdoc} */ public static function fromArray(array $data): self { diff --git a/src/Responses/UserBalanceResponse.php b/src/Responses/UserBalanceResponse.php index 5594bfb..93bafed 100644 --- a/src/Responses/UserBalanceResponse.php +++ b/src/Responses/UserBalanceResponse.php @@ -61,7 +61,7 @@ private function __construct(string $raw_response, string $state, int $size, Dat } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getRawResponseContent(): string { @@ -69,7 +69,7 @@ public function getRawResponseContent(): string } /** - * {@inheritDoc} + * {@inheritdoc} * * @throws BadResponseException */ @@ -153,7 +153,7 @@ public function getByType(string $balance_type): ?Balance } /** - * {@inheritDoc} + * {@inheritdoc} */ public function count(): int { @@ -161,7 +161,7 @@ public function count(): int } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getIterator(): ArrayIterator { diff --git a/src/Responses/UserReportMakeResponse.php b/src/Responses/UserReportMakeResponse.php index dee4e67..003d800 100644 --- a/src/Responses/UserReportMakeResponse.php +++ b/src/Responses/UserReportMakeResponse.php @@ -61,7 +61,7 @@ private function __construct(string $raw_response, string $state, int $size, Dat } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getRawResponseContent(): string { @@ -69,7 +69,7 @@ public function getRawResponseContent(): string } /** - * {@inheritDoc} + * {@inheritdoc} * * @throws BadResponseException */ @@ -145,7 +145,7 @@ public function first(): ?ReportMade } /** - * {@inheritDoc} + * {@inheritdoc} */ public function count(): int { @@ -153,7 +153,7 @@ public function count(): int } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getIterator(): ArrayIterator { diff --git a/src/Responses/UserReportRefreshResponse.php b/src/Responses/UserReportRefreshResponse.php index ecf4ad6..8d037b2 100644 --- a/src/Responses/UserReportRefreshResponse.php +++ b/src/Responses/UserReportRefreshResponse.php @@ -61,7 +61,7 @@ private function __construct(string $raw_response, string $state, int $size, Dat } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getRawResponseContent(): string { @@ -69,7 +69,7 @@ public function getRawResponseContent(): string } /** - * {@inheritDoc} + * {@inheritdoc} * * @throws BadResponseException */ @@ -145,7 +145,7 @@ public function first(): ?ReportMade } /** - * {@inheritDoc} + * {@inheritdoc} */ public function count(): int { @@ -153,7 +153,7 @@ public function count(): int } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getIterator(): ArrayIterator { diff --git a/src/Responses/UserReportResponse.php b/src/Responses/UserReportResponse.php index a0bc4b0..95ed1f0 100644 --- a/src/Responses/UserReportResponse.php +++ b/src/Responses/UserReportResponse.php @@ -61,7 +61,7 @@ private function __construct(string $raw_response, string $state, int $size, Dat } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getRawResponseContent(): string { @@ -69,7 +69,7 @@ public function getRawResponseContent(): string } /** - * {@inheritDoc} + * {@inheritdoc} * * @throws BadResponseException */ @@ -145,7 +145,7 @@ public function first(): ?Report } /** - * {@inheritDoc} + * {@inheritdoc} */ public function count(): int { @@ -153,7 +153,7 @@ public function count(): int } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getIterator(): ArrayIterator { diff --git a/src/Responses/UserReportTypesResponse.php b/src/Responses/UserReportTypesResponse.php index af62c72..d62abaa 100644 --- a/src/Responses/UserReportTypesResponse.php +++ b/src/Responses/UserReportTypesResponse.php @@ -73,7 +73,7 @@ private function __construct(string $raw_response, } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getRawResponseContent(): string { @@ -81,7 +81,7 @@ public function getRawResponseContent(): string } /** - * {@inheritDoc} + * {@inheritdoc} * * @throws BadResponseException */ @@ -176,7 +176,7 @@ public function getByUid(string $uid): ?ReportType } /** - * {@inheritDoc} + * {@inheritdoc} */ public function count(): int { @@ -184,7 +184,7 @@ public function count(): int } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getIterator(): ArrayIterator { diff --git a/src/Responses/UserReportsResponse.php b/src/Responses/UserReportsResponse.php index 6ac3c8d..01c08dd 100644 --- a/src/Responses/UserReportsResponse.php +++ b/src/Responses/UserReportsResponse.php @@ -73,7 +73,7 @@ private function __construct(string $raw_response, } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getRawResponseContent(): string { @@ -81,7 +81,7 @@ public function getRawResponseContent(): string } /** - * {@inheritDoc} + * {@inheritdoc} * * @throws BadResponseException */ @@ -168,7 +168,7 @@ public function first(): ?Report } /** - * {@inheritDoc} + * {@inheritdoc} */ public function count(): int { @@ -176,7 +176,7 @@ public function count(): int } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getIterator(): ArrayIterator { diff --git a/src/Responses/UserResponse.php b/src/Responses/UserResponse.php index 23aaedc..75e498e 100644 --- a/src/Responses/UserResponse.php +++ b/src/Responses/UserResponse.php @@ -61,7 +61,7 @@ private function __construct(string $raw_response, string $state, int $size, Dat } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getRawResponseContent(): string { @@ -69,7 +69,7 @@ public function getRawResponseContent(): string } /** - * {@inheritDoc} + * {@inheritdoc} * * @throws BadResponseException */ @@ -153,7 +153,7 @@ public function getByUid(string $uid): ?User } /** - * {@inheritDoc} + * {@inheritdoc} */ public function count(): int { @@ -161,7 +161,7 @@ public function count(): int } /** - * {@inheritDoc} + * {@inheritdoc} */ public function getIterator(): ArrayIterator { diff --git a/src/Settings.php b/src/Settings.php index 65c9f27..3bba9e8 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -29,7 +29,7 @@ class Settings /** * Create a new Settings instance. * - * @param string $auth_token For token generation you can use `AuthToken::generate()` + * @param string $auth_token For token generation you can use `AuthToken::generate()` * @param string|null $base_uri * @param mixed[]|null $guzzle_options */ diff --git a/tests/AbstractTestCase.php b/tests/AbstractTestCase.php index f8d29bf..542e504 100644 --- a/tests/AbstractTestCase.php +++ b/tests/AbstractTestCase.php @@ -22,7 +22,7 @@ abstract class AbstractTestCase extends TestCase protected $guzzle_handler; /** - * {@inheritDoc} + * {@inheritdoc} */ protected function setUp(): void { diff --git a/tests/Feature/ClientTest.php b/tests/Feature/ClientTest.php index e4f068f..fef86d1 100644 --- a/tests/Feature/ClientTest.php +++ b/tests/Feature/ClientTest.php @@ -43,7 +43,7 @@ class ClientTest extends AbstractTestCase protected $report_type; /** - * {@inheritDoc} + * {@inheritdoc} */ protected function setUp(): void { diff --git a/tests/Unit/ClientTest.php b/tests/Unit/ClientTest.php index c0e6609..5435ea3 100644 --- a/tests/Unit/ClientTest.php +++ b/tests/Unit/ClientTest.php @@ -50,7 +50,7 @@ class ClientTest extends AbstractTestCase protected $settings; /** - * {@inheritDoc} + * {@inheritdoc} */ protected function setUp(): void { @@ -119,20 +119,20 @@ public function testDoRequestWithSecurityError(): void 'get', new Response( 403, ['content-type' => 'application/json;charset=utf-8'], \json_encode((object) [ - 'uid' => '', - 'stamp' => $stamp = DateTimeFactory::toIso8601Zulu(new DateTime), - 'cls' => 'Security', - 'type' => 'SecurityAuthTimeoutedStamp', - 'name' => 'Метка времени просрочена', - 'message' => 'Метка времени Thu Jan 05 16:45:23 UTC 2017 просрочена - income_age:5, ' . - 'server_time:Fri Jul 05 14:55:44 UTC 2019', - 'data' => (object) [ - 'income_stamp' => '2017-01-05T16:45:23.000Z', - 'income_age' => 5, - 'server_time' => '2019-07-05T14:55:44.604Z', - ], - 'events' => [], - ])), + 'uid' => '', + 'stamp' => $stamp = DateTimeFactory::toIso8601Zulu(new DateTime), + 'cls' => 'Security', + 'type' => 'SecurityAuthTimeoutedStamp', + 'name' => 'Метка времени просрочена', + 'message' => 'Метка времени Thu Jan 05 16:45:23 UTC 2017 просрочена - income_age:5, ' . + 'server_time:Fri Jul 05 14:55:44 UTC 2019', + 'data' => (object) [ + 'income_stamp' => '2017-01-05T16:45:23.000Z', + 'income_age' => 5, + 'server_time' => '2019-07-05T14:55:44.604Z', + ], + 'events' => [], + ])), true ); @@ -154,22 +154,22 @@ public function testDoRequestWithUnknownReportTypeUid(): void 'get', new Response( 500, ['content-type' => 'application/json;charset=utf-8'], \json_encode((object) [ - 'state' => $state = 'fail', - 'stamp' => $stamp = DateTimeFactory::toIso8601Zulu(new DateTime), - 'event' => (object) [ - 'uid' => '', - 'stamp' => $stamp, - 'cls' => 'Data', - 'type' => 'DataSeekObjectError', - 'name' => 'Отсутствие объекта с заданным идентификатором', - 'message' => "Отсутствует объект типа api.model.Report_Type с UID {$report_type_uid}", - 'data' => (object) [ - 'entity_type' => 'api.model.Report_Type', - 'entity_uid' => 'some_report_uid_1@some_domain_uid', + 'state' => $state = 'fail', + 'stamp' => $stamp = DateTimeFactory::toIso8601Zulu(new DateTime), + 'event' => (object) [ + 'uid' => '', + 'stamp' => $stamp, + 'cls' => 'Data', + 'type' => 'DataSeekObjectError', + 'name' => 'Отсутствие объекта с заданным идентификатором', + 'message' => "Отсутствует объект типа api.model.Report_Type с UID {$report_type_uid}", + 'data' => (object) [ + 'entity_type' => 'api.model.Report_Type', + 'entity_uid' => 'some_report_uid_1@some_domain_uid', + ], + 'events' => [], ], - 'events' => [], - ], - ])), + ])), true ); diff --git a/tests/Unit/SettingsTest.php b/tests/Unit/SettingsTest.php index 58b3a1b..7537553 100644 --- a/tests/Unit/SettingsTest.php +++ b/tests/Unit/SettingsTest.php @@ -23,7 +23,7 @@ class SettingsTest extends AbstractTestCase protected $auth_token; /** - * {@inheritDoc} + * {@inheritdoc} */ protected function setUp(): void { From 7191a3e415518f70967af72ff434ee7579c8a9bb Mon Sep 17 00:00:00 2001 From: Paramtamtam Date: Wed, 22 Jan 2020 12:10:45 +0500 Subject: [PATCH 3/5] update phpstan lowest version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8edecbc..17ec471 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "require-dev": { "fzaninotto/faker": "^1.8", "mockery/mockery": "^1.3", - "phpstan/phpstan": "~0.12", + "phpstan/phpstan": "^0.12.1", "phpunit/phpunit": "^7.5", "symfony/var-dumper": "^4.2", "tarampampam/guzzle-url-mock": "^1.1", From 477a41cb37c150f3ef72d3b32388f66214e9461c Mon Sep 17 00:00:00 2001 From: Paramtamtam Date: Wed, 22 Jan 2020 12:35:42 +0500 Subject: [PATCH 4/5] update faker lowest version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 17ec471..0e40ca3 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "tarampampam/wrappers-php": "^1.2" }, "require-dev": { - "fzaninotto/faker": "^1.8", + "fzaninotto/faker": "^1.9.1", "mockery/mockery": "^1.3", "phpstan/phpstan": "^0.12.1", "phpunit/phpunit": "^7.5", From e794813830c711cd41e3f5aac411b681682715cc Mon Sep 17 00:00:00 2001 From: Paramtamtam Date: Wed, 22 Jan 2020 13:09:24 +0500 Subject: [PATCH 5/5] WIP --- .editorconfig | 2 +- CHANGELOG.md | 5 +---- phpstan.neon.dist | 7 +++++++ src/Exceptions/BadResponseException.php | 2 +- src/Exceptions/TokenParserException.php | 2 +- src/Responses/DevPingResponse.php | 2 +- src/Responses/DevTokenResponse.php | 2 +- src/Responses/Entities/Balance.php | 2 +- src/Responses/Entities/CleanOptions.php | 2 +- src/Responses/Entities/Domain.php | 2 +- src/Responses/Entities/Report.php | 2 +- src/Responses/Entities/ReportMade.php | 2 +- src/Responses/Entities/ReportQuery.php | 2 +- src/Responses/Entities/ReportSourceState.php | 2 +- src/Responses/Entities/ReportState.php | 2 +- src/Responses/Entities/ReportType.php | 2 +- src/Responses/Entities/ReportTypeContent.php | 2 +- src/Responses/Entities/User.php | 2 +- src/Responses/UserBalanceResponse.php | 2 +- src/Responses/UserReportMakeResponse.php | 2 +- src/Responses/UserReportRefreshResponse.php | 2 +- src/Responses/UserReportResponse.php | 2 +- src/Responses/UserReportTypesResponse.php | 2 +- src/Responses/UserReportsResponse.php | 2 +- src/Responses/UserResponse.php | 2 +- tests/Unit/DateTimeFactoryTest.php | 8 ++++++++ 26 files changed, 39 insertions(+), 27 deletions(-) diff --git a/.editorconfig b/.editorconfig index 9cbb16e..201e27d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,7 +11,7 @@ trim_trailing_whitespace = true [*.{md,json}] trim_trailing_whitespace = false -[*.{yml,yaml,sh,conf}] +[*.{yml,yaml,sh,conf,*neon*}] indent_size = 2 [Makefile] diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e78774..c60db47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,16 +10,13 @@ The format is based on [Keep a Changelog][keepachangelog] and this project adher - Tests running using GitHub Actions - `phpstan` configuration file with disabled `checkGenericClassInNonGenericObjectType` and `checkMissingIterableValueType` +- PHP 7.4 tests using CI ### Changed - StyleCI rules. Enabled: `length_ordered_imports`, disabled: `alpha_ordered_imports` - Updated dev-dependency versions - Anonymous functions now static (where this is possible) -- `BadResponseException::wrongJson` now returns `self` instead `static` -- `TokenParserException::cannotParseToken` now returns `self` instead `static` -- Method `::fromHttpResponse` in all response classes now returns `self` instead `static` -- Method `::fromArray` in all entity classes now returns `self` instead `static` ## v3.2.0 diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 887e214..541c8ec 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,5 +2,12 @@ parameters: level: 'max' paths: - src + ignoreErrors: + - # Replacing with `return new self` or classes finalization requires major version upping. Make it on next major release + message: '#Unsafe usage of new static\(\)#' + paths: + - src/Responses/*Response.php + - src/Responses/Entities/*.php + - src/Exceptions/*Exception.php checkGenericClassInNonGenericObjectType: false checkMissingIterableValueType: false diff --git a/src/Exceptions/BadResponseException.php b/src/Exceptions/BadResponseException.php index f9a9ab9..fbbe885 100644 --- a/src/Exceptions/BadResponseException.php +++ b/src/Exceptions/BadResponseException.php @@ -44,7 +44,7 @@ public static function wrongJson(ResponseInterface $http_response, ?string $message = null, ?Throwable $prev = null): self { - return new self($http_response, $message ?? 'Server sent wrong json', 0, $prev); + return new static($http_response, $message ?? 'Server sent wrong json', 0, $prev); } /** diff --git a/src/Exceptions/TokenParserException.php b/src/Exceptions/TokenParserException.php index d062c01..c297ad2 100644 --- a/src/Exceptions/TokenParserException.php +++ b/src/Exceptions/TokenParserException.php @@ -18,6 +18,6 @@ class TokenParserException extends RuntimeException implements B2BApiExceptionIn */ public static function cannotParseToken(?string $message = null, int $code = 0, ?Throwable $prev = null): self { - return new self($message ?? 'Cannot parse token', $code, $prev); + return new static($message ?? 'Cannot parse token', $code, $prev); } } diff --git a/src/Responses/DevPingResponse.php b/src/Responses/DevPingResponse.php index 229171d..156f15a 100644 --- a/src/Responses/DevPingResponse.php +++ b/src/Responses/DevPingResponse.php @@ -75,7 +75,7 @@ public static function fromHttpResponse(HttpResponseInterface $response): self throw BadResponseException::wrongJson($response, $e->getMessage(), $e); } - return new self( + return new static( $raw_response, $as_array['value'], $as_array['in'], diff --git a/src/Responses/DevTokenResponse.php b/src/Responses/DevTokenResponse.php index 60029fd..8336578 100644 --- a/src/Responses/DevTokenResponse.php +++ b/src/Responses/DevTokenResponse.php @@ -137,7 +137,7 @@ public static function fromHttpResponse(HttpResponseInterface $response): self throw BadResponseException::wrongJson($response, $e->getMessage(), $e); } - return new self( + return new static( $raw_response, $as_array['user'], $as_array['pass'], diff --git a/src/Responses/Entities/Balance.php b/src/Responses/Entities/Balance.php index 1ac6acb..ef7fbd8 100644 --- a/src/Responses/Entities/Balance.php +++ b/src/Responses/Entities/Balance.php @@ -92,7 +92,7 @@ public function __construct(string $report_type_uid, */ public static function fromArray(array $data): self { - return new self( + return new static( $data['report_type_uid'], $data['balance_type'], $data['quote_init'], diff --git a/src/Responses/Entities/CleanOptions.php b/src/Responses/Entities/CleanOptions.php index 13b89d7..92eaeb7 100644 --- a/src/Responses/Entities/CleanOptions.php +++ b/src/Responses/Entities/CleanOptions.php @@ -40,7 +40,7 @@ public function __construct(?int $process_response, ?int $process_request, ?int */ public static function fromArray(array $data): self { - return new self( + return new static( $data['Process_Response'] ?? null, $data['Process_Request'] ?? null, $data['ReportLog'] ?? null diff --git a/src/Responses/Entities/Domain.php b/src/Responses/Entities/Domain.php index 4ca1af5..ab481a8 100644 --- a/src/Responses/Entities/Domain.php +++ b/src/Responses/Entities/Domain.php @@ -133,7 +133,7 @@ public function __construct(string $uid, */ public static function fromArray(array $data): self { - return new self( + return new static( $data['uid'], $data['comment'], $data['name'], diff --git a/src/Responses/Entities/Report.php b/src/Responses/Entities/Report.php index 0302d07..dd3dc82 100644 --- a/src/Responses/Entities/Report.php +++ b/src/Responses/Entities/Report.php @@ -189,7 +189,7 @@ public function __construct(string $uid, */ public static function fromArray(array $data): self { - return new self( + return new static( $data['uid'], $data['comment'], $data['name'], diff --git a/src/Responses/Entities/ReportMade.php b/src/Responses/Entities/ReportMade.php index 2783a27..a927496 100644 --- a/src/Responses/Entities/ReportMade.php +++ b/src/Responses/Entities/ReportMade.php @@ -50,7 +50,7 @@ public function __construct(string $report_uid, bool $is_new, ?string $process_r */ public static function fromArray(array $data): self { - return new self( + return new static( $data['uid'], $data['isnew'], $data['process_request_uid'] ?? null, diff --git a/src/Responses/Entities/ReportQuery.php b/src/Responses/Entities/ReportQuery.php index 23fbbc2..62cfb0b 100644 --- a/src/Responses/Entities/ReportQuery.php +++ b/src/Responses/Entities/ReportQuery.php @@ -40,7 +40,7 @@ public function __construct(?string $type, ?string $body, ?array $data) */ public static function fromArray(array $data): self { - return new self( + return new static( $data['type'] ?? null, $data['body'] ?? null, $data['data'] ?? null diff --git a/src/Responses/Entities/ReportSourceState.php b/src/Responses/Entities/ReportSourceState.php index 46c4f05..61380f3 100644 --- a/src/Responses/Entities/ReportSourceState.php +++ b/src/Responses/Entities/ReportSourceState.php @@ -55,7 +55,7 @@ public function __construct(string $name, string $state, ?array $data) */ public static function fromArray(array $data): self { - return new self( + return new static( $data['_id'] ?? $data['id'] ?? $data['name'], $data['state'], $data['data'] ?? null diff --git a/src/Responses/Entities/ReportState.php b/src/Responses/Entities/ReportState.php index 16ac7c2..a4e6233 100644 --- a/src/Responses/Entities/ReportState.php +++ b/src/Responses/Entities/ReportState.php @@ -26,7 +26,7 @@ public function __construct(array $source_states) */ public static function fromArray(array $data): self { - return new self( + return new static( \array_map(static function (array $report_data): ReportSourceState { return ReportSourceState::fromArray($report_data); }, $data['sources']) diff --git a/src/Responses/Entities/ReportType.php b/src/Responses/Entities/ReportType.php index 316cb41..c1ee155 100644 --- a/src/Responses/Entities/ReportType.php +++ b/src/Responses/Entities/ReportType.php @@ -253,7 +253,7 @@ public function __construct(string $uid, */ public static function fromArray(array $data): self { - return new self( + return new static( $data['uid'], $data['comment'], $data['name'], diff --git a/src/Responses/Entities/ReportTypeContent.php b/src/Responses/Entities/ReportTypeContent.php index d985f65..c24610a 100644 --- a/src/Responses/Entities/ReportTypeContent.php +++ b/src/Responses/Entities/ReportTypeContent.php @@ -33,7 +33,7 @@ public function __construct(array $sources, array $fields) */ public static function fromArray(array $data): self { - return new self( + return new static( $data['sources'], $data['fields'] ); diff --git a/src/Responses/Entities/User.php b/src/Responses/Entities/User.php index 8b8d417..6f064af 100644 --- a/src/Responses/Entities/User.php +++ b/src/Responses/Entities/User.php @@ -196,7 +196,7 @@ public function __construct(string $uid, */ public static function fromArray(array $data): self { - return new self( + return new static( $data['uid'], $data['comment'], $data['contacts'], diff --git a/src/Responses/UserBalanceResponse.php b/src/Responses/UserBalanceResponse.php index 93bafed..6057de7 100644 --- a/src/Responses/UserBalanceResponse.php +++ b/src/Responses/UserBalanceResponse.php @@ -85,7 +85,7 @@ public static function fromHttpResponse(HttpResponseInterface $response): self return Balance::fromArray($balance_data); }, $as_array['data']); - return new self( + return new static( $raw_response, $as_array['state'], $as_array['size'], diff --git a/src/Responses/UserReportMakeResponse.php b/src/Responses/UserReportMakeResponse.php index 003d800..902e4e2 100644 --- a/src/Responses/UserReportMakeResponse.php +++ b/src/Responses/UserReportMakeResponse.php @@ -85,7 +85,7 @@ public static function fromHttpResponse(HttpResponseInterface $response): self return ReportMade::fromArray($data); }, $as_array['data']); - return new self( + return new static( $raw_response, $as_array['state'], $as_array['size'], diff --git a/src/Responses/UserReportRefreshResponse.php b/src/Responses/UserReportRefreshResponse.php index 8d037b2..516c2df 100644 --- a/src/Responses/UserReportRefreshResponse.php +++ b/src/Responses/UserReportRefreshResponse.php @@ -85,7 +85,7 @@ public static function fromHttpResponse(HttpResponseInterface $response): self return ReportMade::fromArray($data); }, $as_array['data']); - return new self( + return new static( $raw_response, $as_array['state'], $as_array['size'], diff --git a/src/Responses/UserReportResponse.php b/src/Responses/UserReportResponse.php index 95ed1f0..8e04e8c 100644 --- a/src/Responses/UserReportResponse.php +++ b/src/Responses/UserReportResponse.php @@ -85,7 +85,7 @@ public static function fromHttpResponse(HttpResponseInterface $response): self return Report::fromArray($data); }, $as_array['data']); - return new self( + return new static( $raw_response, $as_array['state'], $as_array['size'], diff --git a/src/Responses/UserReportTypesResponse.php b/src/Responses/UserReportTypesResponse.php index d62abaa..a0c5398 100644 --- a/src/Responses/UserReportTypesResponse.php +++ b/src/Responses/UserReportTypesResponse.php @@ -97,7 +97,7 @@ public static function fromHttpResponse(HttpResponseInterface $response): self return ReportType::fromArray($report_type_data); }, $as_array['data']); - return new self( + return new static( $raw_response, $as_array['state'], $as_array['size'], diff --git a/src/Responses/UserReportsResponse.php b/src/Responses/UserReportsResponse.php index 01c08dd..dfc8722 100644 --- a/src/Responses/UserReportsResponse.php +++ b/src/Responses/UserReportsResponse.php @@ -97,7 +97,7 @@ public static function fromHttpResponse(HttpResponseInterface $response): self return Report::fromArray($report_data); }, $as_array['data']); - return new self( + return new static( $raw_response, $as_array['state'], $as_array['size'], diff --git a/src/Responses/UserResponse.php b/src/Responses/UserResponse.php index 75e498e..d601c32 100644 --- a/src/Responses/UserResponse.php +++ b/src/Responses/UserResponse.php @@ -85,7 +85,7 @@ public static function fromHttpResponse(HttpResponseInterface $response): self return User::fromArray($user_data); }, $as_array['data']); - return new self( + return new static( $raw_response, $as_array['state'], $as_array['size'], diff --git a/tests/Unit/DateTimeFactoryTest.php b/tests/Unit/DateTimeFactoryTest.php index 80898c9..bf9f2b0 100644 --- a/tests/Unit/DateTimeFactoryTest.php +++ b/tests/Unit/DateTimeFactoryTest.php @@ -97,6 +97,10 @@ public function testToIso8601ZuluWithoutMicroseconds(): void $date_time = DateTime::createFromFormat('Y-m-d H:i:s', '2009-02-15 15:16:17'); $this->assertSame('2009-02-15T15:16:17.000Z', DateTimeFactory::toIso8601Zulu($date_time)); + + $date_time = DateTime::createFromFormat('Y-m-d H:i:s', '2009-02-15 15:16:00'); + + $this->assertSame('2009-02-15T15:16:00.000Z', DateTimeFactory::toIso8601Zulu($date_time)); } /** @@ -107,6 +111,10 @@ public function testToIso8601ZuluWithoutMs(): void $date_time = DateTime::createFromFormat('Y-m-d H:i:s', '2009-02-15 15:16:17'); $this->assertSame('2009-02-15T15:16:17Z', DateTimeFactory::toIso8601ZuluWithoutMs($date_time)); + + $date_time = DateTime::createFromFormat('Y-m-d H:i:s', '2009-02-15 15:16:00'); + + $this->assertSame('2009-02-15T15:16:00Z', DateTimeFactory::toIso8601ZuluWithoutMs($date_time)); } /**