diff --git a/.github/SECURITY.md b/.github/SECURITY.md index 017f967..7236d4b 100644 --- a/.github/SECURITY.md +++ b/.github/SECURITY.md @@ -3,7 +3,7 @@ ## Supported Versions After each new major release, the previous release will be supported for no -less than 2 years, unless explictly stated otherwise. This may mean that there +less than 2 years, unless explicitly stated otherwise. This may mean that there are multiple supported versions at any given time. ## Reporting a Vulnerability diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 42c11f1..b37fe5d 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -7,11 +7,11 @@ on: jobs: phpstan: name: PHPStan - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -23,14 +23,14 @@ jobs: update: true - name: Install Dependencies - uses: nick-invision/retry@v2 + uses: nick-invision/retry@v3 with: timeout_minutes: 5 max_attempts: 5 command: composer update --no-interaction --no-progress - name: Install PHPStan - uses: nick-invision/retry@v2 + uses: nick-invision/retry@v3 with: timeout_minutes: 5 max_attempts: 5 @@ -41,11 +41,11 @@ jobs: psalm: name: Psalm - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -57,14 +57,14 @@ jobs: update: true - name: Install Dependencies - uses: nick-invision/retry@v2 + uses: nick-invision/retry@v3 with: timeout_minutes: 5 max_attempts: 5 command: composer update --no-interaction --no-progress - name: Install Psalm - uses: nick-invision/retry@v2 + uses: nick-invision/retry@v3 with: timeout_minutes: 5 max_attempts: 5 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e1bed42..f2a04d2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,15 +7,15 @@ on: jobs: tests: name: PHP ${{ matrix.php }} - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 strategy: matrix: - php: ['7.4', '8.0', '8.1', '8.2'] + php: ['8.1', '8.2', '8.3', '8.4'] steps: - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -30,14 +30,14 @@ jobs: run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - name: Install Dependencies - uses: nick-invision/retry@v2 + uses: nick-invision/retry@v3 with: timeout_minutes: 5 max_attempts: 5 command: composer update --no-interaction --no-progress - name: Install PHPUnit - uses: nick-invision/retry@v2 + uses: nick-invision/retry@v3 with: timeout_minutes: 5 max_attempts: 5 diff --git a/.stubs/Http/Promise/Promise.phpstub b/.stubs/Http/Promise/Promise.phpstub index 0cde7ba..05f3bed 100644 --- a/.stubs/Http/Promise/Promise.phpstub +++ b/.stubs/Http/Promise/Promise.phpstub @@ -43,7 +43,7 @@ interface Promise * * @return Promise a new resolved promise with value of the executed callback (onFulfilled / onRejected) */ - public function then(callable $onFulfilled = null, callable $onRejected = null); + public function then(?callable $onFulfilled = null, ?callable $onRejected = null); /** * Returns the state of the promise, one of PENDING, FULFILLED or REJECTED. diff --git a/.styleci.yml b/.styleci.yml index 0eeb39a..fcb5e60 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -16,6 +16,5 @@ enabled: disabled: - native_constant_invocation_symfony - native_function_invocation_symfony - - no_superfluous_phpdoc_tags_symfony - phpdoc_to_comment - phpdoc_var_without_name diff --git a/CHANGELOG.md b/CHANGELOG.md index 4141155..8e6c781 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,33 @@ CHANGE LOG ========== +## V5.0 (23/02/2025) + +* Added PHP 8.4 support +* Dropped PHP 7.4 and 8.0 support +* Moved various param types to native PHP types + + +## V4.7 (17/03/2024) + +* Add support for `php-http/cache-plugin:^2.0` + + +## V4.6.1 (17/03/2024) + +* Fixed issues with `Src` and` Downloads` + + +## V4.6 (03/12/2023) + +* Add support for `symfony/options-resolver:^7.0` + + +## V4.5 (08/10/2023) + +* Added PHP 8.3 support + + ## V4.4 (30/04/2023) * Added support for `psr/http-message` v2 diff --git a/LICENSE b/LICENSE index 48b61e0..72ea6f3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2018-2023 Graham Campbell +Copyright (c) 2018-2025 Graham Campbell 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/README.md b/README.md index 5450dea..809bfd8 100644 --- a/README.md +++ b/README.md @@ -23,13 +23,12 @@ Check out the [change log](CHANGELOG.md), [releases](https://github.com/Bitbucke ## Installation -This version supports [PHP](https://php.net) 7.4-8.2. To get started, simply require the project using [Composer](https://getcomposer.org). You will also need to install packages that "provide" [`psr/http-client-implementation`](https://packagist.org/providers/psr/http-client-implementation) and [`psr/http-factory-implementation`](https://packagist.org/providers/psr/http-factory-implementation). +This version supports [PHP](https://php.net) 8.1-8.4. To get started, simply require the project using [Composer](https://getcomposer.org). You will also need to install packages that "provide" [`psr/http-client-implementation`](https://packagist.org/providers/psr/http-client-implementation) and [`psr/http-factory-implementation`](https://packagist.org/providers/psr/http-factory-implementation). ### Standard Installation ```bash -$ composer require "bitbucket/client:^4.4" \ - "guzzlehttp/guzzle:^7.5.1" "http-interop/http-factory-guzzle:^1.2" +$ composer require "bitbucket/client:^5.0" "guzzlehttp/guzzle:^7.9.2" ``` ### Framework Integration @@ -37,7 +36,7 @@ $ composer require "bitbucket/client:^4.4" \ #### Laravel: ```bash -$ composer require "graham-campbell/bitbucket:^10.1" +$ composer require "graham-campbell/bitbucket:^11.0" ``` We are decoupled from any HTTP messaging client by using [PSR-7](https://www.php-fig.org/psr/psr-7/), [PSR-17](https://www.php-fig.org/psr/psr-17/), [PSR-18](https://www.php-fig.org/psr/psr-18/), and [HTTPlug](https://httplug.io/). You can visit [HTTPlug for library users](https://docs.php-http.org/en/latest/httplug/users.html) to get more information about installing HTTPlug related packages. The framework integration [`graham-campbell/bitbucket`](https://github.com/GrahamCampbell/Laravel-Bitbucket) is by [Graham Campbell](https://github.com/GrahamCampbell). @@ -45,7 +44,7 @@ We are decoupled from any HTTP messaging client by using [PSR-7](https://www.php ## Usage -The main point of entry is the `Bitbucket\Client` class. Simply create a new instance of that, authenticate, and you're good to go! As of time of writing (Tuesday 29th June 2020), every endpoint (excluding issue export and import, and various deprecated endpoints) available on the Bitbucket API 2.0 is also available through this PHP client. We'd recommend looking through the [Bitbucket documentation](https://developer.atlassian.com/cloud/bitbucket/rest/intro/), and also the [source code](https://github.com/BitbucketPHP/Client/tree/4.4/src) to get a full picture of what is available to use. +The main point of entry is the `Bitbucket\Client` class. Simply create a new instance of that, authenticate, and you're good to go! As of time of writing (Tuesday 29th June 2020), every endpoint (excluding issue export and import, and various deprecated endpoints) available on the Bitbucket API 2.0 is also available through this PHP client. We'd recommend looking through the [Bitbucket documentation](https://developer.atlassian.com/cloud/bitbucket/rest/intro/), and also the [source code](https://github.com/BitbucketPHP/Client/tree/5.0/src) to get a full picture of what is available to use. ### Authentication diff --git a/composer.json b/composer.json index e59d0b6..29209e2 100644 --- a/composer.json +++ b/composer.json @@ -11,24 +11,22 @@ } ], "require": { - "php": "^7.4.15 || ^8.0.2", + "php": "^8.1", "ext-json": "*", - "php-http/cache-plugin": "^1.8", - "php-http/client-common": "^2.6.1", - "php-http/discovery": "^1.17", - "php-http/httplug": "^2.4", - "php-http/multipart-stream-builder": "^1.3", - "psr/cache": "^1.0 || ^2.0 || ^3.0", + "php-http/cache-plugin": "^2.0.1", + "php-http/client-common": "^2.7.2", + "php-http/discovery": "^1.20.0", + "php-http/httplug": "^2.4.1", + "php-http/multipart-stream-builder": "^1.4.2", + "psr/cache": "^2.0 || ^3.0", "psr/http-client-implementation": "^1.0", "psr/http-factory-implementation": "^1.0", - "psr/http-message": "^1.1 || ^2.0", - "symfony/polyfill-php80": "^1.26" + "psr/http-message": "^1.1 || ^2.0" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", - "guzzlehttp/guzzle": "^7.5.1", - "http-interop/http-factory-guzzle": "^1.2", - "php-http/mock-client": "^1.5.1" + "guzzlehttp/guzzle": "^7.9.2", + "php-http/mock-client": "^1.6.1" }, "autoload": { "psr-4": { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 0e7d348..e4d3870 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,12 +1,62 @@ parameters: ignoreErrors: - - message: "#^Property Bitbucket\\\\Api\\\\AbstractApi\\:\\:\\$perPage is never written, only read\\.$#" + message: '#^Property Bitbucket\\Api\\AbstractApi\:\:\$perPage \(int\|null\) is never assigned int so it can be removed from the property type\.$#' + identifier: property.unusedType count: 1 path: src/Api/AbstractApi.php - - message: "#^Variable method call on Bitbucket\\\\Api\\\\AbstractApi\\.$#" + message: '#^Parameter \#3 \$options of method Http\\Message\\MultipartStream\\MultipartStreamBuilder\:\:addResource\(\) expects array\{headers\?\: array\, filename\?\: string\}, array given\.$#' + identifier: argument.type + count: 1 + path: src/Api/Repositories/Workspaces/Downloads.php + + - + message: '#^Parameter \#3 \$options of method Http\\Message\\MultipartStream\\MultipartStreamBuilder\:\:addResource\(\) expects array\{headers\?\: array\, filename\?\: string\}, array given\.$#' + identifier: argument.type + count: 1 + path: src/Api/Repositories/Workspaces/Issues/Attachments.php + + - + message: '#^Parameter \#3 \$options of method Http\\Message\\MultipartStream\\MultipartStreamBuilder\:\:addResource\(\) expects array\{headers\?\: array\, filename\?\: string\}, array given\.$#' + identifier: argument.type + count: 1 + path: src/Api/Repositories/Workspaces/Src.php + + - + message: '#^Parameter \#3 \$options of method Http\\Message\\MultipartStream\\MultipartStreamBuilder\:\:addResource\(\) expects array\{headers\?\: array\, filename\?\: string\}, array given\.$#' + identifier: argument.type + count: 1 + path: src/Api/Snippets.php + + - + message: '#^Parameter \#3 \$options of method Http\\Message\\MultipartStream\\MultipartStreamBuilder\:\:addResource\(\) expects array\{headers\?\: array\, filename\?\: string\}, array given\.$#' + identifier: argument.type + count: 2 + path: src/Api/Snippets/Workspaces.php + + - + message: '#^Parameter \#3 \$options of method Http\\Message\\MultipartStream\\MultipartStreamBuilder\:\:addResource\(\) expects array\{headers\?\: array\, filename\?\: string\}, array given\.$#' + identifier: argument.type + count: 1 + path: src/Api/Snippets/Workspaces/Files.php + + - + message: '#^PHPDoc tag @var with type string is not subtype of native type non\-empty\-string\|false\.$#' + identifier: varTag.nativeType + count: 1 + path: src/HttpClient/Util/JsonArray.php + + - + message: '#^PHPDoc tag @var with type Closure\(Bitbucket\\Api\\AbstractApi\)\: Bitbucket\\Api\\AbstractApi is not subtype of type Closure\(Bitbucket\\Api\\AbstractApi\)\: Bitbucket\\Api\\AbstractApi\.$#' + identifier: varTag.type + count: 1 + path: src/ResultPager.php + + - + message: '#^Variable method call on Bitbucket\\Api\\AbstractApi\.$#' + identifier: method.dynamicName count: 1 path: src/ResultPager.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 4a526b0..6749436 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,21 +2,11 @@ includes: - phpstan-baseline.neon - vendor-bin/phpstan/vendor/phpstan/phpstan-deprecation-rules/rules.neon - vendor-bin/phpstan/vendor/phpstan/phpstan-strict-rules/rules.neon - - vendor-bin/phpstan/vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon - -rules: - - Ergebnis\PHPStan\Rules\Closures\NoNullableReturnTypeDeclarationRule - - Ergebnis\PHPStan\Rules\Expressions\NoCompactRule - - Ergebnis\PHPStan\Rules\Expressions\NoEmptyRule - - Ergebnis\PHPStan\Rules\Expressions\NoEvalRule - - Ergebnis\PHPStan\Rules\Files\DeclareStrictTypesRule - - Ergebnis\PHPStan\Rules\Methods\PrivateInFinalClassRule parameters: level: max paths: - src - checkMissingIterableValueType: false stubFiles: - .stubs/Psr/Http/Message/StreamInterface.phpstub - .stubs/Psr/Http/Message/UriInterface.phpstub @@ -25,3 +15,6 @@ parameters: - .stubs/Psr/Http/Message/ResponseInterface.phpstub - .stubs/Http/Promise/Promise.phpstub - .stubs/Http/Client/Common/Plugin.phpstub + ignoreErrors: + - '#return type has no value type specified in iterable type array#' + - '#no value type specified in iterable type array#' diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4ac266f..b689bdf 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,13 +1,13 @@ - + ./tests - + ./src - + diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 31ddd8f..2e96472 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,11 +1,44 @@ - + + + + getOptions()]]> + + + + + getOptions()]]> + + + + + getOptions()]]> + + + + + getOptions()]]> + + + + + getOptions()]]> + getOptions()]]> + + + + + getOptions()]]> + + + + + + + - - $clone->perPage + + perPage]]> - - $closure($api) - diff --git a/psalm.xml b/psalm.xml index 2e19b19..6327984 100644 --- a/psalm.xml +++ b/psalm.xml @@ -6,6 +6,8 @@ xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" errorBaseline="psalm-baseline.xml" + findUnusedBaselineEntry="true" + findUnusedCode="false" > diff --git a/src/Api/AbstractApi.php b/src/Api/AbstractApi.php index ef8ccc8..b43c4a3 100644 --- a/src/Api/AbstractApi.php +++ b/src/Api/AbstractApi.php @@ -18,6 +18,7 @@ use Bitbucket\HttpClient\Util\JsonArray; use Bitbucket\HttpClient\Util\QueryStringBuilder; use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\StreamInterface; /** * @author Joseph Bielawski @@ -32,36 +33,18 @@ abstract class AbstractApi */ private const URI_PREFIX = '/2.0/'; - /** - * The client instance. - * - * @var Client - */ - private $client; + private readonly Client $client; - /** - * The per page parameter. - * - * @var int|null - */ - private $perPage; + private ?int $perPage; - /** - * Create a new API instance. - * - * @param Client $client - * - * @return void - */ public function __construct(Client $client) { $this->client = $client; + $this->perPage = null; } /** * Get the bitbucket client instance. - * - * @return Client */ protected function getClient(): Client { @@ -71,13 +54,9 @@ protected function getClient(): Client /** * Send a GET request with query params and return the raw response. * - * @param string $uri - * @param array $params * @param array $headers * * @throws \Http\Client\Exception - * - * @return \Psr\Http\Message\ResponseInterface */ protected function getAsResponse(string $uri, array $params = [], array $headers = []): ResponseInterface { @@ -91,13 +70,9 @@ protected function getAsResponse(string $uri, array $params = [], array $headers /** * Send a GET request with query params. * - * @param string $uri - * @param array $params * @param array $headers * * @throws \Http\Client\Exception - * - * @return array */ protected function get(string $uri, array $params = [], array $headers = []): array { @@ -109,13 +84,9 @@ protected function get(string $uri, array $params = [], array $headers = []): ar /** * Send a POST request with JSON-encoded params. * - * @param string $uri - * @param array $params * @param array $headers * * @throws \Http\Client\Exception - * - * @return array */ protected function post(string $uri, array $params = [], array $headers = []): array { @@ -131,15 +102,11 @@ protected function post(string $uri, array $params = [], array $headers = []): a /** * Send a POST request with raw data. * - * @param string $uri - * @param string|\Psr\Http\Message\StreamInterface|null $body - * @param array $headers + * @param array $headers * * @throws \Http\Client\Exception - * - * @return array */ - protected function postRaw(string $uri, $body = null, array $headers = []): array + protected function postRaw(string $uri, string|StreamInterface|null $body = null, array $headers = []): array { $response = $this->client->getHttpClient()->post(self::prepareUri($uri), $headers, $body ?? ''); @@ -149,13 +116,9 @@ protected function postRaw(string $uri, $body = null, array $headers = []): arra /** * Send a PUT request with JSON-encoded params. * - * @param string $uri - * @param array $params * @param array $headers * * @throws \Http\Client\Exception - * - * @return array */ protected function put(string $uri, array $params = [], array $headers = []): array { @@ -171,15 +134,11 @@ protected function put(string $uri, array $params = [], array $headers = []): ar /** * Send a PUT request with raw data. * - * @param string $uri - * @param string|\Psr\Http\Message\StreamInterface|null $body - * @param array $headers + * @param array $headers * * @throws \Http\Client\Exception - * - * @return array */ - protected function putRaw(string $uri, $body = null, array $headers = []): array + protected function putRaw(string $uri, string|StreamInterface|null $body = null, array $headers = []): array { $response = $this->client->getHttpClient()->put(self::prepareUri($uri), $headers, $body ?? ''); @@ -189,13 +148,9 @@ protected function putRaw(string $uri, $body = null, array $headers = []): array /** * Send a DELETE request with JSON-encoded params. * - * @param string $uri - * @param array $params * @param array $headers * * @throws \Http\Client\Exception - * - * @return array */ protected function delete(string $uri, array $params = [], array $headers = []): array { @@ -211,15 +166,11 @@ protected function delete(string $uri, array $params = [], array $headers = []): /** * Send a DELETE request with raw data. * - * @param string $uri - * @param string|\Psr\Http\Message\StreamInterface|null $body - * @param array $headers + * @param array $headers * * @throws \Http\Client\Exception - * - * @return array */ - protected function deleteRaw(string $uri, $body = null, array $headers = []): array + protected function deleteRaw(string $uri, string|StreamInterface|null $body = null, array $headers = []): array { $response = $this->client->getHttpClient()->delete(self::prepareUri($uri), $headers, $body ?? ''); @@ -228,11 +179,6 @@ protected function deleteRaw(string $uri, $body = null, array $headers = []): ar /** * Prepare the request URI. - * - * @param string $uri - * @param array $query - * - * @return string */ private static function prepareUri(string $uri, array $query = []): string { @@ -241,10 +187,6 @@ private static function prepareUri(string $uri, array $query = []): string /** * Prepare the request JSON body. - * - * @param array $params - * - * @return string|null */ private static function prepareJsonBody(array $params): ?string { diff --git a/src/Api/Addon.php b/src/Api/Addon.php index 0aad479..6615044 100644 --- a/src/Api/Addon.php +++ b/src/Api/Addon.php @@ -25,13 +25,9 @@ class Addon extends AbstractApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(array $params = []) + public function update(array $params = []): array { $uri = $this->buildAddonUri(); @@ -39,43 +35,29 @@ public function update(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(array $params = []) + public function remove(array $params = []): array { $uri = $this->buildAddonUri(); return $this->delete($uri, $params); } - /** - * @return \Bitbucket\Api\Addon\Linkers - */ - public function linkers() + public function linkers(): Linkers { return new Linkers($this->getClient()); } - /** - * @return \Bitbucket\Api\Addon\Users - */ - public function users() + public function users(): UsersAddon { return new UsersAddon($this->getClient()); } /** * Build the addon URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildAddonUri(string ...$parts) + protected function buildAddonUri(string ...$parts): string { return UriBuilder::build('addon', ...$parts); } diff --git a/src/Api/Addon/Linkers.php b/src/Api/Addon/Linkers.php index bf8fc97..a94e06e 100644 --- a/src/Api/Addon/Linkers.php +++ b/src/Api/Addon/Linkers.php @@ -24,13 +24,9 @@ class Linkers extends AbstractAddonApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildLinkersUri(); @@ -38,38 +34,24 @@ public function list(array $params = []) } /** - * @param string $linker - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $linker, array $params = []) + public function show(string $linker, array $params = []): array { $uri = $this->buildLinkersUri($linker); return $this->get($uri, $params); } - /** - * @param string $linker - * - * @return \Bitbucket\Api\Addon\Linkers\Values - */ - public function values(string $linker) + public function values(string $linker): Values { return new Values($this->getClient(), $linker); } /** * Build the linkers URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildLinkersUri(string ...$parts) + protected function buildLinkersUri(string ...$parts): string { return UriBuilder::build('addon', 'linkers', ...$parts); } diff --git a/src/Api/Addon/Linkers/AbstractLinkersApi.php b/src/Api/Addon/Linkers/AbstractLinkersApi.php index b7ddcfc..2c68764 100644 --- a/src/Api/Addon/Linkers/AbstractLinkersApi.php +++ b/src/Api/Addon/Linkers/AbstractLinkersApi.php @@ -23,21 +23,8 @@ */ abstract class AbstractLinkersApi extends AbstractAddonApi { - /** - * The linker. - * - * @var string - */ - protected $linker; + protected readonly string $linker; - /** - * Create a new API instance. - * - * @param Client $client - * @param string $linker - * - * @return void - */ public function __construct(Client $client, string $linker) { parent::__construct($client); diff --git a/src/Api/Addon/Linkers/Values.php b/src/Api/Addon/Linkers/Values.php index d24a363..58e3f04 100644 --- a/src/Api/Addon/Linkers/Values.php +++ b/src/Api/Addon/Linkers/Values.php @@ -23,13 +23,9 @@ class Values extends AbstractLinkersApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildValuesUri()); @@ -37,13 +33,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildValuesUri()); @@ -51,14 +43,9 @@ public function create(array $params = []) } /** - * @param string $id - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $id, array $params = []) + public function show(string $id, array $params = []): array { $uri = $this->buildValuesUri($id); @@ -66,14 +53,9 @@ public function show(string $id, array $params = []) } /** - * @param string $id - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $id, array $params = []) + public function update(string $id, array $params = []): array { $uri = $this->buildValuesUri($id); @@ -81,14 +63,9 @@ public function update(string $id, array $params = []) } /** - * @param string $id - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $id, array $params = []) + public function remove(string $id, array $params = []): array { $uri = $this->buildValuesUri($id); @@ -97,12 +74,8 @@ public function remove(string $id, array $params = []) /** * Build the values URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildValuesUri(string ...$parts) + protected function buildValuesUri(string ...$parts): string { return UriBuilder::build('addon', 'linkers', $this->linker, 'values', ...$parts); } diff --git a/src/Api/Addon/Users.php b/src/Api/Addon/Users.php index 64c6532..288f77b 100644 --- a/src/Api/Addon/Users.php +++ b/src/Api/Addon/Users.php @@ -22,12 +22,7 @@ */ class Users extends AbstractAddonApi { - /** - * @param string $username - * - * @return \Bitbucket\Api\Addon\Users\Events - */ - public function events(string $username) + public function events(string $username): Events { return new Events($this->getClient(), $username); } diff --git a/src/Api/Addon/Users/AbstractUsersApi.php b/src/Api/Addon/Users/AbstractUsersApi.php index 91ecdd3..dd350e0 100644 --- a/src/Api/Addon/Users/AbstractUsersApi.php +++ b/src/Api/Addon/Users/AbstractUsersApi.php @@ -23,21 +23,8 @@ */ abstract class AbstractUsersApi extends AbstractAddonApi { - /** - * The username. - * - * @var string - */ - protected $username; + protected readonly string $username; - /** - * Create a new API instance. - * - * @param Client $client - * @param string $username - * - * @return void - */ public function __construct(Client $client, string $username) { parent::__construct($client); diff --git a/src/Api/Addon/Users/Events.php b/src/Api/Addon/Users/Events.php index 1886aaf..432c66d 100644 --- a/src/Api/Addon/Users/Events.php +++ b/src/Api/Addon/Users/Events.php @@ -23,14 +23,9 @@ class Events extends AbstractUsersApi { /** - * @param string $event - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(string $event, array $params = []) + public function create(string $event, array $params = []): array { $uri = $this->buildEventsUri($event); @@ -39,12 +34,8 @@ public function create(string $event, array $params = []) /** * Build the events URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildEventsUri(string ...$parts) + protected function buildEventsUri(string ...$parts): string { return UriBuilder::build('addon', 'users', $this->username, 'events', ...$parts); } diff --git a/src/Api/CurrentUser.php b/src/Api/CurrentUser.php index c610721..f090dfb 100644 --- a/src/Api/CurrentUser.php +++ b/src/Api/CurrentUser.php @@ -23,13 +23,9 @@ class CurrentUser extends AbstractApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(array $params = []) + public function show(array $params = []): array { $uri = $this->buildCurrentUserUri(); @@ -37,13 +33,9 @@ public function show(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function listEmails(array $params = []) + public function listEmails(array $params = []): array { $uri = $this->buildCurrentUserUri('emails'); @@ -51,14 +43,9 @@ public function listEmails(array $params = []) } /** - * @param string $email - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function showEmail(string $email, array $params = []) + public function showEmail(string $email, array $params = []): array { $uri = $this->buildCurrentUserUri('emails', $email); @@ -66,13 +53,9 @@ public function showEmail(string $email, array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function listRepositoryPermissions(array $params = []) + public function listRepositoryPermissions(array $params = []): array { $uri = $this->buildCurrentUserUri('permissions', 'repositories'); @@ -80,13 +63,9 @@ public function listRepositoryPermissions(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function listTeamPermissions(array $params = []) + public function listTeamPermissions(array $params = []): array { $uri = $this->buildCurrentUserUri('permissions', 'teams'); @@ -94,13 +73,9 @@ public function listTeamPermissions(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function listWorkspacePermissions(array $params = []) + public function listWorkspacePermissions(array $params = []): array { $uri = $this->buildCurrentUserUri('permissions', 'workspaces'); @@ -108,13 +83,9 @@ public function listWorkspacePermissions(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function listWorkspaces(array $params = []) + public function listWorkspaces(array $params = []): array { $uri = UriBuilder::build('workspaces'); @@ -123,12 +94,8 @@ public function listWorkspaces(array $params = []) /** * Build the current user URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildCurrentUserUri(string ...$parts) + protected function buildCurrentUserUri(string ...$parts): string { return UriBuilder::build('user', ...$parts); } diff --git a/src/Api/HookEvents.php b/src/Api/HookEvents.php index 62c9144..61e8c76 100644 --- a/src/Api/HookEvents.php +++ b/src/Api/HookEvents.php @@ -23,13 +23,9 @@ class HookEvents extends AbstractApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function listUserEvents(array $params = []) + public function listUserEvents(array $params = []): array { $uri = $this->buildHookEventsUri('user'); @@ -37,13 +33,9 @@ public function listUserEvents(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function listRepositoryEvents(array $params = []) + public function listRepositoryEvents(array $params = []): array { $uri = $this->buildHookEventsUri('repository'); @@ -51,13 +43,9 @@ public function listRepositoryEvents(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function listTeamEvents(array $params = []) + public function listTeamEvents(array $params = []): array { $uri = $this->buildHookEventsUri('team'); @@ -65,13 +53,9 @@ public function listTeamEvents(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function listWorkspaceEvents(array $params = []) + public function listWorkspaceEvents(array $params = []): array { $uri = $this->buildHookEventsUri('workspace'); @@ -80,12 +64,8 @@ public function listWorkspaceEvents(array $params = []) /** * Build the hook events URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildHookEventsUri(string ...$parts) + protected function buildHookEventsUri(string ...$parts): string { return UriBuilder::build('hook_events', ...$parts); } diff --git a/src/Api/PullRequests.php b/src/Api/PullRequests.php index 241cfae..61293cc 100644 --- a/src/Api/PullRequests.php +++ b/src/Api/PullRequests.php @@ -23,14 +23,9 @@ class PullRequests extends AbstractApi { /** - * @param string $username - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(string $username, array $params = []) + public function list(string $username, array $params = []): array { $uri = $this->buildPullRequestsUri($username); @@ -39,12 +34,8 @@ public function list(string $username, array $params = []) /** * Build the pull requests URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildPullRequestsUri(string ...$parts) + protected function buildPullRequestsUri(string ...$parts): string { return UriBuilder::build('pullrequests', ...$parts); } diff --git a/src/Api/Repositories.php b/src/Api/Repositories.php index 6587ca3..d3ee791 100644 --- a/src/Api/Repositories.php +++ b/src/Api/Repositories.php @@ -24,37 +24,24 @@ class Repositories extends AbstractApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildRepositoriesUri(); return $this->get($uri, $params); } - /** - * @param string $workspace - * - * @return \Bitbucket\Api\Repositories\Workspaces - */ - public function workspaces(string $workspace) + public function workspaces(string $workspace): RepositoriesWorkspaces { return new RepositoriesWorkspaces($this->getClient(), $workspace); } /** * Build the repositories URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildRepositoriesUri(string ...$parts) + protected function buildRepositoriesUri(string ...$parts): string { return UriBuilder::build('repositories', ...$parts); } diff --git a/src/Api/Repositories/AbstractRepositoriesApi.php b/src/Api/Repositories/AbstractRepositoriesApi.php index 834c16c..b79e715 100644 --- a/src/Api/Repositories/AbstractRepositoriesApi.php +++ b/src/Api/Repositories/AbstractRepositoriesApi.php @@ -23,21 +23,8 @@ */ abstract class AbstractRepositoriesApi extends AbstractApi { - /** - * The workspace. - * - * @var string - */ - protected $workspace; + protected readonly string $workspace; - /** - * Create a new API instance. - * - * @param Client $client - * @param string $workspace - * - * @return void - */ public function __construct(Client $client, string $workspace) { parent::__construct($client); diff --git a/src/Api/Repositories/Workspaces.php b/src/Api/Repositories/Workspaces.php index 18a86c9..3a68b10 100644 --- a/src/Api/Repositories/Workspaces.php +++ b/src/Api/Repositories/Workspaces.php @@ -50,13 +50,9 @@ class Workspaces extends AbstractRepositoriesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildWorkspacesUri(); @@ -64,14 +60,9 @@ public function list(array $params = []) } /** - * @param string $repo - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $repo, array $params = []) + public function show(string $repo, array $params = []): array { $uri = $this->buildWorkspacesUri($repo); @@ -79,14 +70,9 @@ public function show(string $repo, array $params = []) } /** - * @param string $repo - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(string $repo, array $params = []) + public function create(string $repo, array $params = []): array { $uri = $this->buildWorkspacesUri($repo); @@ -94,14 +80,9 @@ public function create(string $repo, array $params = []) } /** - * @param string $repo - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $repo, array $params = []) + public function update(string $repo, array $params = []): array { $uri = $this->buildWorkspacesUri($repo); @@ -109,298 +90,154 @@ public function update(string $repo, array $params = []) } /** - * @param string $repo - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $repo, array $params = []) + public function remove(string $repo, array $params = []): array { $uri = $this->buildWorkspacesUri($repo); return $this->delete($uri, $params); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\BranchingModel - */ - public function branchingModel(string $repo) + public function branchingModel(string $repo): BranchingModel { return new BranchingModel($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\BranchRestrictions - */ - public function branchRestrictions(string $repo) + public function branchRestrictions(string $repo): BranchRestrictions { return new BranchRestrictions($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\Commit - */ - public function commit(string $repo) + public function commit(string $repo): Commit { return new Commit($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\Commits - */ - public function commits(string $repo) + public function commits(string $repo): Commits { return new Commits($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\Components - */ - public function components(string $repo) + public function components(string $repo): Components { return new Components($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\DefaultReviewers - */ - public function defaultReviewers(string $repo) + public function defaultReviewers(string $repo): DefaultReviewers { return new DefaultReviewers($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\DeployKeys - */ - public function deployKeys(string $repo) + public function deployKeys(string $repo): DeployKeys { return new DeployKeys($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\Deployments - */ - public function deployments(string $repo) + public function deployments(string $repo): Deployments { return new Deployments($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\Diffs - */ - public function diffs(string $repo) + public function diffs(string $repo): Diffs { return new Diffs($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\DiffStat - */ - public function diffStat(string $repo) + public function diffStat(string $repo): DiffStat { return new DiffStat($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\Downloads - */ - public function downloads(string $repo) + public function downloads(string $repo): Downloads { return new Downloads($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\Environments - */ - public function environments(string $repo) + public function environments(string $repo): Environments { return new Environments($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\FileHistory - */ - public function fileHistory(string $repo) + public function fileHistory(string $repo): FileHistory { return new FileHistory($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\Forks - */ - public function forks(string $repo) + public function forks(string $repo): Forks { return new Forks($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\Hooks - */ - public function hooks(string $repo) + public function hooks(string $repo): Hooks { return new Hooks($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\Issues - */ - public function issues(string $repo) + public function issues(string $repo): Issues { return new Issues($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\MergeBases - */ - public function mergeBases(string $repo) + public function mergeBases(string $repo): MergeBases { return new MergeBases($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\Milestones - */ - public function milestones(string $repo) + public function milestones(string $repo): Milestones { return new Milestones($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\Patches - */ - public function patches(string $repo) + public function patches(string $repo): Patches { return new Patches($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\Pipelines - */ - public function pipelines(string $repo) + public function pipelines(string $repo): Pipelines { return new Pipelines($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\PipelinesConfig - */ - public function pipelinesConfig(string $repo) + public function pipelinesConfig(string $repo): PipelinesConfig { return new PipelinesConfig($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\Properties - */ - public function properties(string $repo) + public function properties(string $repo): Properties { return new Properties($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\PullRequests - */ - public function pullRequests(string $repo) + public function pullRequests(string $repo): PullRequests { return new PullRequests($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\Refs - */ - public function refs(string $repo) + public function refs(string $repo): Refs { return new Refs($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\Src - */ - public function src(string $repo) + public function src(string $repo): Src { return new Src($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\Versions - */ - public function versions(string $repo) + public function versions(string $repo): Versions { return new Versions($this->getClient(), $this->workspace, $repo); } - /** - * @param string $repo - * - * @return \Bitbucket\Api\Repositories\Workspaces\Watchers - */ - public function watchers(string $repo) + public function watchers(string $repo): Watchers { return new Watchers($this->getClient(), $this->workspace, $repo); } /** * Build the workspaces URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildWorkspacesUri(string ...$parts) + protected function buildWorkspacesUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, ...$parts); } diff --git a/src/Api/Repositories/Workspaces/AbstractWorkspacesApi.php b/src/Api/Repositories/Workspaces/AbstractWorkspacesApi.php index de4be9f..b8a91ac 100644 --- a/src/Api/Repositories/Workspaces/AbstractWorkspacesApi.php +++ b/src/Api/Repositories/Workspaces/AbstractWorkspacesApi.php @@ -23,22 +23,8 @@ */ abstract class AbstractWorkspacesApi extends AbstractRepositoriesApi { - /** - * The repo. - * - * @var string - */ - protected $repo; + protected readonly string $repo; - /** - * Create a new API instance. - * - * @param Client $client - * @param string $workspace - * @param string $repo - * - * @return void - */ public function __construct(Client $client, string $workspace, string $repo) { parent::__construct($client, $workspace); diff --git a/src/Api/Repositories/Workspaces/BranchRestrictions.php b/src/Api/Repositories/Workspaces/BranchRestrictions.php index ef0cb8f..ed669b1 100644 --- a/src/Api/Repositories/Workspaces/BranchRestrictions.php +++ b/src/Api/Repositories/Workspaces/BranchRestrictions.php @@ -23,13 +23,9 @@ class BranchRestrictions extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildBranchRestrictionsUri(); @@ -37,13 +33,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = $this->buildBranchRestrictionsUri(); @@ -51,14 +43,9 @@ public function create(array $params = []) } /** - * @param string $restriction - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $restriction, array $params = []) + public function show(string $restriction, array $params = []): array { $uri = $this->buildBranchRestrictionsUri($restriction); @@ -66,14 +53,9 @@ public function show(string $restriction, array $params = []) } /** - * @param string $restriction - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $restriction, array $params = []) + public function update(string $restriction, array $params = []): array { $uri = $this->buildBranchRestrictionsUri($restriction); @@ -81,14 +63,9 @@ public function update(string $restriction, array $params = []) } /** - * @param string $restriction - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $restriction, array $params = []) + public function remove(string $restriction, array $params = []): array { $uri = $this->buildBranchRestrictionsUri($restriction); @@ -97,12 +74,8 @@ public function remove(string $restriction, array $params = []) /** * Build the branch restrictions URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildBranchRestrictionsUri(string ...$parts) + protected function buildBranchRestrictionsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'branch-restrictions', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/BranchingModel.php b/src/Api/Repositories/Workspaces/BranchingModel.php index 26bb497..4911e60 100644 --- a/src/Api/Repositories/Workspaces/BranchingModel.php +++ b/src/Api/Repositories/Workspaces/BranchingModel.php @@ -23,13 +23,9 @@ class BranchingModel extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(array $params = []) + public function show(array $params = []): array { $uri = $this->buildBranchingModelUri(); @@ -37,13 +33,9 @@ public function show(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function showSettings(array $params = []) + public function showSettings(array $params = []): array { $uri = $this->buildBranchingModelUri('settings'); @@ -51,13 +43,9 @@ public function showSettings(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function updateSettings(array $params = []) + public function updateSettings(array $params = []): array { $uri = $this->buildBranchingModelUri('settings'); @@ -66,12 +54,8 @@ public function updateSettings(array $params = []) /** * Build the branching model URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildBranchingModelUri(string ...$parts) + protected function buildBranchingModelUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'branching-model', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Commit.php b/src/Api/Repositories/Workspaces/Commit.php index 911163f..8aa28a8 100644 --- a/src/Api/Repositories/Workspaces/Commit.php +++ b/src/Api/Repositories/Workspaces/Commit.php @@ -29,88 +29,49 @@ class Commit extends AbstractWorkspacesApi { /** - * @param string $commit - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $commit, array $params = []) + public function show(string $commit, array $params = []): array { $uri = $this->buildCommitUri($commit); return $this->get($uri, $params); } - /** - * @param string $commit - * - * @return \Bitbucket\Api\Repositories\Workspaces\Commit\Approval - */ - public function approval(string $commit) + public function approval(string $commit): Approval { return new Approval($this->getClient(), $this->workspace, $this->repo, $commit); } - /** - * @param string $commit - * - * @return \Bitbucket\Api\Repositories\Workspaces\Commit\Comments - */ - public function comments(string $commit) + public function comments(string $commit): Comments { return new Comments($this->getClient(), $this->workspace, $this->repo, $commit); } - /** - * @param string $commit - * - * @return \Bitbucket\Api\Repositories\Workspaces\Commit\Properties - */ - public function properties(string $commit) + public function properties(string $commit): CommitProperties { return new CommitProperties($this->getClient(), $this->workspace, $this->repo, $commit); } - /** - * @param string $commit - * - * @return \Bitbucket\Api\Repositories\Workspaces\Commit\PullRequests - */ - public function pullRequests(string $commit) + public function pullRequests(string $commit): CommitPullRequests { return new CommitPullRequests($this->getClient(), $this->workspace, $this->repo, $commit); } - /** - * @param string $commit - * - * @return \Bitbucket\Api\Repositories\Workspaces\Commit\Reports - */ - public function reports(string $commit) + public function reports(string $commit): Reports { return new Reports($this->getClient(), $this->workspace, $this->repo, $commit); } - /** - * @param string $commit - * - * @return \Bitbucket\Api\Repositories\Workspaces\Commit\Statuses - */ - public function statuses(string $commit) + public function statuses(string $commit): Statuses { return new Statuses($this->getClient(), $this->workspace, $this->repo, $commit); } /** * Build the commit URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildCommitUri(string ...$parts) + protected function buildCommitUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'commit', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Commit/AbstractCommitApi.php b/src/Api/Repositories/Workspaces/Commit/AbstractCommitApi.php index 8b54be9..48d258c 100644 --- a/src/Api/Repositories/Workspaces/Commit/AbstractCommitApi.php +++ b/src/Api/Repositories/Workspaces/Commit/AbstractCommitApi.php @@ -23,23 +23,8 @@ */ abstract class AbstractCommitApi extends AbstractWorkspacesApi { - /** - * The commit. - * - * @var string - */ - protected $commit; + protected readonly string $commit; - /** - * Create a new API instance. - * - * @param Client $client - * @param string $workspace - * @param string $repo - * @param string $commit - * - * @return void - */ public function __construct(Client $client, string $workspace, string $repo, string $commit) { parent::__construct($client, $workspace, $repo); diff --git a/src/Api/Repositories/Workspaces/Commit/Approval.php b/src/Api/Repositories/Workspaces/Commit/Approval.php index f7794a3..a174ba1 100644 --- a/src/Api/Repositories/Workspaces/Commit/Approval.php +++ b/src/Api/Repositories/Workspaces/Commit/Approval.php @@ -23,13 +23,9 @@ class Approval extends AbstractCommitApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function approve(array $params = []) + public function approve(array $params = []): array { $uri = $this->buildApprovalUri(); @@ -37,13 +33,9 @@ public function approve(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function redact(array $params = []) + public function redact(array $params = []): array { $uri = $this->buildApprovalUri(); @@ -52,12 +44,8 @@ public function redact(array $params = []) /** * Build the approval URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildApprovalUri(string ...$parts) + protected function buildApprovalUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'commit', $this->commit, 'approve', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Commit/Comments.php b/src/Api/Repositories/Workspaces/Commit/Comments.php index 9eac97c..b1099a8 100644 --- a/src/Api/Repositories/Workspaces/Commit/Comments.php +++ b/src/Api/Repositories/Workspaces/Commit/Comments.php @@ -23,13 +23,9 @@ class Comments extends AbstractCommitApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildCommentsUri(); @@ -37,13 +33,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = $this->buildCommentsUri(); @@ -51,14 +43,9 @@ public function create(array $params = []) } /** - * @param string $comment - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $comment, array $params = []) + public function show(string $comment, array $params = []): array { $uri = $this->buildCommentsUri($comment); @@ -67,12 +54,8 @@ public function show(string $comment, array $params = []) /** * Build the comments URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildCommentsUri(string ...$parts) + protected function buildCommentsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'commit', $this->commit, 'comments', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Commit/Properties.php b/src/Api/Repositories/Workspaces/Commit/Properties.php index 4c84fb7..0e9f895 100644 --- a/src/Api/Repositories/Workspaces/Commit/Properties.php +++ b/src/Api/Repositories/Workspaces/Commit/Properties.php @@ -23,15 +23,9 @@ class Properties extends AbstractCommitApi { /** - * @param string $app - * @param string $property - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $app, string $property, array $params = []) + public function show(string $app, string $property, array $params = []): array { $uri = $this->buildPropertiesUri($app, $property); @@ -39,15 +33,9 @@ public function show(string $app, string $property, array $params = []) } /** - * @param string $app - * @param string $property - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $app, string $property, array $params = []) + public function update(string $app, string $property, array $params = []): array { $uri = $this->buildPropertiesUri($app, $property); @@ -55,15 +43,9 @@ public function update(string $app, string $property, array $params = []) } /** - * @param string $app - * @param string $property - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $app, string $property, array $params = []) + public function remove(string $app, string $property, array $params = []): array { $uri = $this->buildPropertiesUri($app, $property); @@ -72,12 +54,8 @@ public function remove(string $app, string $property, array $params = []) /** * Build the properties URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildPropertiesUri(string ...$parts) + protected function buildPropertiesUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'commit', $this->commit, 'properties', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Commit/PullRequests.php b/src/Api/Repositories/Workspaces/Commit/PullRequests.php index cdb84b7..13cecce 100644 --- a/src/Api/Repositories/Workspaces/Commit/PullRequests.php +++ b/src/Api/Repositories/Workspaces/Commit/PullRequests.php @@ -23,13 +23,9 @@ class PullRequests extends AbstractCommitApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildPullRequestsUri(); @@ -38,12 +34,8 @@ public function list(array $params = []) /** * Build the pull requests URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildPullRequestsUri(string ...$parts) + protected function buildPullRequestsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'commit', $this->commit, 'pullrequests', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Commit/Reports.php b/src/Api/Repositories/Workspaces/Commit/Reports.php index 1a94c55..2416058 100644 --- a/src/Api/Repositories/Workspaces/Commit/Reports.php +++ b/src/Api/Repositories/Workspaces/Commit/Reports.php @@ -24,13 +24,9 @@ class Reports extends AbstractCommitApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildReportsUri(); @@ -38,14 +34,9 @@ public function list(array $params = []) } /** - * @param string $report - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(string $report, array $params = []) + public function create(string $report, array $params = []): array { $uri = $this->buildReportsUri($report); @@ -53,36 +44,24 @@ public function create(string $report, array $params = []) } /** - * @param string $report - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $report, array $params = []) + public function show(string $report, array $params = []): array { $uri = $this->buildReportsUri($report); return $this->get($uri, $params); } - /** - * @return \Bitbucket\Api\Repositories\Workspaces\Commit\Reports\Annotations - */ - public function annotations() + public function annotations(): Annotations { return new Annotations($this->getClient(), $this->workspace, $this->repo, $this->commit); } /** * Build the reports URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildReportsUri(string ...$parts) + protected function buildReportsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'commit', $this->commit, 'reports', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Commit/Reports/Annotations.php b/src/Api/Repositories/Workspaces/Commit/Reports/Annotations.php index c51f065..dbfcc86 100644 --- a/src/Api/Repositories/Workspaces/Commit/Reports/Annotations.php +++ b/src/Api/Repositories/Workspaces/Commit/Reports/Annotations.php @@ -23,13 +23,9 @@ class Annotations extends AbstractReportsApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildAnnotationsUri(); @@ -37,13 +33,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = $this->buildAnnotationsUri(); @@ -51,14 +43,9 @@ public function create(array $params = []) } /** - * @param string $annotation - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $annotation, array $params = []) + public function show(string $annotation, array $params = []): array { $uri = $this->buildAnnotationsUri($annotation); @@ -66,14 +53,9 @@ public function show(string $annotation, array $params = []) } /** - * @param string $annotation - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $annotation, array $params = []) + public function update(string $annotation, array $params = []): array { $uri = $this->buildAnnotationsUri($annotation); @@ -81,14 +63,9 @@ public function update(string $annotation, array $params = []) } /** - * @param string $annotation - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $annotation, array $params = []) + public function remove(string $annotation, array $params = []): array { $uri = $this->buildAnnotationsUri($annotation); @@ -97,12 +74,8 @@ public function remove(string $annotation, array $params = []) /** * Annotations the build URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildAnnotationsUri(string ...$parts) + protected function buildAnnotationsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'commit', $this->commit, 'reports', 'annotations', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Commit/Statuses.php b/src/Api/Repositories/Workspaces/Commit/Statuses.php index f304195..c1f0c95 100644 --- a/src/Api/Repositories/Workspaces/Commit/Statuses.php +++ b/src/Api/Repositories/Workspaces/Commit/Statuses.php @@ -24,35 +24,24 @@ class Statuses extends AbstractCommitApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildStatusesUri(); return $this->get($uri, $params); } - /** - * @return \Bitbucket\Api\Repositories\Workspaces\Commit\Statuses\Build - */ - public function build() + public function build(): Build { return new Build($this->getClient(), $this->workspace, $this->repo, $this->commit); } /** * Build the statuses URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildStatusesUri(string ...$parts) + protected function buildStatusesUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'commit', $this->commit, 'statuses', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Commit/Statuses/Build.php b/src/Api/Repositories/Workspaces/Commit/Statuses/Build.php index 577c9c2..7e4e314 100644 --- a/src/Api/Repositories/Workspaces/Commit/Statuses/Build.php +++ b/src/Api/Repositories/Workspaces/Commit/Statuses/Build.php @@ -23,13 +23,9 @@ class Build extends AbstractStatusesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = $this->buildBuildUri(); @@ -37,14 +33,9 @@ public function create(array $params = []) } /** - * @param string $key - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $key, array $params = []) + public function show(string $key, array $params = []): array { $uri = $this->buildBuildUri(...\explode('/', $key)); @@ -52,14 +43,9 @@ public function show(string $key, array $params = []) } /** - * @param string $key - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $key, array $params = []) + public function update(string $key, array $params = []): array { $uri = $this->buildBuildUri(...\explode('/', $key)); @@ -68,12 +54,8 @@ public function update(string $key, array $params = []) /** * Build the build URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildBuildUri(string ...$parts) + protected function buildBuildUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'commit', $this->commit, 'statuses', 'build', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Commits.php b/src/Api/Repositories/Workspaces/Commits.php index e4f62c9..1954a49 100644 --- a/src/Api/Repositories/Workspaces/Commits.php +++ b/src/Api/Repositories/Workspaces/Commits.php @@ -23,13 +23,9 @@ class Commits extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = UriBuilder::build('repositories', $this->workspace, $this->repo, 'commits'); @@ -37,14 +33,9 @@ public function list(array $params = []) } /** - * @param string $commit - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $commit, array $params = []) + public function show(string $commit, array $params = []): array { $uri = UriBuilder::build('repositories', $this->workspace, $this->repo, 'commit', $commit); diff --git a/src/Api/Repositories/Workspaces/Components.php b/src/Api/Repositories/Workspaces/Components.php index 1520486..abeb050 100644 --- a/src/Api/Repositories/Workspaces/Components.php +++ b/src/Api/Repositories/Workspaces/Components.php @@ -23,13 +23,9 @@ class Components extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildComponentsUri(); @@ -37,14 +33,9 @@ public function list(array $params = []) } /** - * @param string $component - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $component, array $params = []) + public function show(string $component, array $params = []): array { $uri = $this->buildComponentsUri($component); @@ -53,12 +44,8 @@ public function show(string $component, array $params = []) /** * Build the components URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildComponentsUri(string ...$parts) + protected function buildComponentsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'components', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/DefaultReviewers.php b/src/Api/Repositories/Workspaces/DefaultReviewers.php index b97909b..7f4e017 100644 --- a/src/Api/Repositories/Workspaces/DefaultReviewers.php +++ b/src/Api/Repositories/Workspaces/DefaultReviewers.php @@ -23,13 +23,9 @@ class DefaultReviewers extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildDefaultReviewersUri(); @@ -37,14 +33,9 @@ public function list(array $params = []) } /** - * @param string $reviewer - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $reviewer, array $params = []) + public function show(string $reviewer, array $params = []): array { $uri = $this->buildDefaultReviewersUri($reviewer); @@ -52,14 +43,9 @@ public function show(string $reviewer, array $params = []) } /** - * @param string $reviewer - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function add(string $reviewer, array $params = []) + public function add(string $reviewer, array $params = []): array { $uri = $this->buildDefaultReviewersUri($reviewer); @@ -67,14 +53,9 @@ public function add(string $reviewer, array $params = []) } /** - * @param string $reviewer - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $reviewer, array $params = []) + public function remove(string $reviewer, array $params = []): array { $uri = $this->buildDefaultReviewersUri($reviewer); @@ -83,12 +64,8 @@ public function remove(string $reviewer, array $params = []) /** * Build the default reviewers URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildDefaultReviewersUri(string ...$parts) + protected function buildDefaultReviewersUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'default-reviewers', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/DeployKeys.php b/src/Api/Repositories/Workspaces/DeployKeys.php index 8aac334..b60f05c 100644 --- a/src/Api/Repositories/Workspaces/DeployKeys.php +++ b/src/Api/Repositories/Workspaces/DeployKeys.php @@ -23,13 +23,9 @@ class DeployKeys extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildDeployKeysUri(); @@ -37,13 +33,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = $this->buildDeployKeysUri(); @@ -51,14 +43,9 @@ public function create(array $params = []) } /** - * @param string $id - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $id, array $params = []) + public function show(string $id, array $params = []): array { $uri = $this->buildDeployKeysUri($id); @@ -66,14 +53,9 @@ public function show(string $id, array $params = []) } /** - * @param string $id - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $id, array $params = []) + public function update(string $id, array $params = []): array { $uri = $this->buildDeployKeysUri($id); @@ -81,14 +63,9 @@ public function update(string $id, array $params = []) } /** - * @param string $id - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $id, array $params = []) + public function remove(string $id, array $params = []): array { $uri = $this->buildDeployKeysUri($id); @@ -97,12 +74,8 @@ public function remove(string $id, array $params = []) /** * Build the deploy keys URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildDeployKeysUri(string ...$parts) + protected function buildDeployKeysUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'deploy-keys', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Deployments.php b/src/Api/Repositories/Workspaces/Deployments.php index d127a14..6efc38c 100644 --- a/src/Api/Repositories/Workspaces/Deployments.php +++ b/src/Api/Repositories/Workspaces/Deployments.php @@ -24,13 +24,9 @@ class Deployments extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildDeploymentsUri(); @@ -38,38 +34,24 @@ public function list(array $params = []) } /** - * @param string $deployments - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $deployments, array $params = []) + public function show(string $deployments, array $params = []): array { $uri = $this->buildDeploymentsUri($deployments); return $this->get($uri, $params); } - /** - * @param string $environment - * - * @return \Bitbucket\Api\Repositories\Workspaces\Deployments\EnvironmentVariables - */ - public function environmentVariables(string $environment) + public function environmentVariables(string $environment): EnvironmentVariables { return new EnvironmentVariables($this->getClient(), $this->workspace, $this->repo, $environment); } /** * Build the deployments URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildDeploymentsUri(string ...$parts) + protected function buildDeploymentsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'deployments', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Deployments/AbstractDeploymentsApi.php b/src/Api/Repositories/Workspaces/Deployments/AbstractDeploymentsApi.php index e8a530b..879d726 100644 --- a/src/Api/Repositories/Workspaces/Deployments/AbstractDeploymentsApi.php +++ b/src/Api/Repositories/Workspaces/Deployments/AbstractDeploymentsApi.php @@ -23,23 +23,8 @@ */ abstract class AbstractDeploymentsApi extends AbstractWorkspacesApi { - /** - * The environment. - * - * @var string - */ - protected $environment; + protected readonly string $environment; - /** - * Create a new API instance. - * - * @param Client $client - * @param string $workspace - * @param string $repo - * @param string $environment - * - * @return void - */ public function __construct(Client $client, string $workspace, string $repo, string $environment) { parent::__construct($client, $workspace, $repo); diff --git a/src/Api/Repositories/Workspaces/Deployments/EnvironmentVariables.php b/src/Api/Repositories/Workspaces/Deployments/EnvironmentVariables.php index 7332efa..ac9f96a 100644 --- a/src/Api/Repositories/Workspaces/Deployments/EnvironmentVariables.php +++ b/src/Api/Repositories/Workspaces/Deployments/EnvironmentVariables.php @@ -23,13 +23,9 @@ class EnvironmentVariables extends AbstractDeploymentsApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildEnvironmentVariablesUri(); @@ -37,13 +33,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = $this->buildEnvironmentVariablesUri(); @@ -51,14 +43,9 @@ public function create(array $params = []) } /** - * @param string $variable - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $variable, array $params = []) + public function update(string $variable, array $params = []): array { $uri = $this->buildEnvironmentVariablesUri($variable); @@ -66,14 +53,9 @@ public function update(string $variable, array $params = []) } /** - * @param string $variable - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $variable, array $params = []) + public function remove(string $variable, array $params = []): array { $uri = $this->buildEnvironmentVariablesUri($variable); @@ -82,12 +64,8 @@ public function remove(string $variable, array $params = []) /** * Build the variables URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildEnvironmentVariablesUri(string ...$parts) + protected function buildEnvironmentVariablesUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'deployments_config', 'environments', $this->environment, 'variables', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/DiffStat.php b/src/Api/Repositories/Workspaces/DiffStat.php index a0427a0..3811fd7 100644 --- a/src/Api/Repositories/Workspaces/DiffStat.php +++ b/src/Api/Repositories/Workspaces/DiffStat.php @@ -23,14 +23,9 @@ class DiffStat extends AbstractWorkspacesApi { /** - * @param string $spec - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function download(string $spec, array $params = []) + public function download(string $spec, array $params = []): array { $uri = $this->buildDiffStatUri($spec); @@ -39,12 +34,8 @@ public function download(string $spec, array $params = []) /** * Build the diff stat URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildDiffStatUri(string ...$parts) + protected function buildDiffStatUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'diffstat', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Diffs.php b/src/Api/Repositories/Workspaces/Diffs.php index 260911a..5b2bad5 100644 --- a/src/Api/Repositories/Workspaces/Diffs.php +++ b/src/Api/Repositories/Workspaces/Diffs.php @@ -23,14 +23,9 @@ class Diffs extends AbstractWorkspacesApi { /** - * @param string $spec - * @param array $params - * * @throws \Http\Client\Exception - * - * @return \Psr\Http\Message\StreamInterface */ - public function download(string $spec, array $params = []) + public function download(string $spec, array $params = []): \Psr\Http\Message\StreamInterface { $uri = $this->buildDiffsUri($spec); @@ -39,12 +34,8 @@ public function download(string $spec, array $params = []) /** * Build the diff URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildDiffsUri(string ...$parts) + protected function buildDiffsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'diff', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Downloads.php b/src/Api/Repositories/Workspaces/Downloads.php index 9444696..626ebed 100644 --- a/src/Api/Repositories/Workspaces/Downloads.php +++ b/src/Api/Repositories/Workspaces/Downloads.php @@ -26,13 +26,9 @@ class Downloads extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildDownloadsUri(); @@ -40,13 +36,9 @@ public function list(array $params = []) } /** - * @param \Bitbucket\HttpClient\Message\FileResource $file - * * @throws \Http\Client\Exception - * - * @return array */ - public function upload(FileResource $file) + public function upload(FileResource $file): array { $uri = $this->buildDownloadsUri(); $builder = (new MultipartStreamBuilder())->addResource($file->getName(), $file->getResource(), $file->getOptions()); @@ -56,43 +48,29 @@ public function upload(FileResource $file) } /** - * @param string $filename - * @param array $params - * * @throws \Http\Client\Exception - * - * @return \Psr\Http\Message\StreamInterface */ - public function download(string $filename, array $params = []) + public function download(string $filename, array $params = []): \Psr\Http\Message\StreamInterface { - $uri = $this->buildDownloadsUri($filename); + $uri = $this->buildDownloadsUri(...\explode('/', $filename)); return $this->getAsResponse($uri, $params, ['Accept' => '*/*'])->getBody(); } /** - * @param string $filename - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $filename, array $params = []) + public function remove(string $filename, array $params = []): array { - $uri = $this->buildDownloadsUri($filename); + $uri = $this->buildDownloadsUri(...\explode('/', $filename)); return $this->delete($uri, $params); } /** * Build the downloads URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildDownloadsUri(string ...$parts) + protected function buildDownloadsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'downloads', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Environments.php b/src/Api/Repositories/Workspaces/Environments.php index ebf84c0..ef6fade 100644 --- a/src/Api/Repositories/Workspaces/Environments.php +++ b/src/Api/Repositories/Workspaces/Environments.php @@ -23,13 +23,9 @@ class Environments extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildEnvironmentsUri()); @@ -37,14 +33,9 @@ public function list(array $params = []) } /** - * @param string $env - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $env, array $params = []) + public function show(string $env, array $params = []): array { $uri = $this->buildEnvironmentsUri($env); @@ -52,13 +43,9 @@ public function show(string $env, array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildEnvironmentsUri()); @@ -66,14 +53,9 @@ public function create(array $params = []) } /** - * @param string $env - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $env, array $params = []) + public function update(string $env, array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildEnvironmentsUri($env, 'changes')); @@ -81,13 +63,9 @@ public function update(string $env, array $params = []) } /** - * @param string $env - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $env) + public function remove(string $env): array { $uri = $this->buildEnvironmentsUri($env); @@ -96,12 +74,8 @@ public function remove(string $env) /** * Build the environments URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildEnvironmentsUri(string ...$parts) + protected function buildEnvironmentsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'environments', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/FileHistory.php b/src/Api/Repositories/Workspaces/FileHistory.php index 01d0cea..9e300dd 100644 --- a/src/Api/Repositories/Workspaces/FileHistory.php +++ b/src/Api/Repositories/Workspaces/FileHistory.php @@ -23,15 +23,9 @@ class FileHistory extends AbstractWorkspacesApi { /** - * @param string $commit - * @param string $uri - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(string $commit, string $uri, array $params = []) + public function list(string $commit, string $uri, array $params = []): array { $uri = $this->buildFileHistoryUri($commit, ...\explode('/', $uri)); @@ -40,12 +34,8 @@ public function list(string $commit, string $uri, array $params = []) /** * Build the file history URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildFileHistoryUri(string ...$parts) + protected function buildFileHistoryUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'filehistory', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Forks.php b/src/Api/Repositories/Workspaces/Forks.php index 6d5ebc2..4af6b09 100644 --- a/src/Api/Repositories/Workspaces/Forks.php +++ b/src/Api/Repositories/Workspaces/Forks.php @@ -23,13 +23,9 @@ class Forks extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildForksUri(); @@ -37,13 +33,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = $this->buildForksUri(); @@ -52,12 +44,8 @@ public function create(array $params = []) /** * Build the forks URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildForksUri(string ...$parts) + protected function buildForksUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'forks', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Hooks.php b/src/Api/Repositories/Workspaces/Hooks.php index 2cbdcef..7edb8a8 100644 --- a/src/Api/Repositories/Workspaces/Hooks.php +++ b/src/Api/Repositories/Workspaces/Hooks.php @@ -23,13 +23,9 @@ class Hooks extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildHooksUri(); @@ -37,13 +33,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = $this->buildHooksUri(); @@ -51,14 +43,9 @@ public function create(array $params = []) } /** - * @param string $hook - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $hook, array $params = []) + public function show(string $hook, array $params = []): array { $uri = $this->buildHooksUri($hook); @@ -66,14 +53,9 @@ public function show(string $hook, array $params = []) } /** - * @param string $hook - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $hook, array $params = []) + public function update(string $hook, array $params = []): array { $uri = $this->buildHooksUri($hook); @@ -81,14 +63,9 @@ public function update(string $hook, array $params = []) } /** - * @param string $hook - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $hook, array $params = []) + public function remove(string $hook, array $params = []): array { $uri = $this->buildHooksUri($hook); @@ -97,12 +74,8 @@ public function remove(string $hook, array $params = []) /** * Build the hooks URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildHooksUri(string ...$parts) + protected function buildHooksUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'hooks', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Issues.php b/src/Api/Repositories/Workspaces/Issues.php index 2bf3fb7..fbca4bc 100644 --- a/src/Api/Repositories/Workspaces/Issues.php +++ b/src/Api/Repositories/Workspaces/Issues.php @@ -28,13 +28,9 @@ class Issues extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildIssuesUri(); @@ -42,13 +38,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = $this->buildIssuesUri(); @@ -56,14 +48,9 @@ public function create(array $params = []) } /** - * @param string $issue - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $issue, array $params = []) + public function show(string $issue, array $params = []): array { $uri = $this->buildIssuesUri($issue); @@ -71,14 +58,9 @@ public function show(string $issue, array $params = []) } /** - * @param string $issue - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $issue, array $params = []) + public function update(string $issue, array $params = []): array { $uri = $this->buildIssuesUri($issue); @@ -86,78 +68,44 @@ public function update(string $issue, array $params = []) } /** - * @param string $issue - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $issue, array $params = []) + public function remove(string $issue, array $params = []): array { $uri = $this->buildIssuesUri($issue); return $this->delete($uri, $params); } - /** - * @param string $issue - * - * @return \Bitbucket\Api\Repositories\Workspaces\Issues\Attachments - */ - public function attachments(string $issue) + public function attachments(string $issue): Attachments { return new Attachments($this->getClient(), $this->workspace, $this->repo, $issue); } - /** - * @param string $issue - * - * @return \Bitbucket\Api\Repositories\Workspaces\Issues\Changes - */ - public function changes(string $issue) + public function changes(string $issue): Changes { return new Changes($this->getClient(), $this->workspace, $this->repo, $issue); } - /** - * @param string $issue - * - * @return \Bitbucket\Api\Repositories\Workspaces\Issues\Comments - */ - public function comments(string $issue) + public function comments(string $issue): Comments { return new Comments($this->getClient(), $this->workspace, $this->repo, $issue); } - /** - * @param string $issue - * - * @return \Bitbucket\Api\Repositories\Workspaces\Issues\Voting - */ - public function voting(string $issue) + public function voting(string $issue): Voting { return new Voting($this->getClient(), $this->workspace, $this->repo, $issue); } - /** - * @param string $issue - * - * @return \Bitbucket\Api\Repositories\Workspaces\Issues\Watching - */ - public function watching(string $issue) + public function watching(string $issue): Watching { return new Watching($this->getClient(), $this->workspace, $this->repo, $issue); } /** * Build the issues URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildIssuesUri(string ...$parts) + protected function buildIssuesUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'issues', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Issues/AbstractIssuesApi.php b/src/Api/Repositories/Workspaces/Issues/AbstractIssuesApi.php index 4051d7a..dd4f32c 100644 --- a/src/Api/Repositories/Workspaces/Issues/AbstractIssuesApi.php +++ b/src/Api/Repositories/Workspaces/Issues/AbstractIssuesApi.php @@ -23,23 +23,8 @@ */ abstract class AbstractIssuesApi extends AbstractWorkspacesApi { - /** - * The issue. - * - * @var string - */ - protected $issue; + protected readonly string $issue; - /** - * Create a new API instance. - * - * @param Client $client - * @param string $workspace - * @param string $repo - * @param string $issue - * - * @return void - */ public function __construct(Client $client, string $workspace, string $repo, string $issue) { parent::__construct($client, $workspace, $repo); diff --git a/src/Api/Repositories/Workspaces/Issues/Attachments.php b/src/Api/Repositories/Workspaces/Issues/Attachments.php index 0cc9f64..66e0f1b 100644 --- a/src/Api/Repositories/Workspaces/Issues/Attachments.php +++ b/src/Api/Repositories/Workspaces/Issues/Attachments.php @@ -26,13 +26,9 @@ class Attachments extends AbstractIssuesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildAttachmentsUri(); @@ -40,13 +36,9 @@ public function list(array $params = []) } /** - * @param \Bitbucket\HttpClient\Message\FileResource $file - * * @throws \Http\Client\Exception - * - * @return array */ - public function upload(FileResource $file) + public function upload(FileResource $file): array { $uri = $this->buildAttachmentsUri(); $builder = (new MultipartStreamBuilder())->addResource($file->getName(), $file->getResource(), $file->getOptions()); @@ -56,14 +48,9 @@ public function upload(FileResource $file) } /** - * @param string $filename - * @param array $params - * * @throws \Http\Client\Exception - * - * @return \Psr\Http\Message\StreamInterface */ - public function download(string $filename, array $params = []) + public function download(string $filename, array $params = []): \Psr\Http\Message\StreamInterface { $uri = $this->buildAttachmentsUri($filename); @@ -71,14 +58,9 @@ public function download(string $filename, array $params = []) } /** - * @param string $filename - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $filename, array $params = []) + public function remove(string $filename, array $params = []): array { $uri = $this->buildAttachmentsUri($filename); @@ -87,12 +69,8 @@ public function remove(string $filename, array $params = []) /** * Build the attachments URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildAttachmentsUri(string ...$parts) + protected function buildAttachmentsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'issues', $this->issue, 'attachments', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Issues/Changes.php b/src/Api/Repositories/Workspaces/Issues/Changes.php index 02b0b11..d32615e 100644 --- a/src/Api/Repositories/Workspaces/Issues/Changes.php +++ b/src/Api/Repositories/Workspaces/Issues/Changes.php @@ -23,13 +23,9 @@ class Changes extends AbstractIssuesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildChangesUri(); @@ -37,13 +33,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = $this->buildChangesUri(); @@ -51,14 +43,9 @@ public function create(array $params = []) } /** - * @param string $change - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $change, array $params = []) + public function show(string $change, array $params = []): array { $uri = $this->buildChangesUri($change); @@ -67,12 +54,8 @@ public function show(string $change, array $params = []) /** * Build the changes URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildChangesUri(string ...$parts) + protected function buildChangesUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'issues', $this->issue, 'changes', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Issues/Comments.php b/src/Api/Repositories/Workspaces/Issues/Comments.php index 2a74b41..29b1b32 100644 --- a/src/Api/Repositories/Workspaces/Issues/Comments.php +++ b/src/Api/Repositories/Workspaces/Issues/Comments.php @@ -23,13 +23,9 @@ class Comments extends AbstractIssuesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildCommentsUri(); @@ -37,14 +33,9 @@ public function list(array $params = []) } /** - * @param string $comment - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $comment, array $params = []) + public function show(string $comment, array $params = []): array { $uri = $this->buildCommentsUri($comment); @@ -52,13 +43,9 @@ public function show(string $comment, array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = $this->buildCommentsUri(); @@ -66,14 +53,9 @@ public function create(array $params = []) } /** - * @param string $comment - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $comment, array $params = []) + public function update(string $comment, array $params = []): array { $uri = $this->buildCommentsUri($comment); @@ -81,13 +63,9 @@ public function update(string $comment, array $params = []) } /** - * @param string $comment - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $comment) + public function remove(string $comment): array { $uri = $this->buildCommentsUri($comment); @@ -96,12 +74,8 @@ public function remove(string $comment) /** * Build the comments URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildCommentsUri(string ...$parts) + protected function buildCommentsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'issues', $this->issue, 'comments', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Issues/Voting.php b/src/Api/Repositories/Workspaces/Issues/Voting.php index 2b05c9d..8be650a 100644 --- a/src/Api/Repositories/Workspaces/Issues/Voting.php +++ b/src/Api/Repositories/Workspaces/Issues/Voting.php @@ -23,13 +23,9 @@ class Voting extends AbstractIssuesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function check(array $params = []) + public function check(array $params = []): array { $uri = $this->buildVotingUri(); @@ -37,13 +33,9 @@ public function check(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function vote(array $params = []) + public function vote(array $params = []): array { $uri = $this->buildVotingUri(); @@ -51,13 +43,9 @@ public function vote(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function retract(array $params = []) + public function retract(array $params = []): array { $uri = $this->buildVotingUri(); @@ -66,12 +54,8 @@ public function retract(array $params = []) /** * Build the voting URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildVotingUri(string ...$parts) + protected function buildVotingUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'issues', $this->issue, 'vote', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Issues/Watching.php b/src/Api/Repositories/Workspaces/Issues/Watching.php index 141b03b..7e5119c 100644 --- a/src/Api/Repositories/Workspaces/Issues/Watching.php +++ b/src/Api/Repositories/Workspaces/Issues/Watching.php @@ -23,13 +23,9 @@ class Watching extends AbstractIssuesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function check(array $params = []) + public function check(array $params = []): array { $uri = $this->buildWatchingUri(); @@ -37,13 +33,9 @@ public function check(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function watch(array $params = []) + public function watch(array $params = []): array { $uri = $this->buildWatchingUri(); @@ -51,13 +43,9 @@ public function watch(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function ignore(array $params = []) + public function ignore(array $params = []): array { $uri = $this->buildWatchingUri(); @@ -66,12 +54,8 @@ public function ignore(array $params = []) /** * Build the watching URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildWatchingUri(string ...$parts) + protected function buildWatchingUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'issues', $this->issue, 'watch', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/MergeBases.php b/src/Api/Repositories/Workspaces/MergeBases.php index 9abbbda..7891c16 100644 --- a/src/Api/Repositories/Workspaces/MergeBases.php +++ b/src/Api/Repositories/Workspaces/MergeBases.php @@ -23,14 +23,9 @@ class MergeBases extends AbstractWorkspacesApi { /** - * @param string $spec - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $spec, array $params = []) + public function show(string $spec, array $params = []): array { $uri = $this->buildMergeBasesUri($spec); @@ -39,12 +34,8 @@ public function show(string $spec, array $params = []) /** * Build the merge base URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildMergeBasesUri(string ...$parts) + protected function buildMergeBasesUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'merge-base', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Milestones.php b/src/Api/Repositories/Workspaces/Milestones.php index ca883ab..b3816e4 100644 --- a/src/Api/Repositories/Workspaces/Milestones.php +++ b/src/Api/Repositories/Workspaces/Milestones.php @@ -23,13 +23,9 @@ class Milestones extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildMilestonesUri(); @@ -37,14 +33,9 @@ public function list(array $params = []) } /** - * @param string $milestone - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $milestone, array $params = []) + public function show(string $milestone, array $params = []): array { $uri = $this->buildMilestonesUri($milestone); @@ -53,12 +44,8 @@ public function show(string $milestone, array $params = []) /** * Build the milestones URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildMilestonesUri(string ...$parts) + protected function buildMilestonesUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'milestones', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Patches.php b/src/Api/Repositories/Workspaces/Patches.php index 92311dc..5f62874 100644 --- a/src/Api/Repositories/Workspaces/Patches.php +++ b/src/Api/Repositories/Workspaces/Patches.php @@ -23,14 +23,9 @@ class Patches extends AbstractWorkspacesApi { /** - * @param string $spec - * @param array $params - * * @throws \Http\Client\Exception - * - * @return \Psr\Http\Message\StreamInterface */ - public function download(string $spec, array $params = []) + public function download(string $spec, array $params = []): \Psr\Http\Message\StreamInterface { $uri = $this->buildPatchesUri($spec); @@ -39,12 +34,8 @@ public function download(string $spec, array $params = []) /** * Build the patches URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildPatchesUri(string ...$parts) + protected function buildPatchesUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'patch', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Pipelines.php b/src/Api/Repositories/Workspaces/Pipelines.php index 2000fdc..0536200 100644 --- a/src/Api/Repositories/Workspaces/Pipelines.php +++ b/src/Api/Repositories/Workspaces/Pipelines.php @@ -25,13 +25,9 @@ class Pipelines extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildPipelinesUri()); @@ -39,13 +35,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildPipelinesUri()); @@ -53,14 +45,9 @@ public function create(array $params = []) } /** - * @param string $pipeline - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $pipeline, array $params = []) + public function show(string $pipeline, array $params = []): array { $uri = $this->buildPipelinesUri($pipeline); @@ -68,48 +55,29 @@ public function show(string $pipeline, array $params = []) } /** - * @param string $pipeline - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function stop(string $pipeline, array $params = []) + public function stop(string $pipeline, array $params = []): array { $uri = $this->buildPipelinesUri($pipeline, 'stopPipeline'); return $this->post($uri, $params); } - /** - * @param string $pipeline - * - * @return \Bitbucket\Api\Repositories\Workspaces\Pipelines\RemoteTriggers - */ - public function remoteTriggers(string $pipeline) + public function remoteTriggers(string $pipeline): RemoteTriggers { return new RemoteTriggers($this->getClient(), $this->workspace, $this->repo, $pipeline); } - /** - * @param string $pipeline - * - * @return \Bitbucket\Api\Repositories\Workspaces\Pipelines\Steps - */ - public function steps(string $pipeline) + public function steps(string $pipeline): Steps { return new Steps($this->getClient(), $this->workspace, $this->repo, $pipeline); } /** * Build the pipelines URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildPipelinesUri(string ...$parts) + protected function buildPipelinesUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'pipelines', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Pipelines/AbstractPipelinesApi.php b/src/Api/Repositories/Workspaces/Pipelines/AbstractPipelinesApi.php index f646809..f2b65ac 100644 --- a/src/Api/Repositories/Workspaces/Pipelines/AbstractPipelinesApi.php +++ b/src/Api/Repositories/Workspaces/Pipelines/AbstractPipelinesApi.php @@ -23,23 +23,8 @@ */ abstract class AbstractPipelinesApi extends AbstractWorkspacesApi { - /** - * The pipeline. - * - * @var string - */ - protected $pipeline; + protected readonly string $pipeline; - /** - * Create a new API instance. - * - * @param Client $client - * @param string $workspace - * @param string $repo - * @param string $pipeline - * - * @return void - */ public function __construct(Client $client, string $workspace, string $repo, string $pipeline) { parent::__construct($client, $workspace, $repo); diff --git a/src/Api/Repositories/Workspaces/Pipelines/RemoteTriggers.php b/src/Api/Repositories/Workspaces/Pipelines/RemoteTriggers.php index 1a69292..b09e5aa 100644 --- a/src/Api/Repositories/Workspaces/Pipelines/RemoteTriggers.php +++ b/src/Api/Repositories/Workspaces/Pipelines/RemoteTriggers.php @@ -23,14 +23,9 @@ class RemoteTriggers extends AbstractPipelinesApi { /** - * @param string $key - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $key, array $params = []) + public function update(string $key, array $params = []): array { $uri = $this->buildRemoteTriggersUri($key); @@ -39,12 +34,8 @@ public function update(string $key, array $params = []) /** * Build the remote triggers URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildRemoteTriggersUri(string ...$parts) + protected function buildRemoteTriggersUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'pipelines', $this->pipeline, 'remote-triggers', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Pipelines/Steps.php b/src/Api/Repositories/Workspaces/Pipelines/Steps.php index 1daf670..321f21a 100644 --- a/src/Api/Repositories/Workspaces/Pipelines/Steps.php +++ b/src/Api/Repositories/Workspaces/Pipelines/Steps.php @@ -23,13 +23,9 @@ class Steps extends AbstractPipelinesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildStepsUri()); @@ -37,14 +33,9 @@ public function list(array $params = []) } /** - * @param string $step - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $step, array $params = []) + public function show(string $step, array $params = []): array { $uri = $this->buildStepsUri($step); @@ -52,14 +43,9 @@ public function show(string $step, array $params = []) } /** - * @param string $step - * @param array $params - * * @throws \Http\Client\Exception - * - * @return \Psr\Http\Message\StreamInterface */ - public function log(string $step, array $params = []) + public function log(string $step, array $params = []): \Psr\Http\Message\StreamInterface { $uri = $this->buildStepsUri($step, 'log'); @@ -67,15 +53,9 @@ public function log(string $step, array $params = []) } /** - * @param string $step - * @param string $uuid - * @param array $params - * * @throws \Http\Client\Exception - * - * @return \Psr\Http\Message\StreamInterface */ - public function specificLog(string $step, string $uuid, array $params = []) + public function specificLog(string $step, string $uuid, array $params = []): \Psr\Http\Message\StreamInterface { $uri = $this->buildStepsUri($step, 'logs', $uuid); @@ -83,14 +63,9 @@ public function specificLog(string $step, string $uuid, array $params = []) } /** - * @param string $step - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function stop(string $step, array $params = []) + public function stop(string $step, array $params = []): array { $uri = $this->buildStepsUri($step, 'stopPipeline'); @@ -99,12 +74,8 @@ public function stop(string $step, array $params = []) /** * Build the steps URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildStepsUri(string ...$parts) + protected function buildStepsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'pipelines', $this->pipeline, 'steps', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/PipelinesConfig.php b/src/Api/Repositories/Workspaces/PipelinesConfig.php index 073b3b6..a5a9aa0 100644 --- a/src/Api/Repositories/Workspaces/PipelinesConfig.php +++ b/src/Api/Repositories/Workspaces/PipelinesConfig.php @@ -23,22 +23,15 @@ */ class PipelinesConfig extends AbstractWorkspacesApi { - /** - * @return \Bitbucket\Api\Repositories\Workspaces\PipelinesConfig\Variables - */ - public function variables() + public function variables(): Variables { return new Variables($this->getClient(), $this->workspace, $this->repo); } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(array $params = []) + public function show(array $params = []): array { $uri = $this->buildPipelinesConfigUri(); @@ -46,13 +39,9 @@ public function show(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(array $params = []) + public function update(array $params = []): array { $uri = $this->buildPipelinesConfigUri(); @@ -61,12 +50,8 @@ public function update(array $params = []) /** * Build the pipelines config URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildPipelinesConfigUri(string ...$parts) + protected function buildPipelinesConfigUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'pipelines_config', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/PipelinesConfig/BuildNumber.php b/src/Api/Repositories/Workspaces/PipelinesConfig/BuildNumber.php index 44637fa..e1276e4 100644 --- a/src/Api/Repositories/Workspaces/PipelinesConfig/BuildNumber.php +++ b/src/Api/Repositories/Workspaces/PipelinesConfig/BuildNumber.php @@ -23,13 +23,9 @@ class BuildNumber extends AbstractPipelinesConfigApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(array $params = []) + public function update(array $params = []): array { $uri = $this->buildBuildNumberUri(); @@ -38,12 +34,8 @@ public function update(array $params = []) /** * Build the build number URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildBuildNumberUri(string ...$parts) + protected function buildBuildNumberUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'pipelines_config', 'build_number', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/PipelinesConfig/Schedules.php b/src/Api/Repositories/Workspaces/PipelinesConfig/Schedules.php index e36d73c..59052fb 100644 --- a/src/Api/Repositories/Workspaces/PipelinesConfig/Schedules.php +++ b/src/Api/Repositories/Workspaces/PipelinesConfig/Schedules.php @@ -24,13 +24,9 @@ class Schedules extends AbstractPipelinesConfigApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildSchedulesUri()); @@ -38,13 +34,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildSchedulesUri()); @@ -52,14 +44,9 @@ public function create(array $params = []) } /** - * @param string $schedule - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $schedule, array $params = []) + public function show(string $schedule, array $params = []): array { $uri = $this->buildSchedulesUri($schedule); @@ -67,14 +54,9 @@ public function show(string $schedule, array $params = []) } /** - * @param string $schedule - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $schedule, array $params = []) + public function update(string $schedule, array $params = []): array { $uri = $this->buildSchedulesUri($schedule); @@ -82,38 +64,24 @@ public function update(string $schedule, array $params = []) } /** - * @param string $schedule - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $schedule, array $params = []) + public function remove(string $schedule, array $params = []): array { $uri = $this->buildSchedulesUri($schedule); return $this->delete($uri, $params); } - /** - * @param string $schedule - * - * @return \Bitbucket\Api\Repositories\Workspaces\PipelinesConfig\Schedules\Executions - */ - public function executions(string $schedule) + public function executions(string $schedule): Executions { return new Executions($this->getClient(), $this->workspace, $this->repo, $schedule); } /** * Build the schedules URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildSchedulesUri(string ...$parts) + protected function buildSchedulesUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'pipelines_config', 'schedules', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/PipelinesConfig/Schedules/AbstractSchedulesApi.php b/src/Api/Repositories/Workspaces/PipelinesConfig/Schedules/AbstractSchedulesApi.php index 92585cd..9638002 100644 --- a/src/Api/Repositories/Workspaces/PipelinesConfig/Schedules/AbstractSchedulesApi.php +++ b/src/Api/Repositories/Workspaces/PipelinesConfig/Schedules/AbstractSchedulesApi.php @@ -23,23 +23,8 @@ */ abstract class AbstractSchedulesApi extends AbstractPipelinesConfigApi { - /** - * The schedule. - * - * @var string - */ - protected $schedule; + protected readonly string $schedule; - /** - * Create a new API instance. - * - * @param Client $client - * @param string $workspace - * @param string $repo - * @param string $schedule - * - * @return void - */ public function __construct(Client $client, string $workspace, string $repo, string $schedule) { parent::__construct($client, $workspace, $repo); diff --git a/src/Api/Repositories/Workspaces/PipelinesConfig/Schedules/Executions.php b/src/Api/Repositories/Workspaces/PipelinesConfig/Schedules/Executions.php index b886722..8225373 100644 --- a/src/Api/Repositories/Workspaces/PipelinesConfig/Schedules/Executions.php +++ b/src/Api/Repositories/Workspaces/PipelinesConfig/Schedules/Executions.php @@ -23,13 +23,9 @@ class Executions extends AbstractSchedulesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildExecutionsUri()); @@ -38,12 +34,8 @@ public function list(array $params = []) /** * Build the executions URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildExecutionsUri(string ...$parts) + protected function buildExecutionsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'pipelines_config', 'schedules', $this->schedule, 'executions', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/PipelinesConfig/Ssh.php b/src/Api/Repositories/Workspaces/PipelinesConfig/Ssh.php index d433199..b36c98b 100644 --- a/src/Api/Repositories/Workspaces/PipelinesConfig/Ssh.php +++ b/src/Api/Repositories/Workspaces/PipelinesConfig/Ssh.php @@ -24,30 +24,20 @@ */ class Ssh extends AbstractPipelinesConfigApi { - /** - * @return \Bitbucket\Api\Repositories\Workspaces\PipelinesConfig\Ssh\KeyPair - */ - public function keyPair() + public function keyPair(): KeyPair { return new KeyPair($this->getClient(), $this->workspace, $this->repo); } - /** - * @return \Bitbucket\Api\Repositories\Workspaces\PipelinesConfig\Ssh\KnownHosts - */ - public function knownHosts() + public function knownHosts(): KnownHosts { return new KnownHosts($this->getClient(), $this->workspace, $this->repo); } /** * Build the ssh URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildSshUri(string ...$parts) + protected function buildSshUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'pipelines_config', 'ssh', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/PipelinesConfig/Ssh/KeyPair.php b/src/Api/Repositories/Workspaces/PipelinesConfig/Ssh/KeyPair.php index 0edc9e6..92df5e8 100644 --- a/src/Api/Repositories/Workspaces/PipelinesConfig/Ssh/KeyPair.php +++ b/src/Api/Repositories/Workspaces/PipelinesConfig/Ssh/KeyPair.php @@ -23,13 +23,9 @@ class KeyPair extends AbstractSshApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(array $params = []) + public function show(array $params = []): array { $uri = $this->buildKeyPairUri(); @@ -37,13 +33,9 @@ public function show(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(array $params = []) + public function update(array $params = []): array { $uri = $this->buildKeyPairUri(); @@ -51,13 +43,9 @@ public function update(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(array $params = []) + public function remove(array $params = []): array { $uri = $this->buildKeyPairUri(); @@ -66,12 +54,8 @@ public function remove(array $params = []) /** * Build the key pair URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildKeyPairUri(string ...$parts) + protected function buildKeyPairUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'pipelines_config', 'ssh', 'key_pair', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/PipelinesConfig/Ssh/KnownHosts.php b/src/Api/Repositories/Workspaces/PipelinesConfig/Ssh/KnownHosts.php index be7a3af..a4d645b 100644 --- a/src/Api/Repositories/Workspaces/PipelinesConfig/Ssh/KnownHosts.php +++ b/src/Api/Repositories/Workspaces/PipelinesConfig/Ssh/KnownHosts.php @@ -23,13 +23,9 @@ class KnownHosts extends AbstractSshApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildKnownHostsUri()); @@ -37,13 +33,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildKnownHostsUri()); @@ -51,14 +43,9 @@ public function create(array $params = []) } /** - * @param string $host - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $host, array $params = []) + public function show(string $host, array $params = []): array { $uri = $this->buildKnownHostsUri($host); @@ -66,14 +53,9 @@ public function show(string $host, array $params = []) } /** - * @param string $host - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $host, array $params = []) + public function update(string $host, array $params = []): array { $uri = $this->buildKnownHostsUri($host); @@ -81,14 +63,9 @@ public function update(string $host, array $params = []) } /** - * @param string $host - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $host, array $params = []) + public function remove(string $host, array $params = []): array { $uri = $this->buildKnownHostsUri($host); @@ -97,12 +74,8 @@ public function remove(string $host, array $params = []) /** * Build the known hosts URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildKnownHostsUri(string ...$parts) + protected function buildKnownHostsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'pipelines_config', 'ssh', 'known_hosts', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/PipelinesConfig/Variables.php b/src/Api/Repositories/Workspaces/PipelinesConfig/Variables.php index f50874b..7d1c4ce 100644 --- a/src/Api/Repositories/Workspaces/PipelinesConfig/Variables.php +++ b/src/Api/Repositories/Workspaces/PipelinesConfig/Variables.php @@ -23,13 +23,9 @@ class Variables extends AbstractPipelinesConfigApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildVariablesUri()); @@ -37,13 +33,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildVariablesUri()); @@ -51,14 +43,9 @@ public function create(array $params = []) } /** - * @param string $variable - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $variable, array $params = []) + public function show(string $variable, array $params = []): array { $uri = $this->buildVariablesUri($variable); @@ -66,14 +53,9 @@ public function show(string $variable, array $params = []) } /** - * @param string $variable - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $variable, array $params = []) + public function update(string $variable, array $params = []): array { $uri = $this->buildVariablesUri($variable); @@ -81,14 +63,9 @@ public function update(string $variable, array $params = []) } /** - * @param string $variable - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $variable, array $params = []) + public function remove(string $variable, array $params = []): array { $uri = $this->buildVariablesUri($variable); @@ -97,12 +74,8 @@ public function remove(string $variable, array $params = []) /** * Build the variables URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildVariablesUri(string ...$parts) + protected function buildVariablesUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'pipelines_config', 'variables', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Properties.php b/src/Api/Repositories/Workspaces/Properties.php index a616f8d..7abe189 100644 --- a/src/Api/Repositories/Workspaces/Properties.php +++ b/src/Api/Repositories/Workspaces/Properties.php @@ -23,15 +23,9 @@ class Properties extends AbstractWorkspacesApi { /** - * @param string $app - * @param string $property - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $app, string $property, array $params = []) + public function show(string $app, string $property, array $params = []): array { $uri = $this->buildPropertiesUri($app, $property); @@ -39,15 +33,9 @@ public function show(string $app, string $property, array $params = []) } /** - * @param string $app - * @param string $property - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $app, string $property, array $params = []) + public function update(string $app, string $property, array $params = []): array { $uri = $this->buildPropertiesUri($app, $property); @@ -55,15 +43,9 @@ public function update(string $app, string $property, array $params = []) } /** - * @param string $app - * @param string $property - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $app, string $property, array $params = []) + public function remove(string $app, string $property, array $params = []): array { $uri = $this->buildPropertiesUri($app, $property); @@ -72,12 +54,8 @@ public function remove(string $app, string $property, array $params = []) /** * Build the properties URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildPropertiesUri(string ...$parts) + protected function buildPropertiesUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'properties', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/PullRequests.php b/src/Api/Repositories/Workspaces/PullRequests.php index b9c68fd..e848e95 100644 --- a/src/Api/Repositories/Workspaces/PullRequests.php +++ b/src/Api/Repositories/Workspaces/PullRequests.php @@ -31,13 +31,9 @@ class PullRequests extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildPullRequestsUri(); @@ -45,13 +41,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function activity(array $params = []) + public function activity(array $params = []): array { $uri = $this->buildPullRequestsUri('activity'); @@ -59,13 +51,9 @@ public function activity(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = $this->buildPullRequestsUri(); @@ -73,14 +61,9 @@ public function create(array $params = []) } /** - * @param string $pr - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $pr, array $params = []) + public function show(string $pr, array $params = []): array { $uri = $this->buildPullRequestsUri($pr); @@ -88,14 +71,9 @@ public function show(string $pr, array $params = []) } /** - * @param string $pr - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function activityByPr(string $pr, array $params = []) + public function activityByPr(string $pr, array $params = []): array { $uri = $this->buildPullRequestsUri($pr, 'activity'); @@ -103,14 +81,9 @@ public function activityByPr(string $pr, array $params = []) } /** - * @param string $pr - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $pr, array $params = []) + public function update(string $pr, array $params = []): array { $uri = $this->buildPullRequestsUri($pr); @@ -118,14 +91,9 @@ public function update(string $pr, array $params = []) } /** - * @param string $pr - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function decline(string $pr, array $params = []) + public function decline(string $pr, array $params = []): array { $uri = $this->buildPullRequestsUri($pr, 'decline'); @@ -133,14 +101,9 @@ public function decline(string $pr, array $params = []) } /** - * @param string $pr - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function merge(string $pr, array $params = []) + public function merge(string $pr, array $params = []): array { $uri = $this->buildPullRequestsUri($pr, 'merge'); @@ -148,109 +111,59 @@ public function merge(string $pr, array $params = []) } /** - * @param string $pr - * @param string $task - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function mergeTaskStatus(string $pr, string $task, array $params = []) + public function mergeTaskStatus(string $pr, string $task, array $params = []): array { $uri = $this->buildPullRequestsUri($pr, 'merge', 'task-status', $task); return $this->get($uri, $params); } - /** - * @param string $pr - * - * @return \Bitbucket\Api\Repositories\Workspaces\PullRequests\Approval - */ - public function approval(string $pr) + public function approval(string $pr): Approval { return new Approval($this->getClient(), $this->workspace, $this->repo, $pr); } - /** - * @param string $pr - * - * @return \Bitbucket\Api\Repositories\Workspaces\PullRequests\Comments - */ - public function comments(string $pr) + public function comments(string $pr): Comments { return new Comments($this->getClient(), $this->workspace, $this->repo, $pr); } - /** - * @param string $pr - * - * @return \Bitbucket\Api\Repositories\Workspaces\PullRequests\Commits - */ - public function commits(string $pr) + public function commits(string $pr): PullRequestsCommits { return new PullRequestsCommits($this->getClient(), $this->workspace, $this->repo, $pr); } - /** - * @param string $pr - * - * @return \Bitbucket\Api\Repositories\Workspaces\PullRequests\Diff - */ - public function diff(string $pr) + public function diff(string $pr): Diff { return new Diff($this->getClient(), $this->workspace, $this->repo, $pr); } - /** - * @param string $pr - * - * @return \Bitbucket\Api\Repositories\Workspaces\PullRequests\DiffStat - */ - public function diffstat(string $pr) + public function diffstat(string $pr): DiffStat { return new DiffStat($this->getClient(), $this->workspace, $this->repo, $pr); } - /** - * @param string $pr - * - * @return \Bitbucket\Api\Repositories\Workspaces\PullRequests\Patch - */ - public function patch(string $pr) + public function patch(string $pr): Patch { return new Patch($this->getClient(), $this->workspace, $this->repo, $pr); } - /** - * @param string $pr - * - * @return \Bitbucket\Api\Repositories\Workspaces\PullRequests\Properties - */ - public function properties(string $pr) + public function properties(string $pr): PullRequestsProperties { return new PullRequestsProperties($this->getClient(), $this->workspace, $this->repo, $pr); } - /** - * @param string $pr - * - * @return \Bitbucket\Api\Repositories\Workspaces\PullRequests\Statuses - */ - public function statuses(string $pr) + public function statuses(string $pr): Statuses { return new Statuses($this->getClient(), $this->workspace, $this->repo, $pr); } /** * Build the pull requests URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildPullRequestsUri(string ...$parts) + protected function buildPullRequestsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'pullrequests', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/PullRequests/AbstractPullRequestsApi.php b/src/Api/Repositories/Workspaces/PullRequests/AbstractPullRequestsApi.php index 4260466..27e6766 100644 --- a/src/Api/Repositories/Workspaces/PullRequests/AbstractPullRequestsApi.php +++ b/src/Api/Repositories/Workspaces/PullRequests/AbstractPullRequestsApi.php @@ -23,23 +23,8 @@ */ abstract class AbstractPullRequestsApi extends AbstractWorkspacesApi { - /** - * The pr. - * - * @var string - */ - protected $pr; + protected readonly string $pr; - /** - * Create a new API instance. - * - * @param Client $client - * @param string $workspace - * @param string $repo - * @param string $pr - * - * @return void - */ public function __construct(Client $client, string $workspace, string $repo, string $pr) { parent::__construct($client, $workspace, $repo); diff --git a/src/Api/Repositories/Workspaces/PullRequests/Approval.php b/src/Api/Repositories/Workspaces/PullRequests/Approval.php index 23db61a..a5abb68 100644 --- a/src/Api/Repositories/Workspaces/PullRequests/Approval.php +++ b/src/Api/Repositories/Workspaces/PullRequests/Approval.php @@ -23,13 +23,9 @@ class Approval extends AbstractPullRequestsApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function approve(array $params = []) + public function approve(array $params = []): array { $uri = $this->buildApprovalUri(); @@ -37,13 +33,9 @@ public function approve(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function redact(array $params = []) + public function redact(array $params = []): array { $uri = $this->buildApprovalUri(); @@ -52,12 +44,8 @@ public function redact(array $params = []) /** * Build the approval URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildApprovalUri(string ...$parts) + protected function buildApprovalUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'pullrequests', $this->pr, 'approve', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/PullRequests/Comments.php b/src/Api/Repositories/Workspaces/PullRequests/Comments.php index d0f6d6a..af2c884 100644 --- a/src/Api/Repositories/Workspaces/PullRequests/Comments.php +++ b/src/Api/Repositories/Workspaces/PullRequests/Comments.php @@ -23,13 +23,9 @@ class Comments extends AbstractPullRequestsApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildCommentsUri(); @@ -37,14 +33,9 @@ public function list(array $params = []) } /** - * @param string $comment - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $comment, array $params = []) + public function show(string $comment, array $params = []): array { $uri = $this->buildCommentsUri($comment); @@ -52,13 +43,9 @@ public function show(string $comment, array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = $this->buildCommentsUri(); @@ -66,14 +53,9 @@ public function create(array $params = []) } /** - * @param string $comment - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $comment, array $params = []) + public function update(string $comment, array $params = []): array { $uri = $this->buildCommentsUri($comment); @@ -81,13 +63,9 @@ public function update(string $comment, array $params = []) } /** - * @param string $comment - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $comment) + public function remove(string $comment): array { $uri = $this->buildCommentsUri($comment); @@ -96,12 +74,8 @@ public function remove(string $comment) /** * Build the comments URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildCommentsUri(string ...$parts) + protected function buildCommentsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'pullrequests', $this->pr, 'comments', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/PullRequests/Commits.php b/src/Api/Repositories/Workspaces/PullRequests/Commits.php index 27da748..0b9c1a6 100644 --- a/src/Api/Repositories/Workspaces/PullRequests/Commits.php +++ b/src/Api/Repositories/Workspaces/PullRequests/Commits.php @@ -23,13 +23,9 @@ class Commits extends AbstractPullRequestsApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildCommitsUri(); @@ -38,12 +34,8 @@ public function list(array $params = []) /** * Build the commits URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildCommitsUri(string ...$parts) + protected function buildCommitsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'pullrequests', $this->pr, 'commits', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/PullRequests/Diff.php b/src/Api/Repositories/Workspaces/PullRequests/Diff.php index c0ea632..33a08db 100644 --- a/src/Api/Repositories/Workspaces/PullRequests/Diff.php +++ b/src/Api/Repositories/Workspaces/PullRequests/Diff.php @@ -23,13 +23,9 @@ class Diff extends AbstractPullRequestsApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return \Psr\Http\Message\StreamInterface */ - public function download(array $params = []) + public function download(array $params = []): \Psr\Http\Message\StreamInterface { $uri = $this->buildDiffUri(); @@ -38,12 +34,8 @@ public function download(array $params = []) /** * Build the diff URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildDiffUri(string ...$parts) + protected function buildDiffUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'pullrequests', $this->pr, 'diff', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/PullRequests/DiffStat.php b/src/Api/Repositories/Workspaces/PullRequests/DiffStat.php index 1acaea3..871737e 100644 --- a/src/Api/Repositories/Workspaces/PullRequests/DiffStat.php +++ b/src/Api/Repositories/Workspaces/PullRequests/DiffStat.php @@ -23,13 +23,9 @@ class DiffStat extends AbstractPullRequestsApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function download(array $params = []) + public function download(array $params = []): array { $uri = $this->buildDiffStatUri(); @@ -38,12 +34,8 @@ public function download(array $params = []) /** * Build the diff stat URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildDiffStatUri(string ...$parts) + protected function buildDiffStatUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'pullrequests', $this->pr, 'diffstat', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/PullRequests/Patch.php b/src/Api/Repositories/Workspaces/PullRequests/Patch.php index d23e079..75b0d7e 100644 --- a/src/Api/Repositories/Workspaces/PullRequests/Patch.php +++ b/src/Api/Repositories/Workspaces/PullRequests/Patch.php @@ -23,13 +23,9 @@ class Patch extends AbstractPullRequestsApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return \Psr\Http\Message\StreamInterface */ - public function download(array $params = []) + public function download(array $params = []): \Psr\Http\Message\StreamInterface { $uri = $this->buildPatchUri(); @@ -38,12 +34,8 @@ public function download(array $params = []) /** * Build the patch URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildPatchUri(string ...$parts) + protected function buildPatchUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'pullrequests', $this->pr, 'patch', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/PullRequests/Properties.php b/src/Api/Repositories/Workspaces/PullRequests/Properties.php index 5b0b511..17eaaa5 100644 --- a/src/Api/Repositories/Workspaces/PullRequests/Properties.php +++ b/src/Api/Repositories/Workspaces/PullRequests/Properties.php @@ -23,15 +23,9 @@ class Properties extends AbstractPullRequestsApi { /** - * @param string $app - * @param string $property - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $app, string $property, array $params = []) + public function show(string $app, string $property, array $params = []): array { $uri = $this->buildPropertiesUri($app, $property); @@ -39,15 +33,9 @@ public function show(string $app, string $property, array $params = []) } /** - * @param string $app - * @param string $property - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $app, string $property, array $params = []) + public function update(string $app, string $property, array $params = []): array { $uri = $this->buildPropertiesUri($app, $property); @@ -55,15 +43,9 @@ public function update(string $app, string $property, array $params = []) } /** - * @param string $app - * @param string $property - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $app, string $property, array $params = []) + public function remove(string $app, string $property, array $params = []): array { $uri = $this->buildPropertiesUri($app, $property); @@ -72,12 +54,8 @@ public function remove(string $app, string $property, array $params = []) /** * Build the properties URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildPropertiesUri(string ...$parts) + protected function buildPropertiesUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'pullrequests', $this->pr, 'properties', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/PullRequests/Statuses.php b/src/Api/Repositories/Workspaces/PullRequests/Statuses.php index 3b222fa..981c891 100644 --- a/src/Api/Repositories/Workspaces/PullRequests/Statuses.php +++ b/src/Api/Repositories/Workspaces/PullRequests/Statuses.php @@ -23,13 +23,9 @@ class Statuses extends AbstractPullRequestsApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildStatusesUri(); @@ -38,12 +34,8 @@ public function list(array $params = []) /** * Build the statuses URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildStatusesUri(string ...$parts) + protected function buildStatusesUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'pullrequests', $this->pr, 'statuses', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Refs.php b/src/Api/Repositories/Workspaces/Refs.php index 78c756d..4ccb5dc 100644 --- a/src/Api/Repositories/Workspaces/Refs.php +++ b/src/Api/Repositories/Workspaces/Refs.php @@ -25,43 +25,29 @@ class Refs extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildRefsUri(); return $this->get($uri, $params); } - /** - * @return \Bitbucket\Api\Repositories\Workspaces\Refs\Branches - */ - public function branches() + public function branches(): Branches { return new Branches($this->getClient(), $this->workspace, $this->repo); } - /** - * @return \Bitbucket\Api\Repositories\Workspaces\Refs\Tags - */ - public function tags() + public function tags(): Tags { return new Tags($this->getClient(), $this->workspace, $this->repo); } /** * Build the refs URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildRefsUri(string ...$parts) + protected function buildRefsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'refs', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Refs/Branches.php b/src/Api/Repositories/Workspaces/Refs/Branches.php index 22b4e76..4ed4d02 100644 --- a/src/Api/Repositories/Workspaces/Refs/Branches.php +++ b/src/Api/Repositories/Workspaces/Refs/Branches.php @@ -23,13 +23,9 @@ class Branches extends AbstractRefsApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildBranchesUri(); @@ -37,13 +33,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = $this->buildBranchesUri(); @@ -51,14 +43,9 @@ public function create(array $params = []) } /** - * @param string $branch - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $branch, array $params = []) + public function show(string $branch, array $params = []): array { $uri = $this->buildBranchesUri($branch); @@ -66,14 +53,9 @@ public function show(string $branch, array $params = []) } /** - * @param string $branch - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $branch, array $params = []) + public function remove(string $branch, array $params = []): array { $uri = $this->buildBranchesUri($branch); @@ -82,12 +64,8 @@ public function remove(string $branch, array $params = []) /** * Build the branches URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildBranchesUri(string ...$parts) + protected function buildBranchesUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'refs', 'branches', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Refs/Tags.php b/src/Api/Repositories/Workspaces/Refs/Tags.php index 0cc038f..dba8db9 100644 --- a/src/Api/Repositories/Workspaces/Refs/Tags.php +++ b/src/Api/Repositories/Workspaces/Refs/Tags.php @@ -23,13 +23,9 @@ class Tags extends AbstractRefsApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildTagsUri(); @@ -37,13 +33,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = $this->buildTagsUri(); @@ -51,14 +43,9 @@ public function create(array $params = []) } /** - * @param string $tag - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $tag, array $params = []) + public function show(string $tag, array $params = []): array { $uri = $this->buildTagsUri($tag); @@ -66,14 +53,9 @@ public function show(string $tag, array $params = []) } /** - * @param string $tag - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $tag, array $params = []) + public function remove(string $tag, array $params = []): array { $uri = $this->buildTagsUri($tag); @@ -82,12 +64,8 @@ public function remove(string $tag, array $params = []) /** * Build the tags URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildTagsUri(string ...$parts) + protected function buildTagsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'refs', 'tags', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Src.php b/src/Api/Repositories/Workspaces/Src.php index 88a4ef2..37c7985 100644 --- a/src/Api/Repositories/Workspaces/Src.php +++ b/src/Api/Repositories/Workspaces/Src.php @@ -25,13 +25,9 @@ class Src extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildSrcUri(); @@ -42,10 +38,8 @@ public function list(array $params = []) * @param array $params * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = $this->buildSrcUri(); @@ -57,10 +51,8 @@ public function create(array $params = []) * @param array $params * * @throws \Http\Client\Exception - * - * @return array */ - public function createWithFiles(array $files, array $params = []) + public function createWithFiles(array $files, array $params = []): array { $uri = $this->buildSrcUri(); @@ -84,17 +76,11 @@ public function createWithFiles(array $files, array $params = []) } /** - * @param string $commit - * @param string $filepath - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $commit, string $filepath, array $params = []) + public function show(string $commit, string $filepath, array $params = []): array { - $uri = $this->buildSrcUri($commit, $filepath); + $uri = $this->buildSrcUri($commit, ...\explode('/', $filepath)); if (!isset($params['format'])) { $params['format'] = 'meta'; @@ -104,29 +90,19 @@ public function show(string $commit, string $filepath, array $params = []) } /** - * @param string $commit - * @param string $filepath - * @param array $params - * * @throws \Http\Client\Exception - * - * @return \Psr\Http\Message\StreamInterface */ - public function download(string $commit, string $filepath, array $params = []) + public function download(string $commit, string $filepath, array $params = []): \Psr\Http\Message\StreamInterface { - $uri = $this->buildSrcUri($commit, $filepath); + $uri = $this->buildSrcUri($commit, ...\explode('/', $filepath)); return $this->getAsResponse($uri, $params, ['Accept' => '*/*'])->getBody(); } /** * Build the src URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildSrcUri(string ...$parts) + protected function buildSrcUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'src', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Versions.php b/src/Api/Repositories/Workspaces/Versions.php index f532a33..c07e0a0 100644 --- a/src/Api/Repositories/Workspaces/Versions.php +++ b/src/Api/Repositories/Workspaces/Versions.php @@ -23,13 +23,9 @@ class Versions extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildVersionsUri(); @@ -37,14 +33,9 @@ public function list(array $params = []) } /** - * @param string $version - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $version, array $params = []) + public function show(string $version, array $params = []): array { $uri = $this->buildVersionsUri($version); @@ -53,12 +44,8 @@ public function show(string $version, array $params = []) /** * Build the versions URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildVersionsUri(string ...$parts) + protected function buildVersionsUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'versions', ...$parts); } diff --git a/src/Api/Repositories/Workspaces/Watchers.php b/src/Api/Repositories/Workspaces/Watchers.php index 3dc321a..d605228 100644 --- a/src/Api/Repositories/Workspaces/Watchers.php +++ b/src/Api/Repositories/Workspaces/Watchers.php @@ -23,13 +23,9 @@ class Watchers extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildWatchersUri(); @@ -38,12 +34,8 @@ public function list(array $params = []) /** * Build the watchers URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildWatchersUri(string ...$parts) + protected function buildWatchersUri(string ...$parts): string { return UriBuilder::build('repositories', $this->workspace, $this->repo, 'watchers', ...$parts); } diff --git a/src/Api/Snippets.php b/src/Api/Snippets.php index 4344a70..e2165d6 100644 --- a/src/Api/Snippets.php +++ b/src/Api/Snippets.php @@ -27,13 +27,9 @@ class Snippets extends AbstractApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildSnippetsUri(); @@ -41,13 +37,9 @@ public function list(array $params = []) } /** - * @param \Bitbucket\HttpClient\Message\FileResource $file - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(FileResource $file) + public function create(FileResource $file): array { $uri = $this->buildSnippetsUri(); $builder = (new MultipartStreamBuilder())->addResource($file->getName(), $file->getResource(), $file->getOptions()); @@ -56,24 +48,15 @@ public function create(FileResource $file) return $this->postRaw($uri, $builder->build(), $headers); } - /** - * @param string $workspace - * - * @return \Bitbucket\Api\Snippets\Workspaces - */ - public function workspaces(string $workspace) + public function workspaces(string $workspace): SnippetsWorkspaces { return new SnippetsWorkspaces($this->getClient(), $workspace); } /** * Build the snippets URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildSnippetsUri(string ...$parts) + protected function buildSnippetsUri(string ...$parts): string { return UriBuilder::build('snippets', ...$parts); } diff --git a/src/Api/Snippets/AbstractSnippetsApi.php b/src/Api/Snippets/AbstractSnippetsApi.php index ba3a497..7a78e61 100644 --- a/src/Api/Snippets/AbstractSnippetsApi.php +++ b/src/Api/Snippets/AbstractSnippetsApi.php @@ -23,21 +23,8 @@ */ abstract class AbstractSnippetsApi extends AbstractApi { - /** - * The workspace. - * - * @var string - */ - protected $workspace; + protected readonly string $workspace; - /** - * Create a new API instance. - * - * @param Client $client - * @param string $workspace - * - * @return void - */ public function __construct(Client $client, string $workspace) { parent::__construct($client); diff --git a/src/Api/Snippets/Workspaces.php b/src/Api/Snippets/Workspaces.php index 99d98c6..db42621 100644 --- a/src/Api/Snippets/Workspaces.php +++ b/src/Api/Snippets/Workspaces.php @@ -33,13 +33,9 @@ class Workspaces extends AbstractSnippetsApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildWorkspacesUri(); @@ -47,13 +43,9 @@ public function list(array $params = []) } /** - * @param \Bitbucket\HttpClient\Message\FileResource $file - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(FileResource $file) + public function create(FileResource $file): array { $uri = $this->buildWorkspacesUri(); $builder = (new MultipartStreamBuilder())->addResource($file->getName(), $file->getResource(), $file->getOptions()); @@ -63,14 +55,9 @@ public function create(FileResource $file) } /** - * @param string $snippet - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $snippet, array $params = []) + public function show(string $snippet, array $params = []): array { $uri = $this->buildWorkspacesUri($snippet); @@ -78,14 +65,9 @@ public function show(string $snippet, array $params = []) } /** - * @param string $snippet - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $snippet, array $params = []) + public function update(string $snippet, array $params = []): array { $uri = $this->buildWorkspacesUri($snippet); @@ -93,14 +75,11 @@ public function update(string $snippet, array $params = []) } /** - * @param string $snippet * @param \Bitbucket\HttpClient\Message\FileResource[] $files * * @throws \Http\Client\Exception - * - * @return array */ - public function updateFiles(string $snippet, array $files) + public function updateFiles(string $snippet, array $files): array { $uri = $this->buildWorkspacesUri($snippet); @@ -116,98 +95,54 @@ public function updateFiles(string $snippet, array $files) } /** - * @param string $snippet - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $snippet, array $params = []) + public function remove(string $snippet, array $params = []): array { $uri = $this->buildWorkspacesUri($snippet); return $this->delete($uri, $params); } - /** - * @param string $snippet - * - * @return \Bitbucket\Api\Snippets\Workspaces\Comments - */ - public function comments(string $snippet) + public function comments(string $snippet): Comments { return new Comments($this->getClient(), $this->workspace, $snippet); } - /** - * @param string $snippet - * - * @return \Bitbucket\Api\Snippets\Workspaces\Commits - */ - public function commits(string $snippet) + public function commits(string $snippet): Commits { return new Commits($this->getClient(), $this->workspace, $snippet); } - /** - * @param string $snippet - * - * @return \Bitbucket\Api\Snippets\Workspaces\Diffs - */ - public function diffs(string $snippet) + public function diffs(string $snippet): Diffs { return new Diffs($this->getClient(), $this->workspace, $snippet); } - /** - * @param string $snippet - * - * @return \Bitbucket\Api\Snippets\Workspaces\Files - */ - public function files(string $snippet) + public function files(string $snippet): Files { return new Files($this->getClient(), $this->workspace, $snippet); } - /** - * @param string $snippet - * - * @return \Bitbucket\Api\Snippets\Workspaces\Patches - */ - public function patches(string $snippet) + public function patches(string $snippet): Patches { return new Patches($this->getClient(), $this->workspace, $snippet); } - /** - * @param string $snippet - * - * @return \Bitbucket\Api\Snippets\Workspaces\Watchers - */ - public function watchers(string $snippet) + public function watchers(string $snippet): Watchers { return new Watchers($this->getClient(), $this->workspace, $snippet); } - /** - * @param string $snippet - * - * @return \Bitbucket\Api\Snippets\Workspaces\Watching - */ - public function watching(string $snippet) + public function watching(string $snippet): Watching { return new Watching($this->getClient(), $this->workspace, $snippet); } /** * Build the workspaces URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildWorkspacesUri(string ...$parts) + protected function buildWorkspacesUri(string ...$parts): string { return UriBuilder::build('snippets', $this->workspace, ...$parts); } diff --git a/src/Api/Snippets/Workspaces/AbstractWorkspacesApi.php b/src/Api/Snippets/Workspaces/AbstractWorkspacesApi.php index afdad2a..5103f42 100644 --- a/src/Api/Snippets/Workspaces/AbstractWorkspacesApi.php +++ b/src/Api/Snippets/Workspaces/AbstractWorkspacesApi.php @@ -23,22 +23,8 @@ */ abstract class AbstractWorkspacesApi extends AbstractSnippetsApi { - /** - * The snippet. - * - * @var string - */ - protected $snippet; + protected readonly string $snippet; - /** - * Create a new API instance. - * - * @param Client $client - * @param string $workspace - * @param string $snippet - * - * @return void - */ public function __construct(Client $client, string $workspace, string $snippet) { parent::__construct($client, $workspace); diff --git a/src/Api/Snippets/Workspaces/Comments.php b/src/Api/Snippets/Workspaces/Comments.php index 7c00fcd..ea3ff06 100644 --- a/src/Api/Snippets/Workspaces/Comments.php +++ b/src/Api/Snippets/Workspaces/Comments.php @@ -23,13 +23,9 @@ class Comments extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildCommentsUri(); @@ -37,13 +33,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = $this->buildCommentsUri(); @@ -51,14 +43,9 @@ public function create(array $params = []) } /** - * @param string $comment - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $comment, array $params = []) + public function show(string $comment, array $params = []): array { $uri = $this->buildCommentsUri($comment); @@ -66,14 +53,9 @@ public function show(string $comment, array $params = []) } /** - * @param string $comment - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $comment, array $params = []) + public function update(string $comment, array $params = []): array { $uri = $this->buildCommentsUri($comment); @@ -81,14 +63,9 @@ public function update(string $comment, array $params = []) } /** - * @param string $comment - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $comment, array $params = []) + public function remove(string $comment, array $params = []): array { $uri = $this->buildCommentsUri($comment); @@ -97,12 +74,8 @@ public function remove(string $comment, array $params = []) /** * Build the comments URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildCommentsUri(string ...$parts) + protected function buildCommentsUri(string ...$parts): string { return UriBuilder::build('snippets', $this->workspace, $this->snippet, 'comments', ...$parts); } diff --git a/src/Api/Snippets/Workspaces/Commits.php b/src/Api/Snippets/Workspaces/Commits.php index c5b7564..a4ce9b6 100644 --- a/src/Api/Snippets/Workspaces/Commits.php +++ b/src/Api/Snippets/Workspaces/Commits.php @@ -23,13 +23,9 @@ class Commits extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildCommitsUri(); @@ -37,14 +33,9 @@ public function list(array $params = []) } /** - * @param string $commit - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $commit, array $params = []) + public function show(string $commit, array $params = []): array { $uri = $this->buildCommitsUri($commit); @@ -53,12 +44,8 @@ public function show(string $commit, array $params = []) /** * Build the commits URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildCommitsUri(string ...$parts) + protected function buildCommitsUri(string ...$parts): string { return UriBuilder::build('snippets', $this->workspace, $this->snippet, 'commits', ...$parts); } diff --git a/src/Api/Snippets/Workspaces/Diffs.php b/src/Api/Snippets/Workspaces/Diffs.php index 328c862..77d9aa8 100644 --- a/src/Api/Snippets/Workspaces/Diffs.php +++ b/src/Api/Snippets/Workspaces/Diffs.php @@ -23,14 +23,9 @@ class Diffs extends AbstractWorkspacesApi { /** - * @param string $commit - * @param array $params - * * @throws \Http\Client\Exception - * - * @return \Psr\Http\Message\StreamInterface */ - public function download(string $commit, array $params = []) + public function download(string $commit, array $params = []): \Psr\Http\Message\StreamInterface { $uri = $this->buildDiffsUri($commit, 'diff'); @@ -39,12 +34,8 @@ public function download(string $commit, array $params = []) /** * Build the diffs URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildDiffsUri(string ...$parts) + protected function buildDiffsUri(string ...$parts): string { return UriBuilder::build('snippets', $this->workspace, $this->snippet, ...$parts); } diff --git a/src/Api/Snippets/Workspaces/Files.php b/src/Api/Snippets/Workspaces/Files.php index a7609fb..79301e4 100644 --- a/src/Api/Snippets/Workspaces/Files.php +++ b/src/Api/Snippets/Workspaces/Files.php @@ -25,14 +25,9 @@ class Files extends AbstractWorkspacesApi { /** - * @param string $commit - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $commit, array $params = []) + public function show(string $commit, array $params = []): array { $uri = $this->buildFilesUri($commit); @@ -40,15 +35,9 @@ public function show(string $commit, array $params = []) } /** - * @param string $commit - * @param string $uri - * @param array $params - * * @throws \Http\Client\Exception - * - * @return \Psr\Http\Message\StreamInterface */ - public function download(string $commit, string $uri, array $params = []) + public function download(string $commit, string $uri, array $params = []): \Psr\Http\Message\StreamInterface { $uri = $this->buildFilesUri($commit, 'files', ...\explode('/', $uri)); @@ -56,14 +45,9 @@ public function download(string $commit, string $uri, array $params = []) } /** - * @param string $commit - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $commit, array $params = []) + public function update(string $commit, array $params = []): array { $uri = $this->buildFilesUri($commit); @@ -71,14 +55,11 @@ public function update(string $commit, array $params = []) } /** - * @param string $commit * @param \Bitbucket\HttpClient\Message\FileResource[] $files * * @throws \Http\Client\Exception - * - * @return array */ - public function updateFiles(string $commit, array $files) + public function updateFiles(string $commit, array $files): array { $uri = $this->buildFilesUri($commit); @@ -94,14 +75,9 @@ public function updateFiles(string $commit, array $files) } /** - * @param string $commit - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $commit, array $params = []) + public function remove(string $commit, array $params = []): array { $uri = $this->buildFilesUri($commit); @@ -110,12 +86,8 @@ public function remove(string $commit, array $params = []) /** * Build the files URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildFilesUri(string ...$parts) + protected function buildFilesUri(string ...$parts): string { return UriBuilder::build('snippets', $this->workspace, $this->snippet, ...$parts); } diff --git a/src/Api/Snippets/Workspaces/Patches.php b/src/Api/Snippets/Workspaces/Patches.php index 67298f3..e7d1737 100644 --- a/src/Api/Snippets/Workspaces/Patches.php +++ b/src/Api/Snippets/Workspaces/Patches.php @@ -23,14 +23,9 @@ class Patches extends AbstractWorkspacesApi { /** - * @param string $commit - * @param array $params - * * @throws \Http\Client\Exception - * - * @return \Psr\Http\Message\StreamInterface */ - public function download(string $commit, array $params = []) + public function download(string $commit, array $params = []): \Psr\Http\Message\StreamInterface { $uri = $this->buildPatchesUri($commit, 'patch'); @@ -39,12 +34,8 @@ public function download(string $commit, array $params = []) /** * Build the patches URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildPatchesUri(string ...$parts) + protected function buildPatchesUri(string ...$parts): string { return UriBuilder::build('snippets', $this->workspace, $this->snippet, ...$parts); } diff --git a/src/Api/Snippets/Workspaces/Watchers.php b/src/Api/Snippets/Workspaces/Watchers.php index dc3b0cc..40a2628 100644 --- a/src/Api/Snippets/Workspaces/Watchers.php +++ b/src/Api/Snippets/Workspaces/Watchers.php @@ -23,13 +23,9 @@ class Watchers extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildWatchersUri(); @@ -38,12 +34,8 @@ public function list(array $params = []) /** * Build the watchers URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildWatchersUri(string ...$parts) + protected function buildWatchersUri(string ...$parts): string { return UriBuilder::build('snippets', $this->workspace, $this->snippet, 'watchers', ...$parts); } diff --git a/src/Api/Snippets/Workspaces/Watching.php b/src/Api/Snippets/Workspaces/Watching.php index 6e75349..b9c0619 100644 --- a/src/Api/Snippets/Workspaces/Watching.php +++ b/src/Api/Snippets/Workspaces/Watching.php @@ -23,13 +23,9 @@ class Watching extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function check(array $params = []) + public function check(array $params = []): array { $uri = $this->buildWatchingUri(); @@ -37,13 +33,9 @@ public function check(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function watch(array $params = []) + public function watch(array $params = []): array { $uri = $this->buildWatchingUri(); @@ -51,13 +43,9 @@ public function watch(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function ignore(array $params = []) + public function ignore(array $params = []): array { $uri = $this->buildWatchingUri(); @@ -66,12 +54,8 @@ public function ignore(array $params = []) /** * Build the watching URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildWatchingUri(string ...$parts) + protected function buildWatchingUri(string ...$parts): string { return UriBuilder::build('snippets', $this->workspace, $this->snippet, 'watch', ...$parts); } diff --git a/src/Api/Users.php b/src/Api/Users.php index ac8b9be..fc03ca0 100644 --- a/src/Api/Users.php +++ b/src/Api/Users.php @@ -26,59 +26,33 @@ */ class Users extends AbstractApi { - /** - * The username. - * - * @var string - */ - protected $username; + protected readonly string $username; - /** - * Create a new API instance. - * - * @param Client $client - * @param string $username - * - * @return void - */ public function __construct(Client $client, string $username) { parent::__construct($client); $this->username = $username; } - /** - * @return \Bitbucket\Api\Users\Properties - */ - public function properties() + public function properties(): Properties { return new Properties($this->getClient(), $this->username); } - /** - * @return \Bitbucket\Api\Users\Repositories - */ - public function repositories() + public function repositories(): UsersRepositories { return new UsersRepositories($this->getClient(), $this->username); } - /** - * @return \Bitbucket\Api\Users\SshKeys - */ - public function sshKeys() + public function sshKeys(): SshKeys { return new SshKeys($this->getClient(), $this->username); } /** * Build the users URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildUsersUri(string ...$parts) + protected function buildUsersUri(string ...$parts): string { return UriBuilder::build('users', $this->username, ...$parts); } diff --git a/src/Api/Users/AbstractUsersApi.php b/src/Api/Users/AbstractUsersApi.php index 41710c3..ba282e5 100644 --- a/src/Api/Users/AbstractUsersApi.php +++ b/src/Api/Users/AbstractUsersApi.php @@ -23,21 +23,8 @@ */ abstract class AbstractUsersApi extends AbstractApi { - /** - * The username. - * - * @var string - */ - protected $username; + protected readonly string $username; - /** - * Create a new API instance. - * - * @param Client $client - * @param string $username - * - * @return void - */ public function __construct(Client $client, string $username) { parent::__construct($client); diff --git a/src/Api/Users/Properties.php b/src/Api/Users/Properties.php index 9b35111..77dcc22 100644 --- a/src/Api/Users/Properties.php +++ b/src/Api/Users/Properties.php @@ -23,15 +23,9 @@ class Properties extends AbstractUsersApi { /** - * @param string $app - * @param string $property - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $app, string $property, array $params = []) + public function show(string $app, string $property, array $params = []): array { $uri = $this->buildPropertiesUri($app, $property); @@ -39,15 +33,9 @@ public function show(string $app, string $property, array $params = []) } /** - * @param string $app - * @param string $property - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $app, string $property, array $params = []) + public function update(string $app, string $property, array $params = []): array { $uri = $this->buildPropertiesUri($app, $property); @@ -55,15 +43,9 @@ public function update(string $app, string $property, array $params = []) } /** - * @param string $app - * @param string $property - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $app, string $property, array $params = []) + public function remove(string $app, string $property, array $params = []): array { $uri = $this->buildPropertiesUri($app, $property); @@ -72,12 +54,8 @@ public function remove(string $app, string $property, array $params = []) /** * Build the properties URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildPropertiesUri(string ...$parts) + protected function buildPropertiesUri(string ...$parts): string { return UriBuilder::build('users', $this->username, 'properties', ...$parts); } diff --git a/src/Api/Users/Repositories.php b/src/Api/Users/Repositories.php index e7e8c46..6287ba0 100644 --- a/src/Api/Users/Repositories.php +++ b/src/Api/Users/Repositories.php @@ -23,13 +23,9 @@ class Repositories extends AbstractUsersApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildRepositoriesUri(); @@ -38,12 +34,8 @@ public function list(array $params = []) /** * Build the repositories URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildRepositoriesUri(string ...$parts) + protected function buildRepositoriesUri(string ...$parts): string { return UriBuilder::build('users', $this->username, 'repositories', ...$parts); } diff --git a/src/Api/Users/SshKeys.php b/src/Api/Users/SshKeys.php index ecc7432..9ac4666 100644 --- a/src/Api/Users/SshKeys.php +++ b/src/Api/Users/SshKeys.php @@ -23,13 +23,9 @@ class SshKeys extends AbstractUsersApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildSshKeysUri()); @@ -37,13 +33,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildSshKeysUri()); @@ -51,14 +43,9 @@ public function create(array $params = []) } /** - * @param string $id - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $id, array $params = []) + public function show(string $id, array $params = []): array { $uri = $this->buildSshKeysUri($id); @@ -66,14 +53,9 @@ public function show(string $id, array $params = []) } /** - * @param string $id - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $id, array $params = []) + public function update(string $id, array $params = []): array { $uri = $this->buildSshKeysUri($id); @@ -81,14 +63,9 @@ public function update(string $id, array $params = []) } /** - * @param string $id - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $id, array $params = []) + public function remove(string $id, array $params = []): array { $uri = $this->buildSshKeysUri($id); @@ -97,12 +74,8 @@ public function remove(string $id, array $params = []) /** * Build the ssh keys URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildSshKeysUri(string ...$parts) + protected function buildSshKeysUri(string ...$parts): string { return UriBuilder::build('users', $this->username, 'ssh-keys', ...$parts); } diff --git a/src/Api/Workspaces.php b/src/Api/Workspaces.php index 4ca5e83..2c993b8 100644 --- a/src/Api/Workspaces.php +++ b/src/Api/Workspaces.php @@ -28,21 +28,8 @@ */ class Workspaces extends AbstractApi { - /** - * The workspace. - * - * @var string - */ - protected $workspace; + protected readonly string $workspace; - /** - * Create a new API instance. - * - * @param Client $client - * @param string $workspace - * - * @return void - */ public function __construct(Client $client, string $workspace) { parent::__construct($client); @@ -50,13 +37,9 @@ public function __construct(Client $client, string $workspace) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(array $params = []) + public function show(array $params = []): array { $uri = $this->buildWorkspacesUri(); @@ -64,67 +47,44 @@ public function show(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function codeSearch(array $params = []) + public function codeSearch(array $params = []): array { $uri = $this->buildWorkspacesUri('search', 'code'); return $this->get($uri, $params); } - /** - * @return \Bitbucket\Api\Workspaces\Hooks - */ - public function hooks() + public function hooks(): Hooks { return new Hooks($this->getClient(), $this->workspace); } - /** - * @return \Bitbucket\Api\Workspaces\Members - */ - public function members() + public function members(): Members { return new Members($this->getClient(), $this->workspace); } - /** - * @return \Bitbucket\Api\Workspaces\Permissions - */ - public function permissions() + public function permissions(): Permissions { return new Permissions($this->getClient(), $this->workspace); } - /** - * @return \Bitbucket\Api\Workspaces\PipelinesConfig - */ - public function pipelinesConfig() + public function pipelinesConfig(): PipelinesConfig { return new PipelinesConfig($this->getClient(), $this->workspace); } - /** - * @return \Bitbucket\Api\Workspaces\Projects - */ - public function projects() + public function projects(): Projects { return new Projects($this->getClient(), $this->workspace); } /** * Build the workspaces URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildWorkspacesUri(string ...$parts) + protected function buildWorkspacesUri(string ...$parts): string { return UriBuilder::build('workspaces', $this->workspace, ...$parts); } diff --git a/src/Api/Workspaces/AbstractWorkspacesApi.php b/src/Api/Workspaces/AbstractWorkspacesApi.php index 9d30aea..fd7cff8 100644 --- a/src/Api/Workspaces/AbstractWorkspacesApi.php +++ b/src/Api/Workspaces/AbstractWorkspacesApi.php @@ -23,21 +23,8 @@ */ abstract class AbstractWorkspacesApi extends AbstractApi { - /** - * The workspace. - * - * @var string - */ - protected $workspace; + protected readonly string $workspace; - /** - * Create a new API instance. - * - * @param Client $client - * @param string $workspace - * - * @return void - */ public function __construct(Client $client, string $workspace) { parent::__construct($client); diff --git a/src/Api/Workspaces/Hooks.php b/src/Api/Workspaces/Hooks.php index ea60a2c..3472db4 100644 --- a/src/Api/Workspaces/Hooks.php +++ b/src/Api/Workspaces/Hooks.php @@ -23,13 +23,9 @@ class Hooks extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildHooksUri(); @@ -37,13 +33,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = $this->buildHooksUri(); @@ -51,14 +43,9 @@ public function create(array $params = []) } /** - * @param string $hook - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $hook, array $params = []) + public function show(string $hook, array $params = []): array { $uri = $this->buildHooksUri($hook); @@ -66,14 +53,9 @@ public function show(string $hook, array $params = []) } /** - * @param string $hook - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $hook, array $params = []) + public function update(string $hook, array $params = []): array { $uri = $this->buildHooksUri($hook); @@ -81,14 +63,9 @@ public function update(string $hook, array $params = []) } /** - * @param string $hook - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $hook, array $params = []) + public function remove(string $hook, array $params = []): array { $uri = $this->buildHooksUri($hook); @@ -97,12 +74,8 @@ public function remove(string $hook, array $params = []) /** * Build the hooks URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildHooksUri(string ...$parts) + protected function buildHooksUri(string ...$parts): string { return UriBuilder::build('workspaces', $this->workspace, 'hooks', ...$parts); } diff --git a/src/Api/Workspaces/Members.php b/src/Api/Workspaces/Members.php index d5070ba..93d0d4a 100644 --- a/src/Api/Workspaces/Members.php +++ b/src/Api/Workspaces/Members.php @@ -23,13 +23,9 @@ class Members extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildMembersUri(); @@ -37,14 +33,9 @@ public function list(array $params = []) } /** - * @param string $member - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $member, array $params = []) + public function show(string $member, array $params = []): array { $uri = $this->buildMembersUri($member); @@ -53,12 +44,8 @@ public function show(string $member, array $params = []) /** * Build the members URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildMembersUri(string ...$parts) + protected function buildMembersUri(string ...$parts): string { return UriBuilder::build('workspaces', $this->workspace, 'members', ...$parts); } diff --git a/src/Api/Workspaces/Permissions.php b/src/Api/Workspaces/Permissions.php index 9cb77c1..69cd654 100644 --- a/src/Api/Workspaces/Permissions.php +++ b/src/Api/Workspaces/Permissions.php @@ -25,35 +25,24 @@ class Permissions extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = $this->buildPermissionsUri(); return $this->get($uri, $params); } - /** - * @return \Bitbucket\Api\Workspaces\Permissions\Repositories - */ - public function repositories() + public function repositories(): Repositories { return new Repositories($this->getClient(), $this->workspace); } /** * Build the permissions URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildPermissionsUri(string ...$parts) + protected function buildPermissionsUri(string ...$parts): string { return UriBuilder::build('workspaces', $this->workspace, 'permissions', ...$parts); } diff --git a/src/Api/Workspaces/Permissions/Repositories.php b/src/Api/Workspaces/Permissions/Repositories.php index 1a72259..53ef67e 100644 --- a/src/Api/Workspaces/Permissions/Repositories.php +++ b/src/Api/Workspaces/Permissions/Repositories.php @@ -23,13 +23,9 @@ class Repositories extends AbstractPermissionsApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildRepositoriesUri()); @@ -37,14 +33,9 @@ public function list(array $params = []) } /** - * @param string $repo - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $repo, array $params = []) + public function show(string $repo, array $params = []): array { $uri = $this->buildRepositoriesUri($repo); @@ -53,12 +44,8 @@ public function show(string $repo, array $params = []) /** * Build the repositories URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildRepositoriesUri(string ...$parts) + protected function buildRepositoriesUri(string ...$parts): string { return UriBuilder::build('workspaces', $this->workspace, 'permissions', 'repositories', ...$parts); } diff --git a/src/Api/Workspaces/PipelinesConfig.php b/src/Api/Workspaces/PipelinesConfig.php index 0e6ed6c..5951a71 100644 --- a/src/Api/Workspaces/PipelinesConfig.php +++ b/src/Api/Workspaces/PipelinesConfig.php @@ -23,22 +23,15 @@ */ class PipelinesConfig extends AbstractWorkspacesApi { - /** - * @return \Bitbucket\Api\Workspaces\PipelinesConfig\Variables - */ - public function variables() + public function variables(): Variables { return new Variables($this->getClient(), $this->workspace); } /** * Build the pipelines config URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildPipelinesConfigUri(string ...$parts) + protected function buildPipelinesConfigUri(string ...$parts): string { return UriBuilder::build('workspaces', $this->workspace, 'pipelines_config', ...$parts); } diff --git a/src/Api/Workspaces/PipelinesConfig/Variables.php b/src/Api/Workspaces/PipelinesConfig/Variables.php index 6211ac1..7bb2048 100644 --- a/src/Api/Workspaces/PipelinesConfig/Variables.php +++ b/src/Api/Workspaces/PipelinesConfig/Variables.php @@ -23,13 +23,9 @@ class Variables extends AbstractPipelinesConfigApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildVariablesUri()); @@ -37,13 +33,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildVariablesUri()); @@ -51,14 +43,9 @@ public function create(array $params = []) } /** - * @param string $variable - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $variable, array $params = []) + public function show(string $variable, array $params = []): array { $uri = $this->buildVariablesUri($variable); @@ -66,14 +53,9 @@ public function show(string $variable, array $params = []) } /** - * @param string $variable - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $variable, array $params = []) + public function update(string $variable, array $params = []): array { $uri = $this->buildVariablesUri($variable); @@ -81,14 +63,9 @@ public function update(string $variable, array $params = []) } /** - * @param string $variable - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $variable, array $params = []) + public function remove(string $variable, array $params = []): array { $uri = $this->buildVariablesUri($variable); @@ -97,12 +74,8 @@ public function remove(string $variable, array $params = []) /** * Build the variables URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildVariablesUri(string ...$parts) + protected function buildVariablesUri(string ...$parts): string { return UriBuilder::build('workspaces', $this->workspace, 'pipelines-config', 'variables', ...$parts); } diff --git a/src/Api/Workspaces/Projects.php b/src/Api/Workspaces/Projects.php index fa5d454..3b3b525 100644 --- a/src/Api/Workspaces/Projects.php +++ b/src/Api/Workspaces/Projects.php @@ -23,13 +23,9 @@ class Projects extends AbstractWorkspacesApi { /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function list(array $params = []) + public function list(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildProjectsUri()); @@ -37,13 +33,9 @@ public function list(array $params = []) } /** - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function create(array $params = []) + public function create(array $params = []): array { $uri = UriBuilder::appendSeparator($this->buildProjectsUri()); @@ -51,14 +43,9 @@ public function create(array $params = []) } /** - * @param string $project - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function show(string $project, array $params = []) + public function show(string $project, array $params = []): array { $uri = $this->buildProjectsUri($project); @@ -66,14 +53,9 @@ public function show(string $project, array $params = []) } /** - * @param string $project - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function update(string $project, array $params = []) + public function update(string $project, array $params = []): array { $uri = $this->buildProjectsUri($project); @@ -81,14 +63,9 @@ public function update(string $project, array $params = []) } /** - * @param string $project - * @param array $params - * * @throws \Http\Client\Exception - * - * @return array */ - public function remove(string $project, array $params = []) + public function remove(string $project, array $params = []): array { $uri = $this->buildProjectsUri($project); @@ -97,12 +74,8 @@ public function remove(string $project, array $params = []) /** * Build the projects URI from the given parts. - * - * @param string ...$parts - * - * @return string */ - protected function buildProjectsUri(string ...$parts) + protected function buildProjectsUri(string ...$parts): string { return UriBuilder::build('workspaces', $this->workspace, 'projects', ...$parts); } diff --git a/src/Client.php b/src/Client.php index 8fb3b1b..f1782c1 100644 --- a/src/Client.php +++ b/src/Client.php @@ -76,30 +76,12 @@ class Client * * @var string */ - private const USER_AGENT = 'bitbucket-php-api-client/4.4'; + private const USER_AGENT = 'bitbucket-php-api-client/5.0'; - /** - * The HTTP client builder. - * - * @var \Bitbucket\HttpClient\Builder - */ - private $httpClientBuilder; - - /** - * The response history plugin. - * - * @var \Bitbucket\HttpClient\Plugin\History - */ - private $responseHistory; + private readonly Builder $httpClientBuilder; + private readonly History $responseHistory; - /** - * Create a new Bitbucket API client instance. - * - * @param \Bitbucket\HttpClient\Builder|null $httpClientBuilder - * - * @return void - */ - public function __construct(Builder $httpClientBuilder = null) + public function __construct(?Builder $httpClientBuilder = null) { $this->httpClientBuilder = $builder = $httpClientBuilder ?? new Builder(); $this->responseHistory = new History(); @@ -118,10 +100,6 @@ public function __construct(Builder $httpClientBuilder = null) /** * Create a Bitbucket\Client using an HTTP client. - * - * @param \Psr\Http\Client\ClientInterface $httpClient - * - * @return Client */ public static function createWithHttpClient(ClientInterface $httpClient): self { @@ -130,69 +108,41 @@ public static function createWithHttpClient(ClientInterface $httpClient): self return new self($builder); } - /** - * @return \Bitbucket\Api\Addon - */ public function addon(): Addon { return new Addon($this); } - /** - * @return \Bitbucket\Api\CurrentUser - */ public function currentUser(): CurrentUser { return new CurrentUser($this); } - /** - * @return \Bitbucket\Api\HookEvents - */ public function hookEvents(): HookEvents { return new HookEvents($this); } - /** - * @return \Bitbucket\Api\PullRequests - */ public function pullRequests(): PullRequests { return new PullRequests($this); } - /** - * @return \Bitbucket\Api\Repositories - */ public function repositories(): Repositories { return new Repositories($this); } - /** - * @return \Bitbucket\Api\Snippets - */ public function snippets(): Snippets { return new Snippets($this); } - /** - * @param string $username - * - * @return \Bitbucket\Api\Users - */ public function users(string $username): Users { return new Users($this, $username); } - /** - * @param string $workspace - * - * @return \Bitbucket\Api\Workspaces - */ public function workspaces(string $workspace): Workspaces { return new Workspaces($this, $workspace); @@ -200,14 +150,8 @@ public function workspaces(string $workspace): Workspaces /** * Authenticate a user for all next requests. - * - * @param string $method - * @param string $token - * @param string|null $password - * - * @return void */ - public function authenticate(string $method, string $token, string $password = null): void + public function authenticate(string $method, string $token, ?string $password = null): void { $this->getHttpClientBuilder()->removePlugin(Authentication::class); $this->getHttpClientBuilder()->addPlugin(new Authentication($method, $token, $password)); @@ -215,10 +159,6 @@ public function authenticate(string $method, string $token, string $password = n /** * Set the base URL. - * - * @param string $url - * - * @return void */ public function setUrl(string $url): void { @@ -228,8 +168,6 @@ public function setUrl(string $url): void /** * Get the last response. - * - * @return \Psr\Http\Message\ResponseInterface|null */ public function getLastResponse(): ?ResponseInterface { @@ -238,8 +176,6 @@ public function getLastResponse(): ?ResponseInterface /** * Get the HTTP client. - * - * @return \Http\Client\Common\HttpMethodsClientInterface */ public function getHttpClient(): HttpMethodsClientInterface { @@ -248,8 +184,6 @@ public function getHttpClient(): HttpMethodsClientInterface /** * Get the HTTP client builder. - * - * @return \Bitbucket\HttpClient\Builder */ protected function getHttpClientBuilder(): Builder { diff --git a/src/HttpClient/Builder.php b/src/HttpClient/Builder.php index a163060..152a1f2 100644 --- a/src/HttpClient/Builder.php +++ b/src/HttpClient/Builder.php @@ -36,72 +36,33 @@ */ final class Builder { - /** - * The object that sends HTTP messages. - * - * @var \Psr\Http\Client\ClientInterface - */ - private $httpClient; - - /** - * The HTTP request factory. - * - * @var \Psr\Http\Message\RequestFactoryInterface - */ - private $requestFactory; + private readonly ClientInterface $httpClient; + private readonly RequestFactoryInterface $requestFactory; + private readonly StreamFactoryInterface $streamFactory; /** - * The HTTP stream factory. - * - * @var \Psr\Http\Message\StreamFactoryInterface + * @var Plugin[] */ - private $streamFactory; + private array $plugins = []; - /** - * The currently registered plugins. - * - * @var \Http\Client\Common\Plugin[] - */ - private $plugins = []; + private ?CachePlugin $cachePlugin; - /** - * The cache plugin to use. - * - * This plugin is specially treated because it has to be the very last plugin. - * - * @var \Http\Client\Common\Plugin\CachePlugin|null - */ - private $cachePlugin; + private ?HttpMethodsClientInterface $pluginClient; - /** - * A HTTP client with all our plugins. - * - * @var \Http\Client\Common\HttpMethodsClientInterface|null - */ - private $pluginClient; - - /** - * Create a new http client builder instance. - * - * @param \Psr\Http\Client\ClientInterface|null $httpClient - * @param \Psr\Http\Message\RequestFactoryInterface|null $requestFactory - * @param \Psr\Http\Message\StreamFactoryInterface|null $streamFactory - * - * @return void - */ public function __construct( - ClientInterface $httpClient = null, - RequestFactoryInterface $requestFactory = null, - StreamFactoryInterface $streamFactory = null + ?ClientInterface $httpClient = null, + ?RequestFactoryInterface $requestFactory = null, + ?StreamFactoryInterface $streamFactory = null, ) { $this->httpClient = $httpClient ?? Psr18ClientDiscovery::find(); $this->requestFactory = $requestFactory ?? Psr17FactoryDiscovery::findRequestFactory(); $this->streamFactory = $streamFactory ?? Psr17FactoryDiscovery::findStreamFactory(); + + $this->plugins = []; + $this->cachePlugin = null; + $this->pluginClient = null; } - /** - * @return \Http\Client\Common\HttpMethodsClientInterface - */ public function getHttpClient(): HttpMethodsClientInterface { if (null === $this->pluginClient) { @@ -122,10 +83,6 @@ public function getHttpClient(): HttpMethodsClientInterface /** * Add a new plugin to the end of the plugin chain. - * - * @param \Http\Client\Common\Plugin $plugin - * - * @return void */ public function addPlugin(Plugin $plugin): void { @@ -135,10 +92,6 @@ public function addPlugin(Plugin $plugin): void /** * Remove a plugin by its fully qualified class name (FQCN). - * - * @param string $fqcn - * - * @return void */ public function removePlugin(string $fqcn): void { @@ -152,11 +105,6 @@ public function removePlugin(string $fqcn): void /** * Add a cache plugin to cache responses locally. - * - * @param \Psr\Cache\CacheItemPoolInterface $cachePool - * @param array $config - * - * @return void */ public function addCache(CacheItemPoolInterface $cachePool, array $config = []): void { @@ -170,8 +118,6 @@ public function addCache(CacheItemPoolInterface $cachePool, array $config = []): /** * Remove the cache plugin. - * - * @return void */ public function removeCache(): void { diff --git a/src/HttpClient/Message/FileResource.php b/src/HttpClient/Message/FileResource.php index 3c405df..3d11887 100644 --- a/src/HttpClient/Message/FileResource.php +++ b/src/HttpClient/Message/FileResource.php @@ -13,6 +13,8 @@ namespace Bitbucket\HttpClient\Message; +use Psr\Http\Message\StreamInterface; + /** * This is the file resource class. * @@ -20,47 +22,22 @@ */ final class FileResource { - /** - * The name. - * - * @var string - */ - private $name; - - /** - * The resource. - * - * @var string|resource|\Psr\Http\Message\StreamInterface - */ - private $resource; - - /** - * The options. - * - * @var array - */ - private $options; - /** * Create a new file resource instance. * - * @param string $name - * @param string|resource|\Psr\Http\Message\StreamInterface $resource - * @param array $options + * @param string|resource|StreamInterface $resource * * @return void */ - public function __construct(string $name, $resource, array $options = []) - { - $this->name = $name; - $this->resource = $resource; - $this->options = $options; + public function __construct( + private readonly string $name, + private readonly mixed $resource, + private readonly array $options = [], + ) { } /** * Get the name. - * - * @return string */ public function getName(): string { @@ -70,7 +47,7 @@ public function getName(): string /** * Get the resource. * - * @return string|resource|\Psr\Http\Message\StreamInterface + * @return string|resource|StreamInterface */ public function getResource() { @@ -79,8 +56,6 @@ public function getResource() /** * Get the options. - * - * @return array */ public function getOptions(): array { diff --git a/src/HttpClient/Message/ResponseMediator.php b/src/HttpClient/Message/ResponseMediator.php index 5ac92e4..7b6cc48 100644 --- a/src/HttpClient/Message/ResponseMediator.php +++ b/src/HttpClient/Message/ResponseMediator.php @@ -43,13 +43,9 @@ final class ResponseMediator * * If the there is no response body, we will always return the empty array. * - * @param \Psr\Http\Message\ResponseInterface $response - * * @throws \Bitbucket\Exception\RuntimeException - * - * @return array */ - public static function getContent(ResponseInterface $response) + public static function getContent(ResponseInterface $response): array { if (204 === $response->getStatusCode()) { return []; @@ -71,8 +67,6 @@ public static function getContent(ResponseInterface $response) /** * Get the pagination data from the response. * - * @param \Psr\Http\Message\ResponseInterface $response - * * @return array */ public static function getPagination(ResponseInterface $response): array @@ -85,22 +79,13 @@ public static function getPagination(ResponseInterface $response): array } } - /** - * @param string|int $key - * - * @return bool - */ - private static function paginationFilter($key) + private static function paginationFilter(string|int $key): bool { return \in_array($key, ['size', 'page', 'pagelen', 'next', 'previous'], true); } /** * Get the error message from the response if present. - * - * @param \Psr\Http\Message\ResponseInterface $response - * - * @return string|null */ public static function getErrorMessage(ResponseInterface $response): ?string { @@ -116,10 +101,6 @@ public static function getErrorMessage(ResponseInterface $response): ?string /** * Get the error message from the error array if present. - * - * @param array $error - * - * @return string|null */ private static function getMessageFromError(array $error): ?string { @@ -145,10 +126,6 @@ private static function getMessageFromError(array $error): ?string /** * Present the detail portion of the error array. - * - * @param array $error - * - * @return string */ private static function getDetailAsString(array $error): string { diff --git a/src/HttpClient/Plugin/Authentication.php b/src/HttpClient/Plugin/Authentication.php index 32aa7aa..09cb69b 100644 --- a/src/HttpClient/Plugin/Authentication.php +++ b/src/HttpClient/Plugin/Authentication.php @@ -30,23 +30,9 @@ */ final class Authentication implements Plugin { - /** - * The authorization header. - * - * @var string - */ - private $header; + private readonly string $header; - /** - * Create a new authentication plugin instance. - * - * @param string $method - * @param string $token - * @param string|null $password - * - * @return void - */ - public function __construct(string $method, string $token, string $password = null) + public function __construct(string $method, string $token, ?string $password = null) { $this->header = self::buildAuthorizationHeader($method, $token, $password); } @@ -54,7 +40,6 @@ public function __construct(string $method, string $token, string $password = nu /** * Handle the request and return the response coming from the next callable. * - * @param \Psr\Http\Message\RequestInterface $request * @param callable(RequestInterface): Promise $next * @param callable(RequestInterface): Promise $first * @@ -70,15 +55,9 @@ public function handleRequest(RequestInterface $request, callable $next, callabl /** * Build the authentication header to be attached to the request. * - * @param string $method - * @param string $token - * @param string|null $password - * * @throws \Bitbucket\Exception\RuntimeException - * - * @return string */ - private static function buildAuthorizationHeader(string $method, string $token, string $password = null): string + private static function buildAuthorizationHeader(string $method, string $token, ?string $password = null): string { switch ($method) { case Client::AUTH_HTTP_PASSWORD: diff --git a/src/HttpClient/Plugin/ExceptionThrower.php b/src/HttpClient/Plugin/ExceptionThrower.php index 14f8cf9..d348860 100644 --- a/src/HttpClient/Plugin/ExceptionThrower.php +++ b/src/HttpClient/Plugin/ExceptionThrower.php @@ -37,7 +37,6 @@ final class ExceptionThrower implements Plugin /** * Handle the request and return the response coming from the next callable. * - * @param \Psr\Http\Message\RequestInterface $request * @param callable(RequestInterface): Promise $next * @param callable(RequestInterface): Promise $first * @@ -59,9 +58,6 @@ public function handleRequest(RequestInterface $request, callable $next, callabl /** * Create an exception from a status code and error message. * - * @param int $status - * @param string $message - * * @return \Bitbucket\Exception\ErrorException|\Bitbucket\Exception\RuntimeException */ private static function createException(int $status, string $message): ExceptionInterface diff --git a/src/HttpClient/Plugin/History.php b/src/HttpClient/Plugin/History.php index 2bf7ef2..0a72cf3 100644 --- a/src/HttpClient/Plugin/History.php +++ b/src/HttpClient/Plugin/History.php @@ -28,17 +28,15 @@ */ final class History implements Journal { - /** - * The last response. - * - * @var \Psr\Http\Message\ResponseInterface|null - */ - private $lastResponse; + private ?ResponseInterface $lastResponse; + + public function __construct() + { + $this->lastResponse = null; + } /** * Get the last response. - * - * @return \Psr\Http\Message\ResponseInterface|null */ public function getLastResponse(): ?ResponseInterface { @@ -47,11 +45,6 @@ public function getLastResponse(): ?ResponseInterface /** * Record a successful call. - * - * @param \Psr\Http\Message\RequestInterface $request - * @param \Psr\Http\Message\ResponseInterface $response - * - * @return void */ public function addSuccess(RequestInterface $request, ResponseInterface $response): void { @@ -60,11 +53,6 @@ public function addSuccess(RequestInterface $request, ResponseInterface $respons /** * Record a failed call. - * - * @param \Psr\Http\Message\RequestInterface $request - * @param \Psr\Http\Client\ClientExceptionInterface $exception - * - * @return void */ public function addFailure(RequestInterface $request, ClientExceptionInterface $exception): void { diff --git a/src/HttpClient/Util/JsonArray.php b/src/HttpClient/Util/JsonArray.php index dc5280b..339c81e 100644 --- a/src/HttpClient/Util/JsonArray.php +++ b/src/HttpClient/Util/JsonArray.php @@ -27,11 +27,7 @@ final class JsonArray /** * Decode a JSON string into a PHP array. * - * @param string $json - * * @throws \Bitbucket\Exception\RuntimeException - * - * @return array */ public static function decode(string $json): array { @@ -52,11 +48,7 @@ public static function decode(string $json): array /** * Encode a PHP array into a JSON string. * - * @param array $value - * * @throws \Bitbucket\Exception\RuntimeException - * - * @return string */ public static function encode(array $value): string { diff --git a/src/HttpClient/Util/QueryStringBuilder.php b/src/HttpClient/Util/QueryStringBuilder.php index fb172d3..8a2aaf4 100644 --- a/src/HttpClient/Util/QueryStringBuilder.php +++ b/src/HttpClient/Util/QueryStringBuilder.php @@ -24,10 +24,6 @@ final class QueryStringBuilder { /** * Encode a query as a query string according to RFC 3986. - * - * @param array $query - * - * @return string */ public static function build(array $query): string { diff --git a/src/HttpClient/Util/UriBuilder.php b/src/HttpClient/Util/UriBuilder.php index 3261af2..a537d13 100644 --- a/src/HttpClient/Util/UriBuilder.php +++ b/src/HttpClient/Util/UriBuilder.php @@ -26,10 +26,6 @@ final class UriBuilder { /** * Build a URI from the given parts. - * - * @param string ...$parts - * - * @return string */ public static function build(string ...$parts): string { @@ -47,10 +43,6 @@ public static function build(string ...$parts): string /** * Append a URI separator to the given URI. - * - * @param string $uri - * - * @return string */ public static function appendSeparator(string $uri): string { diff --git a/src/ResultPager.php b/src/ResultPager.php index faf33be..dcc5f1d 100644 --- a/src/ResultPager.php +++ b/src/ResultPager.php @@ -36,36 +36,16 @@ final class ResultPager implements ResultPagerInterface */ private const PER_PAGE = 50; - /** - * The client to use for pagination. - * - * @var Client - */ - private $client; + private readonly Client $client; - /** - * The number of entries to request per page. - * - * @var int - */ - private $perPage; + private readonly int $perPage; /** - * The pagination result from the API. - * * @var array */ - private $pagination; + private array $pagination; - /** - * Create a new result pager instance. - * - * @param Client $client - * @param int|null $perPage - * - * @return void - */ - public function __construct(Client $client, int $perPage = null) + public function __construct(Client $client, ?int $perPage = null) { if (null !== $perPage && ($perPage < 1 || $perPage > 50)) { throw new ValueError(\sprintf('%s::__construct(): Argument #2 ($perPage) must be between 1 and 50, or null', self::class)); @@ -79,13 +59,7 @@ public function __construct(Client $client, int $perPage = null) /** * Fetch a single result from an api call. * - * @param \Bitbucket\Api\AbstractApi $api - * @param string $method - * @param array $parameters - * * @throws \Http\Client\Exception - * - * @return array */ public function fetch(AbstractApi $api, string $method, array $parameters = []): array { @@ -104,13 +78,7 @@ public function fetch(AbstractApi $api, string $method, array $parameters = []): /** * Fetch all results from an api call. * - * @param \Bitbucket\Api\AbstractApi $api - * @param string $method - * @param array $parameters - * * @throws \Http\Client\Exception - * - * @return array */ public function fetchAll(AbstractApi $api, string $method, array $parameters = []): array { @@ -120,13 +88,7 @@ public function fetchAll(AbstractApi $api, string $method, array $parameters = [ /** * Lazily fetch all results from an api call. * - * @param \Bitbucket\Api\AbstractApi $api - * @param string $method - * @param array $parameters - * * @throws \Http\Client\Exception - * - * @return \Generator */ public function fetchAllLazy(AbstractApi $api, string $method, array $parameters = []): Generator { @@ -145,8 +107,6 @@ public function fetchAllLazy(AbstractApi $api, string $method, array $parameters /** * Check to determine the availability of a next page. - * - * @return bool */ public function hasNext(): bool { @@ -157,8 +117,6 @@ public function hasNext(): bool * Fetch the next page. * * @throws \Http\Client\Exception - * - * @return array */ public function fetchNext(): array { @@ -167,8 +125,6 @@ public function fetchNext(): array /** * Check to determine the availability of a previous page. - * - * @return bool */ public function hasPrevious(): bool { @@ -179,8 +135,6 @@ public function hasPrevious(): bool * Fetch the previous page. * * @throws \Http\Client\Exception - * - * @return array */ public function fetchPrevious(): array { @@ -189,8 +143,6 @@ public function fetchPrevious(): array /** * Refresh the pagination property. - * - * @return void */ private function postFetch(): void { @@ -200,11 +152,7 @@ private function postFetch(): void } /** - * @param string $key - * * @throws \Http\Client\Exception - * - * @return array */ private function get(string $key): array { @@ -223,12 +171,6 @@ private function get(string $key): array return $content; } - /** - * @param \Bitbucket\Api\AbstractApi $api - * @param int $perPage - * - * @return \Bitbucket\Api\AbstractApi - */ private static function bindPerPage(AbstractApi $api, int $perPage): AbstractApi { /** @var Closure(AbstractApi): AbstractApi */ @@ -244,11 +186,7 @@ private static function bindPerPage(AbstractApi $api, int $perPage): AbstractApi } /** - * @param array $result - * * @throws \Bitbucket\Exception\RuntimeException - * - * @return array */ private static function getValues(array $result): array { diff --git a/src/ResultPagerInterface.php b/src/ResultPagerInterface.php index 77863ba..f53c736 100644 --- a/src/ResultPagerInterface.php +++ b/src/ResultPagerInterface.php @@ -28,46 +28,26 @@ interface ResultPagerInterface /** * Fetch a single result from an api call. * - * @param \Bitbucket\Api\AbstractApi $api - * @param string $method - * @param array $parameters - * * @throws \Http\Client\Exception - * - * @return array */ public function fetch(AbstractApi $api, string $method, array $parameters = []): array; /** * Fetch all results from an api call. * - * @param \Bitbucket\Api\AbstractApi $api - * @param string $method - * @param array $parameters - * * @throws \Http\Client\Exception - * - * @return array */ public function fetchAll(AbstractApi $api, string $method, array $parameters = []): array; /** * Lazily fetch all results from an api call. * - * @param \Bitbucket\Api\AbstractApi $api - * @param string $method - * @param array $parameters - * * @throws \Http\Client\Exception - * - * @return \Generator */ public function fetchAllLazy(AbstractApi $api, string $method, array $parameters = []): Generator; /** * Check to determine the availability of a next page. - * - * @return bool */ public function hasNext(): bool; @@ -75,15 +55,11 @@ public function hasNext(): bool; * Fetch the next page. * * @throws \Http\Client\Exception - * - * @return array */ public function fetchNext(): array; /** * Check to determine the availability of a previous page. - * - * @return bool */ public function hasPrevious(): bool; @@ -91,8 +67,6 @@ public function hasPrevious(): bool; * Fetch the previous page. * * @throws \Http\Client\Exception - * - * @return array */ public function fetchPrevious(): array; } diff --git a/tests/ApiUrlTest.php b/tests/ApiUrlTest.php new file mode 100644 index 0000000..d41b7b3 --- /dev/null +++ b/tests/ApiUrlTest.php @@ -0,0 +1,90 @@ +httpClient = new MockClient(); + $this->client = new Client(new Builder($this->httpClient)); + } + + #[DataProvider('dataProvider')] + public function testWorkspaceSrcShowUri(string $fileName): void + { + $this->client->repositories() + ->workspaces('my-workspace') + ->src('my-project') + ->show('main', $fileName); + + $this->assertSame( + "https://api.bitbucket.org/2.0/repositories/my-workspace/my-project/src/main/$fileName?format=meta", + (string) $this->httpClient->getLastRequest()->getUri() + ); + } + + #[DataProvider('dataProvider')] + public function testWorkspaceSrcDownloadUri(string $fileName): void + { + $this->client->repositories() + ->workspaces('my-workspace') + ->src('my-project') + ->download('main', $fileName); + + $this->assertSame( + "https://api.bitbucket.org/2.0/repositories/my-workspace/my-project/src/main/$fileName", + (string) $this->httpClient->getLastRequest()->getUri() + ); + } + + #[DataProvider('dataProvider')] + public function testWorkspaceDownloadUri(string $fileName): void + { + $this->client->repositories() + ->workspaces('my-workspace') + ->downloads('my-project') + ->download($fileName); + + $this->assertSame( + "https://api.bitbucket.org/2.0/repositories/my-workspace/my-project/downloads/$fileName", + (string) $this->httpClient->getLastRequest()->getUri() + ); + } + + #[DataProvider('dataProvider')] + public function testWorkspaceRemoveUri(string $fileName): void + { + $this->client->repositories() + ->workspaces('my-workspace') + ->downloads('my-project') + ->remove($fileName); + + $this->assertSame( + "https://api.bitbucket.org/2.0/repositories/my-workspace/my-project/downloads/$fileName", + (string) $this->httpClient->getLastRequest()->getUri() + ); + } + + public static function dataProvider(): array + { + return [ + 'File in root' => ['README.md'], + 'File in subdirectory' => ['docs/contributing/CODE_OF_CONDUCT.md'], + ]; + } +} diff --git a/tests/MockedClient.php b/tests/MockedClient.php index 8778516..1e302d4 100644 --- a/tests/MockedClient.php +++ b/tests/MockedClient.php @@ -25,31 +25,19 @@ */ final class MockedClient { - /** - * @param \Psr\Http\Message\ResponseInterface $response - * - * @return \Bitbucket\Client - */ - public static function create(ResponseInterface $response) + public static function create(ResponseInterface $response): Client { $client = new MockClient(self::createResponseFactory($response)); return new Client(new Builder($client)); } - /** - * @param \Psr\Http\Message\ResponseInterface $response - * - * @return \Psr\Http\Message\ResponseFactoryInterface - */ - private static function createResponseFactory(ResponseInterface $response) + private static function createResponseFactory(ResponseInterface $response): ResponseFactoryInterface { return new class($response) implements ResponseFactoryInterface { - private $response; - - public function __construct(ResponseInterface $response) - { - $this->response = $response; + public function __construct( + private readonly ResponseInterface $response, + ) { } public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface diff --git a/tests/Resource.php b/tests/Resource.php index a1df3ee..cf56851 100644 --- a/tests/Resource.php +++ b/tests/Resource.php @@ -18,12 +18,7 @@ */ final class Resource { - /** - * @param string $path - * - * @return string - */ - public static function get(string $path) + public static function get(string $path): string { $content = @\file_get_contents(\sprintf('%s/Resource/%s', __DIR__, $path)); diff --git a/tests/Response/ProjectsCreateResponse.php b/tests/Response/ProjectsCreateResponse.php index c0faa45..6033d05 100644 --- a/tests/Response/ProjectsCreateResponse.php +++ b/tests/Response/ProjectsCreateResponse.php @@ -22,10 +22,7 @@ */ final class ProjectsCreateResponse { - /** - * @return \Psr\Http\Message\ResponseInterface - */ - public static function create() + public static function create(): \Psr\Http\Message\ResponseInterface { $body = Resource::get('projects-create-success.json'); diff --git a/tests/Response/ProjectsListResponse.php b/tests/Response/ProjectsListResponse.php index e3cf60b..8e12a11 100644 --- a/tests/Response/ProjectsListResponse.php +++ b/tests/Response/ProjectsListResponse.php @@ -22,10 +22,7 @@ */ final class ProjectsListResponse { - /** - * @return \Psr\Http\Message\ResponseInterface - */ - public static function create() + public static function create(): \Psr\Http\Message\ResponseInterface { $body = Resource::get('projects-list-success.json'); diff --git a/tests/Response/ProjectsRemoveResponse.php b/tests/Response/ProjectsRemoveResponse.php index 97b1e0f..b57c738 100644 --- a/tests/Response/ProjectsRemoveResponse.php +++ b/tests/Response/ProjectsRemoveResponse.php @@ -22,10 +22,7 @@ */ final class ProjectsRemoveResponse { - /** - * @return \Psr\Http\Message\ResponseInterface - */ - public static function create() + public static function create(): \Psr\Http\Message\ResponseInterface { $body = Resource::get('projects-remove-success.json'); diff --git a/tests/Response/ProjectsShowResponse.php b/tests/Response/ProjectsShowResponse.php index bc7539e..b3d466d 100644 --- a/tests/Response/ProjectsShowResponse.php +++ b/tests/Response/ProjectsShowResponse.php @@ -22,10 +22,7 @@ */ final class ProjectsShowResponse { - /** - * @return \Psr\Http\Message\ResponseInterface - */ - public static function create() + public static function create(): \Psr\Http\Message\ResponseInterface { $body = Resource::get('projects-show-success.json'); diff --git a/tests/Response/ProjectsUpdateResponse.php b/tests/Response/ProjectsUpdateResponse.php index ae51b41..ffa983f 100644 --- a/tests/Response/ProjectsUpdateResponse.php +++ b/tests/Response/ProjectsUpdateResponse.php @@ -22,10 +22,7 @@ */ final class ProjectsUpdateResponse { - /** - * @return \Psr\Http\Message\ResponseInterface - */ - public static function create() + public static function create(): \Psr\Http\Message\ResponseInterface { $body = Resource::get('projects-update-success.json'); diff --git a/tests/Response/WorkspacesShowResponse.php b/tests/Response/WorkspacesShowResponse.php index d138be5..1aa7c26 100644 --- a/tests/Response/WorkspacesShowResponse.php +++ b/tests/Response/WorkspacesShowResponse.php @@ -22,10 +22,7 @@ */ final class WorkspacesShowResponse { - /** - * @return \Psr\Http\Message\ResponseInterface - */ - public static function create() + public static function create(): \Psr\Http\Message\ResponseInterface { $body = Resource::get('workspaces-show-success.json'); diff --git a/vendor-bin/phpstan/composer.json b/vendor-bin/phpstan/composer.json index 88a5f74..a1bd73c 100644 --- a/vendor-bin/phpstan/composer.json +++ b/vendor-bin/phpstan/composer.json @@ -1,11 +1,9 @@ { "require": { "php": "^8.1", - "phpstan/phpstan": "1.10.3", - "phpstan/phpstan-deprecation-rules": "1.1.2", - "phpstan/phpstan-strict-rules": "1.5.0", - "thecodingmachine/phpstan-strict-rules": "1.0.0", - "ergebnis/phpstan-rules": "1.0.0" + "phpstan/phpstan": "2.1.6", + "phpstan/phpstan-deprecation-rules": "2.0.1", + "phpstan/phpstan-strict-rules": "2.0.3" }, "config": { "preferred-install": "dist" diff --git a/vendor-bin/phpunit/composer.json b/vendor-bin/phpunit/composer.json index 59819b4..21464a1 100644 --- a/vendor-bin/phpunit/composer.json +++ b/vendor-bin/phpunit/composer.json @@ -1,7 +1,7 @@ { "require": { - "php": "^7.4.15 || ^8.0.2", - "phpunit/phpunit": "^9.6.3 || ^10.0.12" + "php": "^8.1", + "phpunit/phpunit": "^10.5.45 || ^11.5.9" }, "config": { "preferred-install": "dist" diff --git a/vendor-bin/psalm/composer.json b/vendor-bin/psalm/composer.json index 5060e69..feebf50 100644 --- a/vendor-bin/psalm/composer.json +++ b/vendor-bin/psalm/composer.json @@ -1,7 +1,7 @@ { "require": { "php": "^8.1", - "psalm/phar": "5.7.6" + "psalm/phar": "5.26.1" }, "config": { "preferred-install": "dist"