Skip to content

Commit

Permalink
Base PHP-cs-fixer migration to version 2 plus style fix
Browse files Browse the repository at this point in the history
  • Loading branch information
massimilianobraglia committed Dec 14, 2018
1 parent 76e868a commit 4541719
Show file tree
Hide file tree
Showing 419 changed files with 995 additions and 555 deletions.
44 changes: 19 additions & 25 deletions .php_cs
@@ -1,32 +1,26 @@
<?php

$finder = Symfony\CS\Finder\DefaultFinder::create()
->in(['lib', 'test']);
$finder = PhpCsFixer\Finder::create()
->exclude(['vendor', 'var'])
->in([__DIR__])
;

$config = Symfony\CS\Config\Config::create()
->setUsingCache(true)
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
->fixers([
// [contrib] Multi-line whitespace before closing semicolon are prohibited.
'multiline_spaces_before_semicolon',
// [contrib] There should be no blank lines before a namespace declaration.
'no_blank_lines_before_namespace',
// [contrib] Ordering use statements.
'ordered_use',
// [contrib] Annotations should be ordered so that param annotations come first, then throws annotations, then return annotations.
'phpdoc_order',
// [contrib] Arrays should use the short syntax.
'short_array_syntax',
// [contrib] Ensure there is no code on the same line as the PHP open tag.
'newline_after_open_tag',
// [contrib] Use null coalescing operator ?? where possible
'ternary_to_null_coalescing',
// [contrib] There should not be useless else cases.
'no_useless_else',
// [contrib] Use dedicated PHPUnit assertions for better error messages.
$config = PhpCsFixer\Config::create()
->setFinder($finder)
->setRules([
'@PSR2' => true,
'@Symfony' => true,
'psr0' => false,
'single_blank_line_before_namespace' => false,
'ordered_imports' => true,
'array_syntax' => ['syntax' => 'short'],
'phpdoc_order' => true,
'blank_line_after_namespace' => true,
'ternary_to_null_coalescing' => true,
'no_useless_else' => true,
'@PHPUnit60Migration:risky' => true,
//'php_unit_dedicate_assert' => ['target' => 'newest'],
'php_unit_dedicate_assert' => ['target' => 'newest'],
])
->finder($finder);
;

return $config;
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -140,7 +140,7 @@ gource:

## DOCKER IMAGES

.PHONY: elastica-image
.PHONY: elastica-image
elastica-image:
docker build -t ruflin/elastica-dev-base -f env/elastica/Docker${TARGET} env/elastica/
docker build -t ruflin/elastica .
Expand Down
18 changes: 9 additions & 9 deletions env/elastica/composer.json
Expand Up @@ -13,14 +13,14 @@
],
"require": {
"php": "^7.0",
"phpdocumentor/phpdocumentor":"~2.8",
"fabpot/php-cs-fixer":"1.11.*",
"mayflower/php-codebrowser":"~1.1",
"pdepend/pdepend":"~2.2",
"phploc/phploc":"~2.1",
"phpmd/phpmd":"~2.3",
"phpunit/phpunit":"~5.6",
"sebastian/phpcpd":"~2.0",
"squizlabs/php_codesniffer":"~2.5"
"phpdocumentor/phpdocumentor": "^2.9",
"friendsofphp/php-cs-fixer": "^2.0",
"mayflower/php-codebrowser": "~1.1",
"pdepend/pdepend": "~2.2",
"phploc/phploc": "~2.1",
"phpmd/phpmd": "~2.3",
"phpunit/phpunit": "~5.6",
"sebastian/phpcpd": "~2.0",
"squizlabs/php_codesniffer": "~2.5"
}
}
5 changes: 3 additions & 2 deletions lib/Elastica/AbstractUpdateAction.php
@@ -1,4 +1,5 @@
<?php

namespace Elastica;

/**
Expand Down Expand Up @@ -108,7 +109,7 @@ public function getIndex()
*
* @return $this
*
* @link https://www.elastic.co/blog/versioning
* @see https://www.elastic.co/blog/versioning
*/
public function setVersion($version)
{
Expand Down Expand Up @@ -171,7 +172,7 @@ public function hasVersionType()
*
* @return $this
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-parent-field.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-parent-field.html
*/
public function setParent($parent)
{
Expand Down
1 change: 1 addition & 0 deletions lib/Elastica/Aggregation/AbstractAggregation.php
@@ -1,4 +1,5 @@
<?php

namespace Elastica\Aggregation;

use Elastica\Exception\InvalidException;
Expand Down
1 change: 1 addition & 0 deletions lib/Elastica/Aggregation/AbstractSimpleAggregation.php
@@ -1,4 +1,5 @@
<?php

namespace Elastica\Aggregation;

use Elastica\Exception\InvalidException;
Expand Down
5 changes: 3 additions & 2 deletions lib/Elastica/Aggregation/AbstractTermsAggregation.php
@@ -1,4 +1,5 @@
<?php

namespace Elastica\Aggregation;

/**
Expand Down Expand Up @@ -61,7 +62,7 @@ public function setExclude($pattern, $flags = null)
/**
* Sets the amount of terms to be returned.
*
* @param int $size The amount of terms to be returned.
* @param int $size the amount of terms to be returned
*
* @return $this
*/
Expand All @@ -73,7 +74,7 @@ public function setSize($size)
/**
* Sets how many terms the coordinating node will request from each shard.
*
* @param int $shard_size The amount of terms to be returned.
* @param int $shard_size the amount of terms to be returned
*
* @return $this
*/
Expand Down
3 changes: 2 additions & 1 deletion lib/Elastica/Aggregation/Avg.php
@@ -1,10 +1,11 @@
<?php

namespace Elastica\Aggregation;

/**
* Class Avg.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html
*/
class Avg extends AbstractSimpleAggregation
{
Expand Down
5 changes: 3 additions & 2 deletions lib/Elastica/Aggregation/AvgBucket.php
@@ -1,12 +1,13 @@
<?php

namespace Elastica\Aggregation;

use Elastica\Exception\InvalidException;

/**
* Class AvgBucket.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-avg-bucket-aggregation.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-avg-bucket-aggregation.html
*/
class AvgBucket extends AbstractAggregation
{
Expand All @@ -18,7 +19,7 @@ public function __construct($name, $bucketsPath = null)
{
parent::__construct($name);

if ($bucketsPath !== null) {
if (null !== $bucketsPath) {
$this->setBucketsPath($bucketsPath);
}
}
Expand Down
7 changes: 4 additions & 3 deletions lib/Elastica/Aggregation/BucketScript.php
@@ -1,12 +1,13 @@
<?php

namespace Elastica\Aggregation;

use Elastica\Exception\InvalidException;

/**
* Class BucketScript.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-script-aggregation.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-script-aggregation.html
*/
class BucketScript extends AbstractAggregation
{
Expand All @@ -19,11 +20,11 @@ public function __construct($name, $bucketsPath = null, $script = null)
{
parent::__construct($name);

if ($bucketsPath !== null) {
if (null !== $bucketsPath) {
$this->setBucketsPath($bucketsPath);
}

if ($script !== null) {
if (null !== $script) {
$this->setScript($script);
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Elastica/Aggregation/Cardinality.php
@@ -1,10 +1,11 @@
<?php

namespace Elastica\Aggregation;

/**
* Class Cardinality.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html
*/
class Cardinality extends AbstractSimpleAggregation
{
Expand Down
3 changes: 2 additions & 1 deletion lib/Elastica/Aggregation/Children.php
@@ -1,10 +1,11 @@
<?php

namespace Elastica\Aggregation;

/**
* Class Children.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/1.7/search-aggregations-bucket-children-aggregation.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/1.7/search-aggregations-bucket-children-aggregation.html
*/
class Children extends AbstractAggregation
{
Expand Down
7 changes: 4 additions & 3 deletions lib/Elastica/Aggregation/DateHistogram.php
@@ -1,10 +1,11 @@
<?php

namespace Elastica\Aggregation;

/**
* Class DateHistogram.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html
*/
class DateHistogram extends Histogram
{
Expand Down Expand Up @@ -47,7 +48,7 @@ public function setOffset($offset)
/**
* Set the format for returned bucket key_as_string values.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/master/search-aggregations-bucket-daterange-aggregation.html#date-format-pattern
* @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-aggregations-bucket-daterange-aggregation.html#date-format-pattern
*
* @param string $format see link for formatting options
*
Expand All @@ -61,7 +62,7 @@ public function setFormat($format)
/**
* Set extended bounds option.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-histogram-aggregation.html#search-aggregations-bucket-histogram-aggregation-extended-bounds
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-histogram-aggregation.html#search-aggregations-bucket-histogram-aggregation-extended-bounds
*
* @param string $min see link for formatting options
* @param string $max see link for formatting options
Expand Down
3 changes: 2 additions & 1 deletion lib/Elastica/Aggregation/DateRange.php
@@ -1,10 +1,11 @@
<?php

namespace Elastica\Aggregation;

/**
* Class DateRange.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html
*/
class DateRange extends Range
{
Expand Down
3 changes: 2 additions & 1 deletion lib/Elastica/Aggregation/ExtendedStats.php
@@ -1,10 +1,11 @@
<?php

namespace Elastica\Aggregation;

/**
* Class ExtendedStats.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-extendedstats-aggregation.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-extendedstats-aggregation.html
*/
class ExtendedStats extends AbstractSimpleAggregation
{
Expand Down
5 changes: 3 additions & 2 deletions lib/Elastica/Aggregation/Filter.php
@@ -1,4 +1,5 @@
<?php

namespace Elastica\Aggregation;

use Elastica\Exception\InvalidException;
Expand All @@ -7,7 +8,7 @@
/**
* Class Filter.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html
*/
class Filter extends AbstractAggregation
{
Expand All @@ -19,7 +20,7 @@ public function __construct($name, AbstractQuery $filter = null)
{
parent::__construct($name);

if ($filter !== null) {
if (null !== $filter) {
$this->setFilter($filter);
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Elastica/Aggregation/Filters.php
@@ -1,4 +1,5 @@
<?php

namespace Elastica\Aggregation;

use Elastica\Exception\InvalidException;
Expand All @@ -7,7 +8,7 @@
/**
* Class Filters.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html
*/
class Filters extends AbstractAggregation
{
Expand Down
3 changes: 2 additions & 1 deletion lib/Elastica/Aggregation/GeoBounds.php
@@ -1,10 +1,11 @@
<?php

namespace Elastica\Aggregation;

/**
* A metric aggregation that computes the bounding box containing all geo_point values for a field.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-geobounds-aggregation.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-geobounds-aggregation.html
*/
class GeoBounds extends AbstractAggregation
{
Expand Down
3 changes: 2 additions & 1 deletion lib/Elastica/Aggregation/GeoCentroid.php
@@ -1,10 +1,11 @@
<?php

namespace Elastica\Aggregation;

/**
* Class GeoCentroid.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-geocentroid-aggregation.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-geocentroid-aggregation.html
*/
class GeoCentroid extends AbstractAggregation
{
Expand Down
3 changes: 2 additions & 1 deletion lib/Elastica/Aggregation/GeoDistance.php
@@ -1,12 +1,13 @@
<?php

namespace Elastica\Aggregation;

use Elastica\Exception\InvalidException;

/**
* Class GeoDistance.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geodistance-aggregation.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geodistance-aggregation.html
*/
class GeoDistance extends AbstractAggregation
{
Expand Down
3 changes: 2 additions & 1 deletion lib/Elastica/Aggregation/GeohashGrid.php
@@ -1,10 +1,11 @@
<?php

namespace Elastica\Aggregation;

/**
* Class GeohashGrid.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohashgrid-aggregation.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohashgrid-aggregation.html
*/
class GeohashGrid extends AbstractAggregation
{
Expand Down
3 changes: 2 additions & 1 deletion lib/Elastica/Aggregation/GlobalAggregation.php
@@ -1,10 +1,11 @@
<?php

namespace Elastica\Aggregation;

/**
* Class GlobalAggregation.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-global-aggregation.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-global-aggregation.html
*/
class GlobalAggregation extends AbstractAggregation
{
Expand Down

0 comments on commit 4541719

Please sign in to comment.