From d8754263dcc4cf3b54c3eb9de13d38c14d8fd81c Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 11 Mar 2024 13:46:29 +0700 Subject: [PATCH] Use latest RectorConfig::configure() syntax --- rector.php | 33 ++++++++++++-------------- spec/Service/ClientAuthServiceSpec.php | 8 +++---- spec/Service/ClientServiceSpec.php | 12 +++++----- 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/rector.php b/rector.php index b876f3c..8ec1591 100644 --- a/rector.php +++ b/rector.php @@ -8,26 +8,24 @@ use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; -return static function (RectorConfig $rectorConfig): void { - $rectorConfig->sets([ - SetList::DEAD_CODE, - SetList::CODING_STYLE, - SetList::CODE_QUALITY, - SetList::EARLY_RETURN, - SetList::NAMING, - LevelSetList::UP_TO_PHP_80, - SetList::TYPE_DECLARATION, - ]); - - $rectorConfig->paths([ +return RectorConfig::configure() + ->withPreparedSets( + deadCode: true, + codingStyle: true, + codeQuality: true, + earlyReturn: true, + naming: true, + typeDeclarations: true + ) + ->withPhpSets(php80: true) + ->withPaths([ __DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/spec', - __DIR__ . '/rector.php', - ]); - $rectorConfig->importNames(); - - $rectorConfig->skip([ + ]) + ->withRootFiles() + ->withImportNames() + ->withSkip([ StaticArrowFunctionRector::class => [ __DIR__ . '/spec', ], @@ -35,4 +33,3 @@ __DIR__ . '/spec', ], ]); -}; diff --git a/spec/Service/ClientAuthServiceSpec.php b/spec/Service/ClientAuthServiceSpec.php index 09a8a67..5d48ef6 100644 --- a/spec/Service/ClientAuthServiceSpec.php +++ b/spec/Service/ClientAuthServiceSpec.php @@ -12,7 +12,7 @@ use Laminas\Http\Response; use Laminas\Json\Json; -describe('ClientAuthService', function () { +describe('ClientAuthService', function (): void { beforeAll(function (): void { $this->httpClient = Double::instance(['extends' => Client::class]); $this->service = new ClientAuthService( @@ -62,7 +62,7 @@ }); - describe('->callAPI', function () { + describe('->callAPI', function (): void { it('define grant_type = client_credentials will not set username form-data', function (): void { @@ -246,7 +246,7 @@ }); - it('set not success on Http Client send got RuntimeException', function () { + it('set not success on Http Client send got RuntimeException', function (): void { $data = [ 'api-route-segment' => '/oauth', @@ -263,7 +263,7 @@ 'Content-type' => 'application/json' ]; - allow($this->httpClient)->toReceive('send')->andRun(function () { + allow($this->httpClient)->toReceive('send')->andRun(function (): void { throw new RuntimeException(); }); diff --git a/spec/Service/ClientServiceSpec.php b/spec/Service/ClientServiceSpec.php index f06f92d..e1ba25e 100644 --- a/spec/Service/ClientServiceSpec.php +++ b/spec/Service/ClientServiceSpec.php @@ -13,7 +13,7 @@ use Laminas\Http\Response; use Laminas\Json\Json; -describe('ClientService', function () { +describe('ClientService', function (): void { beforeAll(function (): void { $this->httpClient = Double::instance(['extends' => Client::class]); $this->service = new ClientService( @@ -96,7 +96,7 @@ }); - describe('->callAPI', function () { + describe('->callAPI', function (): void { it('return "ClientResult" instance with success = true when status code = 200 and body != ""', function (): void { $data = [ @@ -355,7 +355,7 @@ }); - it('return "ClientResult" instance with success = false when client->send() throw exception', function () { + it('return "ClientResult" instance with success = false when client->send() throw exception', function (): void { $data = [ 'api-route-segment' => '/api', @@ -375,7 +375,7 @@ expect($this->httpClient)->toReceive('setHeaders')->with($headers); expect($this->httpClient)->toReceive('setUri')->with('http://api.host.url/api'); expect($this->httpClient)->toReceive('setMethod')->with($data['form-request-method']); - allow($this->httpClient)->toReceive('send')->andRun(function () { + allow($this->httpClient)->toReceive('send')->andRun(function (): void { throw new RuntimeException(); }); @@ -649,7 +649,7 @@ }); - it('set not success on Http Client send got RuntimeException', function () { + it('set not success on Http Client send got RuntimeException', function (): void { $data = [ 'api-route-segment' => '/api', @@ -662,7 +662,7 @@ 'Content-type' => 'application/json' ]; - allow($this->httpClient)->toReceive('send')->andRun(function () { + allow($this->httpClient)->toReceive('send')->andRun(function (): void { throw new RuntimeException(); });