Skip to content

chore: format PHP #465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/.cache_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9.2.2
9.2.3
10 changes: 5 additions & 5 deletions clients/algoliasearch-client-php/.php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
return $config
->setUsingCache(true)
->setRules([
'array_syntax' => [ 'syntax' => 'short' ],
'array_syntax' => ['syntax' => 'short'],
'blank_line_after_namespace' => false,
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => true,
Expand Down Expand Up @@ -43,7 +43,7 @@
'phpdoc_tag_type' => true,
'protected_to_private' => true,
'@PSR2' => true,
'short_scalar_cast' => true,
'short_scalar_cast' => true,
'single_blank_line_at_eof' => false,
'single_blank_line_before_namespace' => true,
'single_quote' => true,
Expand All @@ -57,7 +57,7 @@
])
->setFinder(
PhpCsFixer\Finder::create()
->exclude('test')
->exclude('tests')
->in(__DIR__)
->exclude('test')
->exclude('tests')
->in(__DIR__)
);
86 changes: 45 additions & 41 deletions clients/algoliasearch-client-php/composer.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,49 @@
{
"name": "algolia/algoliasearch-client-php",
"description": "API powering the features of Algolia.",
"keywords": [
"openapitools",
"openapi-generator",
"openapi",
"php",
"sdk",
"rest",
"api"
],
"homepage": "https://openapi-generator.tech",
"license": "unlicense",
"authors": [
{
"name": "OpenAPI-Generator contributors",
"homepage": "https://openapi-generator.tech"
}
],
"require": {
"php": "^7.3 || ^8.0",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"guzzlehttp/guzzle": "^7.3",
"guzzlehttp/psr7": "^2.0",
"psr/http-message": "^1.0",
"psr/log": "^1.0 || ^2.0 || ^3.0",
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.5.0",
"phpunit/phpunit": "^9.3"
},
"autoload": {
"psr-4": { "Algolia\\AlgoliaSearch\\" : "lib/" },
"files": [
"lib/Http/Psr7/functions.php"
]
"name": "algolia/algoliasearch-client-php",
"description": "API powering the features of Algolia.",
"keywords": [
"openapitools",
"openapi-generator",
"openapi",
"php",
"sdk",
"rest",
"api"
],
"homepage": "https://openapi-generator.tech",
"license": "unlicense",
"authors": [
{
"name": "OpenAPI-Generator contributors",
"homepage": "https://openapi-generator.tech"
}
],
"require": {
"php": "^7.3 || ^8.0",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"guzzlehttp/guzzle": "^7.3",
"guzzlehttp/psr7": "^2.0",
"psr/http-message": "^1.0",
"psr/log": "^1.0 || ^2.0 || ^3.0",
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.5.0",
"phpunit/phpunit": "^9.3"
},
"autoload": {
"psr-4": {
"Algolia\\AlgoliaSearch\\": "lib/"
},
"autoload-dev": {
"psr-4": { "Algolia\\AlgoliaSearch\\Test\\" : "test/" }
"files": [
"lib/Http/Psr7/functions.php"
]
},
"autoload-dev": {
"psr-4": {
"Algolia\\AlgoliaSearch\\Test\\": "test/"
}
}
}
4 changes: 3 additions & 1 deletion clients/algoliasearch-client-php/lib/Algolia.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ public static function setLogger(LoggerInterface $logger)
public static function getHttpClient()
{
if (null === self::$httpClient) {
self::setHttpClient(new \Algolia\AlgoliaSearch\Http\GuzzleHttpClient());
self::setHttpClient(
new \Algolia\AlgoliaSearch\Http\GuzzleHttpClient()
);
}

return self::$httpClient;
Expand Down
8 changes: 6 additions & 2 deletions clients/algoliasearch-client-php/lib/ApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ class ApiException extends Exception
* @param string[]|null $responseHeaders HTTP response header
* @param \stdClass|string|null $responseBody HTTP decoded body of the server response either as \stdClass or string
*/
public function __construct($message = '', $code = 0, $responseHeaders = [], $responseBody = null)
{
public function __construct(
$message = '',
$code = 0,
$responseHeaders = [],
$responseBody = null
) {
parent::__construct($message, $code);
$this->responseHeaders = $responseHeaders;
$this->responseBody = $responseBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ final class FileCacheDriver implements CacheInterface

public function __construct($directory)
{
$this->directory = rtrim($directory, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
$this->directory =
rtrim($directory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
}

/**
Expand Down Expand Up @@ -49,7 +50,7 @@ public function delete($key)
public function clear()
{
$result = true;
foreach (glob($this->directory.self::PREFIX.'*') as $file) {
foreach (glob($this->directory . self::PREFIX . '*') as $file) {
$result &= @unlink($file);
}

Expand Down Expand Up @@ -110,7 +111,7 @@ public function has($key)
*/
private function getFilenameFromKey($key)
{
$name = $this->directory.self::PREFIX.$key;
$name = $this->directory . self::PREFIX . $key;

return str_replace('\\', '-', $name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@

abstract class ConfigWithRegion extends Configuration
{
public static function create($appId, $apiKey, $region = null, $allowedRegions = null)
{
public static function create(
$appId,
$apiKey,
$region = null,
$allowedRegions = null
) {
if ($region !== null && !in_array($region, $allowedRegions, true)) {
throw new AlgoliaException('Specified region is not allowed.');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ final class UnreachableException extends AlgoliaException
public function __construct($message = '', $code = 0, $previous = null)
{
if (!$message) {
$message = 'Impossible to connect, please check your Algolia Application Id.';
$message =
'Impossible to connect, please check your Algolia Application Id.';
}

parent::__construct($message, $code, $previous);
Expand Down
23 changes: 7 additions & 16 deletions clients/algoliasearch-client-php/lib/Http/GuzzleHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ public function __construct(GuzzleClient $client = null)
$this->client = $client ?: static::buildClient();
}

public function sendRequest(RequestInterface $request, $timeout, $connectTimeout)
{
public function sendRequest(
RequestInterface $request,
$timeout,
$connectTimeout
) {
try {
$response = $this->client->send($request, [
'timeout' => $timeout,
Expand All @@ -31,21 +34,9 @@ public function sendRequest(RequestInterface $request, $timeout, $connectTimeout
return $e->getResponse();
}

return new Response(
0,
[],
null,
'1.1',
$e->getMessage()
);
return new Response(0, [], null, '1.1', $e->getMessage());
} catch (ConnectException $e) {
return new Response(
0,
[],
null,
'1.1',
$e->getMessage()
);
return new Response(0, [], null, '1.1', $e->getMessage());
}

return $response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ interface HttpClientInterface
*
* @return ResponseInterface
*/
public function sendRequest(RequestInterface $request, $timeout, $connectTimeout);
public function sendRequest(
RequestInterface $request,
$timeout,
$connectTimeout
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ public function eof()

public function tell()
{
throw new \RuntimeException('Cannot determine the position of a BufferStream');
throw new \RuntimeException(
'Cannot determine the position of a BufferStream'
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public function __construct(callable $source, array $options = [])
{
$this->source = $source;
$this->size = isset($options['size']) ? $options['size'] : null;
$this->metadata = isset($options['metadata']) ? $options['metadata'] : [];
$this->metadata = isset($options['metadata'])
? $options['metadata']
: [];
$this->buffer = new BufferStream();
}

Expand Down
18 changes: 13 additions & 5 deletions clients/algoliasearch-client-php/lib/Http/Psr7/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function getRequestTarget()
$target = '/';
}
if ('' !== $this->uri->getQuery()) {
$target .= '?'.$this->uri->getQuery();
$target .= '?' . $this->uri->getQuery();
}

return $target;
Expand All @@ -89,7 +89,9 @@ public function getRequestTarget()
public function withRequestTarget($requestTarget)
{
if (preg_match('#\s#', $requestTarget)) {
throw new InvalidArgumentException('Invalid request target provided; cannot contain whitespace');
throw new InvalidArgumentException(
'Invalid request target provided; cannot contain whitespace'
);
}

$new = clone $this;
Expand Down Expand Up @@ -141,7 +143,7 @@ private function updateHostFromUri()
}

if (null !== ($port = $this->uri->getPort())) {
$host .= ':'.$port;
$host .= ':' . $port;
}

if (isset($this->headerNames['host'])) {
Expand Down Expand Up @@ -224,7 +226,10 @@ public function withAddedHeader($header, $value)
$new = clone $this;
if (isset($new->headerNames[$normalized])) {
$header = $this->headerNames[$normalized];
$new->headers[$header] = array_merge($this->headers[$header], $value);
$new->headers[$header] = array_merge(
$this->headers[$header],
$value
);
} else {
$new->headerNames[$normalized] = $header;
$new->headers[$header] = $value;
Expand Down Expand Up @@ -277,7 +282,10 @@ private function setHeaders(array $headers)
$normalized = mb_strtolower($header);
if (isset($this->headerNames[$normalized])) {
$header = $this->headerNames[$normalized];
$this->headers[$header] = array_merge($this->headers[$header], $value);
$this->headers[$header] = array_merge(
$this->headers[$header],
$value
);
} else {
$this->headerNames[$normalized] = $header;
$this->headers[$header] = $value;
Expand Down
10 changes: 8 additions & 2 deletions clients/algoliasearch-client-php/lib/Http/Psr7/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ public function withAddedHeader($header, $value)
$new = clone $this;
if (isset($new->headerNames[$normalized])) {
$header = $this->headerNames[$normalized];
$new->headers[$header] = array_merge($this->headers[$header], $value);
$new->headers[$header] = array_merge(
$this->headers[$header],
$value
);
} else {
$new->headerNames[$normalized] = $header;
$new->headers[$header] = $value;
Expand Down Expand Up @@ -283,7 +286,10 @@ private function setHeaders(array $headers)
$normalized = mb_strtolower($header);
if (isset($this->headerNames[$normalized])) {
$header = $this->headerNames[$normalized];
$this->headers[$header] = array_merge($this->headers[$header], $value);
$this->headers[$header] = array_merge(
$this->headers[$header],
$value
);
} else {
$this->headerNames[$normalized] = $header;
$this->headers[$header] = $value;
Expand Down
Loading