Skip to content

Commit

Permalink
update PHP-CS-Fixer to the latest version and enable parallelization …
Browse files Browse the repository at this point in the history
…in order to speedup builds
  • Loading branch information
sidz committed Jul 27, 2024
1 parent edd43bb commit 1f9226a
Show file tree
Hide file tree
Showing 57 changed files with 27 additions and 268 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
php-version: '8.0'
coverage: 'none'
extensions: 'json, mbstring, tokenizer'
tools: 'composer-normalize:2.28.0, php-cs-fixer:3.13.2'
tools: 'composer-normalize:2.28.0, php-cs-fixer:3.59.3'

- name: 'Check PHP code'
run: |
php-cs-fixer fix --diff --dry-run --allow-risky=yes --using-cache=no
php-cs-fixer fix --diff --dry-run --allow-risky=yes --using-cache=no --show-progress=dots
- name: 'Check composer.json'
run: |
Expand Down
5 changes: 5 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
;

return (new PhpCsFixer\Config())
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
->setFinder($finder)
->setRules([
'@PHP80Migration' => true,
Expand All @@ -33,5 +34,9 @@
'static_lambda' => true,
'ternary_to_null_coalescing' => true,
'visibility_required' => ['elements' => ['property', 'method', 'const']],
'fully_qualified_strict_types' => [
'import_symbols' => true,
],
'string_implicit_backslashes' => false,
])
;
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ install-tools: install-phpcs

.PHONY: run-phpcs
run-phpcs: install-phpcs
tools/php-cs-fixer.phar fix --diff --dry-run --allow-risky=yes -v
tools/php-cs-fixer.phar fix --diff --dry-run --allow-risky=yes -v --show-progress=dots

.PHONY: fix-phpcs
fix-phpcs: install-phpcs
tools/php-cs-fixer.phar fix --allow-risky=yes -v
tools/php-cs-fixer.phar fix --allow-risky=yes -v --show-progress=dots

.PHONY: run-phpunit
run-phpunit: composer-install
Expand Down
2 changes: 1 addition & 1 deletion phive.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="php-cs-fixer" version="^3.0" installed="3.9.5" location="./tools/php-cs-fixer.phar" copy="true"/>
<phar name="php-cs-fixer" version="^3.0" installed="3.59.3" location="./tools/php-cs-fixer.phar" copy="true"/>
<phar name="php-coveralls" version="^2.2" installed="2.2.0" location="./tools/php-coveralls.phar" copy="true"/>
</phive>
6 changes: 2 additions & 4 deletions src/Aggregation/AbstractSimpleAggregation.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Elastica\Aggregation;

use Elastica\Exception\InvalidException;
use Elastica\Script\AbstractScript;

abstract class AbstractSimpleAggregation extends AbstractAggregation
{
Expand All @@ -23,7 +24,7 @@ public function setField(string $field): self
/**
* Set a script for this aggregation.
*
* @param \Elastica\Script\AbstractScript|string $script
* @param AbstractScript|string $script
*
* @return $this
*/
Expand All @@ -32,9 +33,6 @@ public function setScript($script): self
return $this->setParam('script', $script);
}

/**
* {@inheritdoc}
*/
public function toArray(): array
{
if (!$this->hasParam('field') && !$this->hasParam('script')) {
Expand Down
3 changes: 0 additions & 3 deletions src/Aggregation/ReverseNested.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ public function setPath(string $path): self
return $this->setParam('path', $path);
}

/**
* {@inheritdoc}
*/
public function toArray(): array
{
$array = parent::toArray();
Expand Down
2 changes: 0 additions & 2 deletions src/Aggregation/Traits/MissingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ trait MissingTrait
/**
* Defines how documents that are missing a value should be treated.
*
* @param mixed $missing
*
* @return $this
*/
public function setMissing($missing): self
Expand Down
6 changes: 2 additions & 4 deletions src/Aggregation/WeightedAvg.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class WeightedAvg extends AbstractAggregation
/**
* Set the value for this aggregation.
*
* @param mixed $missing
* @param mixed|null $missing
*
* @return $this
*/
Expand Down Expand Up @@ -52,7 +52,7 @@ public function setValueScript(string $script)
/**
* Set the weight for this aggregation.
*
* @param mixed $missing
* @param mixed|null $missing
*
* @return $this
*/
Expand Down Expand Up @@ -100,8 +100,6 @@ public function setFormat($format)
/**
* Set the value_type for this aggregation.
*
* @param mixed $valueType
*
* @return $this
*/
public function setValueType($valueType)
Expand Down
3 changes: 0 additions & 3 deletions src/Bulk/Action/DeleteDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ class DeleteDocument extends AbstractDocument
*/
protected $_opType = self::OP_TYPE_DELETE;

/**
* {@inheritdoc}
*/
protected function _getMetadata(AbstractUpdateAction $action): array
{
return $action->getOptions([
Expand Down
6 changes: 0 additions & 6 deletions src/Bulk/Action/IndexDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ class IndexDocument extends AbstractDocument
*/
protected $_opType = self::OP_TYPE_INDEX;

/**
* {@inheritdoc}
*/
public function setDocument(Document $document): AbstractDocument
{
parent::setDocument($document);
Expand All @@ -26,9 +23,6 @@ public function setDocument(Document $document): AbstractDocument
return $this;
}

/**
* {@inheritdoc}
*/
protected function _getMetadata(AbstractUpdateAction $action): array
{
return $action->getOptions([
Expand Down
6 changes: 0 additions & 6 deletions src/Bulk/Action/UpdateDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ class UpdateDocument extends IndexDocument
*/
protected $_opType = self::OP_TYPE_UPDATE;

/**
* {@inheritdoc}
*/
public function setDocument(Document $document): AbstractDocument
{
parent::setDocument($document);
Expand All @@ -38,9 +35,6 @@ public function setDocument(Document $document): AbstractDocument
return $this;
}

/**
* {@inheritdoc}
*/
public function setScript(AbstractScript $script): AbstractDocument
{
parent::setScript($script);
Expand Down
15 changes: 0 additions & 15 deletions src/Bulk/ResponseSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,41 +93,26 @@ public function current(): Response
return $this->_bulkResponses[$this->key()];
}

/**
* {@inheritdoc}
*/
public function next(): void
{
++$this->_position;
}

/**
* {@inheritdoc}
*/
public function key(): int
{
return $this->_position;
}

/**
* {@inheritdoc}
*/
public function valid(): bool
{
return isset($this->_bulkResponses[$this->key()]);
}

/**
* {@inheritdoc}
*/
public function rewind(): void
{
$this->_position = 0;
}

/**
* {@inheritdoc}
*/
public function count(): int
{
return \count($this->_bulkResponses);
Expand Down
26 changes: 0 additions & 26 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,67 +68,43 @@ public function __construct(string|array $config = [], ?LoggerInterface $logger
$this->_transport = $this->_buildTransport($this->getConfig());
}

/**
* {@inheritdoc}
*/
public function getLogger(): LoggerInterface
{
return $this->_logger;
}

/**
* {@inheritdoc}
*/
public function getTransport(): Transport
{
return $this->_transport;
}

/**
* {@inheritdoc}
*/
public function setAsync(bool $async): self
{
throw new \Exception('Not supported');
}

/**
* {@inheritdoc}
*/
public function getAsync(): bool
{
throw new \Exception('Not supported');
}

/**
* {@inheritdoc}
*/
public function setElasticMetaHeader(bool $active): self
{
$this->elasticMetaHeader = $active;

return $this;
}

/**
* {@inheritdoc}
*/
public function getElasticMetaHeader(): bool
{
return $this->elasticMetaHeader;
}

/**
* {@inheritdoc}
*/
public function setResponseException(bool $active): self
{
throw new \Exception('Not supported');
}

/**
* {@inheritdoc}
*/
public function getResponseException(): bool
{
throw new \Exception('Not supported');
Expand Down Expand Up @@ -192,8 +168,6 @@ public function setConfigValue(string $key, $value): self
/**
* @param array|string $keys config key or path of config keys
* @param mixed $default default value will be returned if key was not found
*
* @return mixed
*/
public function getConfigValue($keys, $default = null)
{
Expand Down
4 changes: 0 additions & 4 deletions src/Cluster/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ public function getTransient(string $setting = '')

/**
* Sets persistent setting.
*
* @param mixed $value
*/
public function setPersistent(string $key, $value): Response
{
Expand All @@ -119,8 +117,6 @@ public function setPersistent(string $key, $value): Response

/**
* Sets transient settings.
*
* @param mixed $value
*/
public function setTransient(string $key, $value): Response
{
Expand Down
12 changes: 0 additions & 12 deletions src/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,11 @@ public function __construct(?string $id = null, $data = [], $index = '')
$this->setIndex($index);
}

/**
* @return mixed
*/
public function __get(string $key)
{
return $this->get($key);
}

/**
* @param mixed $value
*/
public function __set(string $key, $value): void
{
$this->set($key, $value);
Expand All @@ -78,11 +72,7 @@ public function __unset(string $key): void
/**
* Get the value of the given field.
*
* @param mixed $key
*
* @throws InvalidException If the given field does not exist
*
* @return mixed
*/
public function get($key)
{
Expand All @@ -96,8 +86,6 @@ public function get($key)
/**
* Set the value of the given field.
*
* @param mixed $value
*
* @throws InvalidException if the current document is a serialized data
*/
public function set(string $key, $value): self
Expand Down
9 changes: 0 additions & 9 deletions src/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,6 @@ public function exists(): bool
return 200 === $response->getStatusCode();
}

/**
* {@inheritdoc}
*/
public function createSearch($query = '', ?array $options = null, ?BuilderInterface $builder = null): Search
{
$search = new Search($this->getClient(), $builder);
Expand All @@ -530,19 +527,13 @@ public function createSearch($query = '', ?array $options = null, ?BuilderInterf
return $search;
}

/**
* {@inheritdoc}
*/
public function search($query = '', ?array $options = null, string $method = Request::POST): ResultSet
{
$search = $this->createSearch($query, $options);

return $search->search('', null, $method);
}

/**
* {@inheritdoc}
*/
public function count($query = '', string $method = Request::POST): int
{
$search = $this->createSearch($query);
Expand Down
Loading

0 comments on commit 1f9226a

Please sign in to comment.