Skip to content

Commit

Permalink
Linting Scrub (#516)
Browse files Browse the repository at this point in the history
* Code sniffer auto fixes

* Friends of PHP code lint fixer

* Whoops, fix composer.json
  • Loading branch information
SecondeJK authored Oct 14, 2024
1 parent 9c2cd96 commit 4158951
Show file tree
Hide file tree
Showing 69 changed files with 501 additions and 189 deletions.
1 change: 1 addition & 0 deletions src/Account/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Vonage\Entity\JsonResponseTrait;
use Vonage\Entity\JsonSerializableTrait;
use Vonage\Entity\NoRequestResponseTrait;

use function array_key_exists;
use function ltrim;
use function preg_replace;
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
1 change: 1 addition & 0 deletions src/Client/APIClient.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Vonage\Client;
Expand Down
1 change: 1 addition & 0 deletions src/Client/APIExceptionHandler.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Vonage\Client;
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/BasicHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ public function __invoke(RequestInterface $request, CredentialsInterface $creden

return $request->withHeader('Authorization', 'Basic ' . $cx);
}
}
}
2 changes: 1 addition & 1 deletion src/Client/Credentials/Handler/BasicQueryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ public function __invoke(RequestInterface $request, CredentialsInterface $creden

return $request->withUri($request->getUri()->withQuery(http_build_query($query)));
}
}
}
2 changes: 1 addition & 1 deletion src/Client/Credentials/Handler/GnpKeypairHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ public function __invoke(RequestInterface $request, CredentialsInterface $creden

return $request->withHeader('Authorization', 'Bearer ' . $token->toString());
}
}
}
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;
}
2 changes: 1 addition & 1 deletion src/Client/Credentials/Handler/KeypairHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ public function __invoke(RequestInterface $request, CredentialsInterface $creden

return $request->withHeader('Authorization', 'Bearer ' . $token->toString());
}
}
}
2 changes: 1 addition & 1 deletion src/Client/Credentials/Handler/TokenBodyFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ public function __invoke(RequestInterface $request, CredentialsInterface $creden

return $request;
}
}
}
2 changes: 1 addition & 1 deletion src/Client/Credentials/Handler/TokenQueryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ public function __invoke(RequestInterface $request, CredentialsInterface $creden

return $request;
}
}
}
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
3 changes: 1 addition & 2 deletions src/Client/Factory/MapFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public function __construct(
* Vonage Client
*/
protected Client $client
)
{
) {
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/Client/InvalidResponseException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace Vonage\Client;
Expand Down
1 change: 0 additions & 1 deletion src/Client/Request/RequestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

interface RequestInterface
{

public function getParams(): array;

public function getURI(): string;
Expand Down
10 changes: 6 additions & 4 deletions src/Client/Signature.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ class Signature implements \Stringable
* @throws ClientException
*/
public function __construct(/**
* Params to Sign
*/
protected array $params, $secret, $signatureMethod)
{
* Params to Sign
*/
protected array $params,
$secret,
$signatureMethod
) {
$this->signed = $params;

if (!isset($this->signed['timestamp'])) {
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
1 change: 0 additions & 1 deletion src/Entity/Filter/EmptyFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

class EmptyFilter implements FilterInterface
{

public function getQuery(): array
{
return [];
Expand Down
1 change: 1 addition & 0 deletions src/Insights/Basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Vonage\Insights;

use Vonage\Entity\Hydrator\ArrayHydrateInterface;

class Basic implements ArrayHydrateInterface
{
protected array $data = [];
Expand Down
1 change: 0 additions & 1 deletion src/Meetings/ExceptionErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

use Vonage\Client\Exception\Conflict;
use Vonage\Client\Exception\Credentials;
use Vonage\Client\Exception\NotFound;
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/Messages/Channel/MMS/MMSImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ public function toArray(): array

return $returnArray;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

class InvalidCategoryException extends \Exception
{
}
}
2 changes: 1 addition & 1 deletion src/Messages/Channel/Messenger/MessengerVideo.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ public function toArray(): array

return $returnArray;
}
}
}
2 changes: 1 addition & 1 deletion src/Messages/Channel/RCS/RcsInvalidTtlException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

class RcsInvalidTtlException extends \Exception
{
}
}
8 changes: 4 additions & 4 deletions src/Messages/Channel/Viber/ViberImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public function toArray(): array
$returnArray['image'] = $this->image->toArray();

if ($this->requiresViberServiceObject()) {
$this->getCategory() ? $returnArray['viber_service']['category'] = $this->getCategory(): null;
$this->getTtl() ? $returnArray['viber_service']['ttl'] = $this->getTtl(): null;
$this->getType() ? $returnArray['viber_service']['type'] = $this->getType(): null;
$this->getAction() ? $returnArray['viber_service']['action'] = $this->getAction()->toArray(): null;
$this->getCategory() ? $returnArray['viber_service']['category'] = $this->getCategory() : null;
$this->getTtl() ? $returnArray['viber_service']['ttl'] = $this->getTtl() : null;
$this->getType() ? $returnArray['viber_service']['type'] = $this->getType() : null;
$this->getAction() ? $returnArray['viber_service']['action'] = $this->getAction()->toArray() : null;
}

return array_filter($returnArray);
Expand Down
8 changes: 4 additions & 4 deletions src/Messages/Channel/Viber/ViberText.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public function toArray(): array
$returnArray['text'] = $this->getText();

if ($this->requiresViberServiceObject()) {
$this->getCategory() ? $returnArray['viber_service']['category'] = $this->getCategory(): null;
$this->getTtl() ? $returnArray['viber_service']['ttl'] = $this->getTtl(): null;
$this->getType() ? $returnArray['viber_service']['type'] = $this->getType(): null;
$this->getAction() ? $returnArray['viber_service']['action'] = $this->getAction()->toArray(): null;
$this->getCategory() ? $returnArray['viber_service']['category'] = $this->getCategory() : null;
$this->getTtl() ? $returnArray['viber_service']['ttl'] = $this->getTtl() : null;
$this->getType() ? $returnArray['viber_service']['type'] = $this->getType() : null;
$this->getAction() ? $returnArray['viber_service']['action'] = $this->getAction()->toArray() : null;
}

return array_filter($returnArray);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class StickerObject implements ArrayHydrateInterface
{
public const STICKER_URL = 'url';
public const STICKER_ID = 'id';
public const STICKER_ID = 'id';

private array $allowedTypes = [
self::STICKER_URL,
Expand Down
2 changes: 1 addition & 1 deletion src/Messages/ClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ public function __invoke(ContainerInterface $container): Client

return new Client($api);
}
}
}
2 changes: 1 addition & 1 deletion src/NumberVerification/ClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ public function __invoke(ContainerInterface $container): Client

return new Client($api);
}
}
}
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/ClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ public function __invoke(ContainerInterface $container): Client

return new Client($api);
}
}
}
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);
}
}
2 changes: 1 addition & 1 deletion src/SimSwap/ClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ public function __invoke(ContainerInterface $container): Client

return new Client($api);
}
}
}
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/Subaccount/ClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ public function __invoke(ContainerInterface $container): Client

return new Client($api);
}
}
}
2 changes: 1 addition & 1 deletion src/Subaccount/Filter/SubaccountFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ public function setSubaccount(?string $subaccount): void
{
$this->subaccount = $subaccount;
}
}
}
2 changes: 1 addition & 1 deletion src/Verify2/ClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ public function __invoke(ContainerInterface $container): Client

return new Client($api);
}
}
}
Loading

0 comments on commit 4158951

Please sign in to comment.