Skip to content

Commit

Permalink
Friends of PHP code lint fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
SecondeJK committed Oct 14, 2024
1 parent 938c437 commit 0f67d02
Show file tree
Hide file tree
Showing 22 changed files with 414 additions and 109 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"softcreatr/jsonpath": "^0.7 || ^0.8",
"phpspec/prophecy-phpunit": "^2.0",
"rector/rector": "^1.1",
"phpstan/phpstan": "^1.10"
"phpstan/phpstan": "^1.10",
},
"config": {
"optimize-autoloader": true,
Expand Down
4 changes: 2 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function __construct(

// Additional utility classes
APIResource::class => APIResource::class,
Client::class => fn() => $this
Client::class => fn () => $this
];

if (class_exists('Vonage\Video\ClientFactory')) {
Expand All @@ -231,7 +231,7 @@ public function __construct(
// Disable throwing E_USER_DEPRECATED notices by default, the user can turn it on during development
if (array_key_exists('show_deprecations', $this->options) && ($this->options['show_deprecations'] == true)) {
set_error_handler(
static fn(int $errno, string $errstr, string $errfile = null, int $errline = null, array $errorcontext = null) => true,
static fn (int $errno, string $errstr, string $errfile = null, int $errline = null, array $errorcontext = null) => true,
E_USER_DEPRECATED
);
}
Expand Down
9 changes: 7 additions & 2 deletions src/Client/APIResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,13 @@ public function delete(string $id, array $headers = []): ?array
* @throws ClientExceptionInterface
* @throws Exception\Exception
*/
public function get($id, array $query = [], array $headers = [], bool $jsonResponse = true, bool $uriOverride = false)
{
public function get(
$id,
array $query = [],
array $headers = [],
bool $jsonResponse = true,
bool $uriOverride = false
) {
$uri = $this->getBaseUrl() . $this->baseUri . '/' . $id;

// This is a necessary hack if you want to fetch a totally different URL but use Vonage Auth
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Credentials/Handler/HandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ interface HandlerInterface
/**
* Add authentication to a request
*/
function __invoke(RequestInterface $request, CredentialsInterface $credentials): RequestInterface;
public function __invoke(RequestInterface $request, CredentialsInterface $credentials): RequestInterface;
}
8 changes: 6 additions & 2 deletions src/Client/Exception/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@

class Validation extends Request
{
public function __construct(string $message = '', int $code = 0, Throwable $previous = null, private readonly array $errors = [])
{
public function __construct(
string $message = '',
int $code = 0,
Throwable $previous = null,
private readonly array $errors = []
) {
parent::__construct($message, $code, $previous);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Conversation/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function listMembersByConversationId(
?ListMembersFilter $filter = null
): IterableAPICollection {
$api = clone $this->getAPIResource();
$api->setBaseUrl('https://api.nexmo.com/v1/users');
$api->setBaseUrl('https://api.nexmo.com/v1/users/');
$api->setCollectionName('members');
$response = $api->search($filter, $conversationId . '/members');
$response->setHasPagination(true);
Expand Down
2 changes: 1 addition & 1 deletion src/Meetings/Room.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function fromArray(array $data): static

public function toArray(): array
{
return array_filter($this->data, static fn($value) => $value !== '');
return array_filter($this->data, static fn ($value) => $value !== '');
}

public function __get($value)
Expand Down
2 changes: 1 addition & 1 deletion src/Numbers/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function purchase($number, ?string $country = null): void
'msisdn' => $number->getMsisdn(),
'country' => $number->getCountry()
];
// Evil else that will be removed in the next major version.
// Evil else that will be removed in the next major version.
} else {
$body = [
'msisdn' => $number,
Expand Down
2 changes: 1 addition & 1 deletion src/ProactiveConnect/Objects/ManualList.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,6 @@ public function toArray(): array
'attributes' => $this->getAttributes() ?: null
];

return array_filter($returnArray, fn($value) => $value !== null);
return array_filter($returnArray, fn ($value) => $value !== null);
}
}
2 changes: 1 addition & 1 deletion src/ProactiveConnect/Objects/SalesforceList.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,6 @@ public function toArray(): array
'attributes' => $this->getAttributes() ?: null
];

return array_filter($returnArray, fn($value) => $value !== null);
return array_filter($returnArray, fn ($value) => $value !== null);
}
}
16 changes: 11 additions & 5 deletions src/Subaccount/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function getSubaccounts(string $apiKey): array
$hydrator->setPrototype(new Account());
$subaccounts = $collection->getPageData()['_embedded'][$api->getCollectionName()];

return array_map(fn($item) => $hydrator->hydrate($item), $subaccounts);
return array_map(fn ($item) => $hydrator->hydrate($item), $subaccounts);
}

public function createSubaccount(string $apiKey, Account $account): ?array
Expand All @@ -64,14 +64,20 @@ public function createSubaccount(string $apiKey, Account $account): ?array

public function makeBalanceTransfer(TransferBalanceRequest $transferRequest): BalanceTransfer
{
$response = $this->api->create($transferRequest->toArray(), '/' . $transferRequest->getApiKey() . '/balance-transfers');
$response = $this->api->create(
$transferRequest->toArray(),
'/' . $transferRequest->getApiKey() . '/balance-transfers'
);

return (new BalanceTransfer())->fromArray($response);
}

public function makeCreditTransfer(TransferCreditRequest $transferRequest): CreditTransfer
{
$response = $this->api->create($transferRequest->toArray(), '/' . $transferRequest->getApiKey() . '/credit-transfers');
$response = $this->api->create(
$transferRequest->toArray(),
'/' . $transferRequest->getApiKey() . '/credit-transfers'
);
return (new CreditTransfer())->fromArray($response);
}

Expand All @@ -92,7 +98,7 @@ public function getCreditTransfers(string $apiKey, FilterInterface $filter = nul
$hydrator->setPrototype(new CreditTransfer());
$transfers = $response['_embedded']['credit_transfers'];

return array_map(fn($item) => $hydrator->hydrate($item), $transfers);
return array_map(fn ($item) => $hydrator->hydrate($item), $transfers);
}

public function getBalanceTransfers(string $apiKey, FilterInterface $filter = null): mixed
Expand All @@ -107,7 +113,7 @@ public function getBalanceTransfers(string $apiKey, FilterInterface $filter = nu
$hydrator->setPrototype(new BalanceTransfer());
$transfers = $response['_embedded']['balance_transfers'];

return array_map(fn($item) => $hydrator->hydrate($item), $transfers);
return array_map(fn ($item) => $hydrator->hydrate($item), $transfers);
}

public function makeNumberTransfer(NumberTransferRequest $request): ?array
Expand Down
2 changes: 1 addition & 1 deletion src/Verify2/Request/BaseVerifyRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function setBrand(string $brand): static

public function getWorkflows(): array
{
return array_map(static fn($workflow) => $workflow->toArray(), $this->workflows);
return array_map(static fn ($workflow) => $workflow->toArray(), $this->workflows);
}

public function addWorkflow(VerificationWorkflow $verificationWorkflow): static
Expand Down
45 changes: 38 additions & 7 deletions test/Client/Credentials/Handler/GnpHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ public function testWillReturnSimSwapCheckWithValidCredentials(): void
);

$this->assertRequestFormBodyContains('login_hint', 'tel:+447700900000', $request);
$this->assertRequestFormBodyContains('scope', 'dpv:FraudPreventionAndDetection#check-sim-swap', $request);
$this->assertRequestFormBodyContains(
'scope',
'dpv:FraudPreventionAndDetection#check-sim-swap',
$request
);

$this->assertEquals(
'Bearer ',
Expand All @@ -79,8 +83,17 @@ public function testWillReturnSimSwapCheckWithValidCredentials(): void
$uriString
);

$this->assertRequestFormBodyContains('grant_type', 'urn:openid:params:grant-type:ciba', $request);
$this->assertRequestFormBodyContains('auth_req_id', '0dadaeb4-7c79-4d39-b4b0-5a6cc08bf537', $request);
$this->assertRequestFormBodyContains(
'grant_type',
'urn:openid:params:grant-type:ciba',
$request
);

$this->assertRequestFormBodyContains(
'auth_req_id',
'0dadaeb4-7c79-4d39-b4b0-5a6cc08bf537',
$request
);

return true;
}
Expand Down Expand Up @@ -118,8 +131,17 @@ public function testWillReturnSimSwapDateWithValidCredentials(): void
$uriString
);

$this->assertRequestFormBodyContains('login_hint', 'tel:+447700900000', $request);
$this->assertRequestFormBodyContains('scope', 'dpv:FraudPreventionAndDetection#check-sim-swap', $request);
$this->assertRequestFormBodyContains(
'login_hint',
'tel:+447700900000',
$request
);

$this->assertRequestFormBodyContains(
'scope',
'dpv:FraudPreventionAndDetection#check-sim-swap',
$request
);

$this->assertEquals(
'Bearer ',
Expand All @@ -139,8 +161,17 @@ public function testWillReturnSimSwapDateWithValidCredentials(): void
$uriString
);

$this->assertRequestFormBodyContains('grant_type', 'urn:openid:params:grant-type:ciba', $request);
$this->assertRequestFormBodyContains('auth_req_id', '0dadaeb4-7c79-4d39-b4b0-5a6cc08bf537', $request);
$this->assertRequestFormBodyContains(
'grant_type',
'urn:openid:params:grant-type:ciba',
$request
);

$this->assertRequestFormBodyContains(
'auth_req_id',
'0dadaeb4-7c79-4d39-b4b0-5a6cc08bf537',
$request
);

return true;
}
Expand Down
Loading

0 comments on commit 0f67d02

Please sign in to comment.