Skip to content

Commit 554e6b3

Browse files
authored
Merge pull request #44 from CyberfusionNL/feature/php-8
Update the code with Rector to PHP >= 8.0
2 parents ae3b86e + a29b1aa commit 554e6b3

File tree

104 files changed

+890
-1290
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+890
-1290
lines changed

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ trim_trailing_whitespace = true
1313

1414
[*.md]
1515
trim_trailing_whitespace = false
16+
17+
[*.yml]
18+
indent_size = 2

.github/workflows/ci.yml

+40-36
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,44 @@
11
name: Cluster API
22

3-
on: [push, pull_request]
3+
on: [ push, pull_request ]
44

55
jobs:
6-
cluster-api-tests:
7-
runs-on: ubuntu-latest
8-
strategy:
9-
matrix:
10-
php-versions: ['8.0', '8.1', '8.2']
11-
12-
name: PHP ${{ matrix.php-versions }}
13-
14-
steps:
15-
- name: Checkout
16-
uses: actions/checkout@v3
17-
with:
18-
repository: ${{ github.event.pull_request.head.repo.full_name }}
19-
ref: ${{ github.event.pull_request.head.ref }}
20-
21-
- name: Setup PHP
22-
uses: shivammathur/setup-php@v2
23-
with:
24-
php-version: ${{ matrix.php-versions }}
25-
extensions: mbstring, intl
26-
27-
- name: Install Dependencies
28-
run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress
29-
30-
- name: Execute tests (Unit and Feature tests) via PHPUnit
31-
run: |
32-
vendor/bin/phpunit
33-
34-
- name: Execute static analysis
35-
run: |
36-
vendor/bin/phpstan
37-
38-
- name: Execute code style check
39-
run: |
40-
vendor/bin/ecs check
6+
cluster-api-tests:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
php-versions: [ '8.0', '8.1', '8.2' ]
11+
12+
name: PHP ${{ matrix.php-versions }}
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
with:
18+
repository: ${{ github.event.pull_request.head.repo.full_name }}
19+
ref: ${{ github.event.pull_request.head.ref }}
20+
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php-versions }}
25+
extensions: mbstring, intl
26+
27+
- name: Install Dependencies
28+
run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress
29+
30+
- name: Execute tests (Unit and Feature tests) via PHPUnit
31+
run: |
32+
vendor/bin/phpunit
33+
34+
- name: Execute static analysis
35+
run: |
36+
vendor/bin/phpstan
37+
38+
- name: Execute rector
39+
run: |
40+
composer rector:check
41+
42+
- name: Execute code style check
43+
run: |
44+
vendor/bin/ecs check

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66
this package and not the cluster API. See the changelog of the [cluster API](https://cluster-api.cyberfusion.nl/redoc#section/Changelog)
77
for detailed information.
88

9+
## [1.91.0]
10+
11+
### Changed
12+
13+
- Updated the code with Rector to PHP >= 8.0.
14+
915
## [1.90.0]
1016

1117
### Changed

composer.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"require-dev": {
2121
"phpstan/phpstan": "^1.2",
2222
"phpunit/phpunit": "^9.0",
23+
"rector/rector": "^0.14.6",
2324
"symplify/easy-coding-standard": "^11.1"
2425
},
2526
"autoload": {
@@ -37,7 +38,9 @@
3738
"test-coverage": "vendor/bin/phpunit",
3839
"analyse": "vendor/bin/phpstan analyse",
3940
"ecs:check": "@php vendor/bin/ecs check",
40-
"ecs:fix": "@ecs:check --fix"
41+
"ecs:fix": "@ecs:check --fix",
42+
"rector:check": "@rector:fix --dry-run",
43+
"rector:fix": "@php vendor/bin/rector process"
4144
},
4245
"config": {
4346
"sort-packages": true

rector.php

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
6+
use Rector\Config\RectorConfig;
7+
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
8+
use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector;
9+
use Rector\Set\ValueObject\SetList;
10+
11+
return static function (RectorConfig $rectorConfig): void {
12+
$rectorConfig->sets([
13+
SetList::PHP_80,
14+
SetList::CODE_QUALITY,
15+
SetList::DEAD_CODE,
16+
]);
17+
18+
$rectorConfig->paths([
19+
__DIR__.'/src',
20+
__DIR__.'/tests',
21+
]);
22+
23+
$rectorConfig->skip([
24+
AddLiteralSeparatorToNumberRector::class,
25+
CountArrayToEmptyArrayComparisonRector::class,
26+
JsonThrowOnErrorRector::class,
27+
]);
28+
29+
$rectorConfig->importNames();
30+
$rectorConfig->importShortClasses();
31+
};

src/Client.php

+3-22
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,16 @@ class Client implements ClientContract
1717
{
1818
private const CONNECT_TIMEOUT = 60;
1919
private const TIMEOUT = 180;
20-
private const VERSION = '1.90.0';
20+
private const VERSION = '1.91.0';
2121
private const USER_AGENT = 'cyberfusion-cluster-api-client/' . self::VERSION;
22-
23-
private Configuration $configuration;
2422
private GuzzleClient $httpClient;
2523

2624
/**
27-
* Client constructor.
28-
* @param Configuration $configuration
29-
* @param bool $manuallyAuthenticate
3025
* @throws ClientException
3126
* @throws ClusterApiException
3227
*/
33-
public function __construct(Configuration $configuration, bool $manuallyAuthenticate = false)
28+
public function __construct(private Configuration $configuration, bool $manuallyAuthenticate = false)
3429
{
35-
$this->configuration = $configuration;
36-
3730
// Initialize the HTTP client
3831
$this->initHttpClient();
3932

@@ -70,16 +63,14 @@ private function initHttpClient(): void
7063

7164
/**
7265
* Determines if the API is up.
73-
*
74-
* @return bool
7566
*/
7667
private function isUp(): bool
7768
{
7869
// Retrieve the health status
7970
$healthEndpoint = new Health($this);
8071
try {
8172
$response = $healthEndpoint->get();
82-
} catch (RequestException $exception) {
73+
} catch (RequestException) {
8374
return false;
8475
}
8576

@@ -127,7 +118,6 @@ private function authenticate(): void
127118
/**
128119
* Determine if the current access token is valid.
129120
*
130-
* @return bool
131121
* @throws RequestException
132122
*/
133123
private function validateAccessToken(): bool
@@ -147,7 +137,6 @@ private function validateAccessToken(): bool
147137
/**
148138
* Retrieve the access token with the credentials. Returns null when no access token could be retrieved.
149139
*
150-
* @return string|null
151140
* @throws RequestException
152141
*/
153142
private function retrieveAccessToken(): ?string
@@ -172,8 +161,6 @@ private function retrieveAccessToken(): ?string
172161

173162
/**
174163
* Store the access token in the configuration.
175-
*
176-
* @param string $accessToken
177164
*/
178165
private function storeAccessToken(string $accessToken): void
179166
{
@@ -204,9 +191,6 @@ public function request(Request $request): Response
204191

205192
/**
206193
* Determine the request options based on the request and configuration.
207-
*
208-
* @param Request $request
209-
* @return array
210194
*/
211195
private function getRequestOptions(Request $request): array
212196
{
@@ -227,9 +211,6 @@ private function getRequestOptions(Request $request): array
227211

228212
/**
229213
* Parse the body to error models when applicable.
230-
*
231-
* @param ResponseInterface $response
232-
* @return array
233214
*/
234215
private function parseBody(ResponseInterface $response): array
235216
{

0 commit comments

Comments
 (0)