Skip to content

Commit 5b2cc06

Browse files
authored
symfony coding standard (solariumphp#846)
code style fixes implementing (most of) the rules advised by the symfony coding standard as defined @ https://symfony.com/doc/current/contributing/code/standards.html
1 parent 1b461d6 commit 5b2cc06

File tree

392 files changed

+3915
-515
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

392 files changed

+3915
-515
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
/vendor
44
.idea
55
/.phpunit.result.cache
6-
.php_cs.cache
6+
/.php_cs.cache
7+
/.phpcs-cache

.php_cs.dist

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<?php
22

3+
$header = <<<'EOF'
4+
This file is part of the Solarium package.
5+
6+
For the full copyright and license information, please view the COPYING
7+
file that was distributed with this source code.
8+
EOF;
9+
310
return PhpCsFixer\Config::create()
411
->setRiskyAllowed(true)
512
->setRules([
@@ -9,9 +16,9 @@ return PhpCsFixer\Config::create()
916
'array_syntax' => ['syntax' => 'short'],
1017
'class_attributes_separation' => ['elements' => ['const', 'method', 'property']],
1118
'combine_consecutive_unsets' => true,
12-
// one should use PHPUnit methods to set up expected exception instead of annotations
1319
'general_phpdoc_annotation_remove' => ['expectedException', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp'],
1420
'heredoc_to_nowdoc' => true,
21+
'header_comment' => ['header' => $header],
1522
'list_syntax' => ['syntax' => 'long'],
1623
'method_argument_space' => ['keep_multiple_spaces_after_comma' => false],
1724
'no_extra_consecutive_blank_lines' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'],
@@ -21,12 +28,9 @@ return PhpCsFixer\Config::create()
2128
'no_useless_return' => true,
2229
'ordered_class_elements' => true,
2330
'ordered_imports' => true,
24-
// 'php_unit_strict' => true,
25-
// 'php_unit_test_class_requires_covers' => true,
2631
'phpdoc_add_missing_param_annotation' => true,
2732
'phpdoc_order' => true,
2833
'semicolon_after_instruction' => true,
29-
// 'strict_comparison' => true,
3034
'strict_param' => true,
3135
'implode_call' => true,
3236
'no_superfluous_phpdoc_tags' => false,
@@ -35,6 +39,5 @@ return PhpCsFixer\Config::create()
3539
PhpCsFixer\Finder::create()
3640
->exclude('vendor/')
3741
->in('src')
38-
->in('tests')
3942
)
4043
;

.styleci.yml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ disabled:
99
- blank_line_before_break
1010
- blank_line_before_continue
1111
- blank_line_before_declare
12-
- blank_line_before_return
1312
- blank_line_before_throw
1413
- blank_line_before_try
1514

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"symfony/contracts": "^1.0 || ^2.0"
2121
},
2222
"require-dev": {
23+
"escapestudios/symfony2-coding-standard": "^3.11",
2324
"guzzlehttp/guzzle": "^6.5",
2425
"nyholm/psr7": "^1.2",
2526
"php-http/guzzle6-adapter": "^2.0",

phpcs.xml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
5+
6+
<config name="installed_paths" value="vendor/escapestudios/symfony2-coding-standard" />
7+
8+
<arg name="basepath" value="."/>
9+
<arg name="cache" value=".phpcs-cache"/>
10+
<arg name="colors"/>
11+
<arg name="extensions" value="php"/>
12+
13+
<rule ref="Symfony"/>
14+
15+
<file>src/</file>
16+
17+
</ruleset>

src/Builder/AbstractExpressionVisitor.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the Solarium package.
7+
*
8+
* For the full copyright and license information, please view the COPYING
9+
* file that was distributed with this source code.
10+
*/
11+
512
namespace Solarium\Builder;
613

714
use Solarium\Exception\RuntimeException;
@@ -57,7 +64,7 @@ public function dispatch(ExpressionInterface $expr)
5764
case $expr instanceof CompositeComparison:
5865
return $this->walkCompositeExpression($expr);
5966
default:
60-
throw new RuntimeException('Unknown Expression '.\get_class($expr));
67+
throw new RuntimeException(sprintf('Unknown Expression %s', \get_class($expr)));
6168
}
6269
}
6370
}

src/Builder/Analytics/AnalyticsExpressionVisitor.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the Solarium package.
7+
*
8+
* For the full copyright and license information, please view the COPYING
9+
* file that was distributed with this source code.
10+
*/
11+
512
namespace Solarium\Builder\Analytics;
613

714
use Solarium\Builder\AbstractExpressionVisitor;
@@ -30,7 +37,7 @@ public function dispatch(ExpressionInterface $expr)
3037
return $this->walkExpression($expr);
3138
}
3239

33-
throw new RuntimeException('Unknown Expression '.\get_class($expr));
40+
throw new RuntimeException(sprintf('Unknown Expression %s', \get_class($expr)));
3441
}
3542

3643
/**

src/Builder/Analytics/ExpressionBuilder.php

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the Solarium package.
7+
*
8+
* For the full copyright and license information, please view the COPYING
9+
* file that was distributed with this source code.
10+
*/
11+
512
namespace Solarium\Builder\Analytics;
613

714
use Solarium\Builder\ExpressionInterface;

src/Builder/Analytics/FunctionBuilder.php

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the Solarium package.
7+
*
8+
* For the full copyright and license information, please view the COPYING
9+
* file that was distributed with this source code.
10+
*/
11+
512
namespace Solarium\Builder\Analytics;
613

714
use Solarium\Builder\ExpressionInterface;

src/Builder/Analytics/MappingFunction.php

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the Solarium package.
7+
*
8+
* For the full copyright and license information, please view the COPYING
9+
* file that was distributed with this source code.
10+
*/
11+
512
namespace Solarium\Builder\Analytics;
613

714
use Solarium\Builder\AbstractExpressionVisitor;

src/Builder/Analytics/ReductionFunction.php

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the Solarium package.
7+
*
8+
* For the full copyright and license information, please view the COPYING
9+
* file that was distributed with this source code.
10+
*/
11+
512
namespace Solarium\Builder\Analytics;
613

714
use Solarium\Builder\AbstractExpressionVisitor;

src/Builder/Comparison.php

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the Solarium package.
7+
*
8+
* For the full copyright and license information, please view the COPYING
9+
* file that was distributed with this source code.
10+
*/
11+
512
namespace Solarium\Builder;
613

714
/**

src/Builder/CompositeComparison.php

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the Solarium package.
7+
*
8+
* For the full copyright and license information, please view the COPYING
9+
* file that was distributed with this source code.
10+
*/
11+
512
namespace Solarium\Builder;
613

714
use Solarium\Exception\RuntimeException;

src/Builder/ExpressionInterface.php

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the Solarium package.
7+
*
8+
* For the full copyright and license information, please view the COPYING
9+
* file that was distributed with this source code.
10+
*/
11+
512
namespace Solarium\Builder;
613

714
/**

src/Builder/FunctionInterface.php

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the Solarium package.
7+
*
8+
* For the full copyright and license information, please view the COPYING
9+
* file that was distributed with this source code.
10+
*/
11+
512
namespace Solarium\Builder;
613

714
/**

src/Builder/Value.php

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the Solarium package.
7+
*
8+
* For the full copyright and license information, please view the COPYING
9+
* file that was distributed with this source code.
10+
*/
11+
512
namespace Solarium\Builder;
613

714
/**

src/Client.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<?php
22

3+
/*
4+
* This file is part of the Solarium package.
5+
*
6+
* For the full copyright and license information, please view the COPYING
7+
* file that was distributed with this source code.
8+
*/
9+
310
namespace Solarium;
411

512
use Solarium\Core\Client\Client as CoreClient;
@@ -66,7 +73,7 @@ class Client extends CoreClient
6673
*/
6774
public static function checkExact(string $version): bool
6875
{
69-
return substr(self::VERSION, 0, strlen($version)) == $version;
76+
return 0 === strpos(self::VERSION, $version);
7077
}
7178

7279
/**

src/Component/AbstractComponent.php

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<?php
22

3+
/*
4+
* This file is part of the Solarium package.
5+
*
6+
* For the full copyright and license information, please view the COPYING
7+
* file that was distributed with this source code.
8+
*/
9+
310
namespace Solarium\Component;
411

512
use Solarium\Component\RequestBuilder\ComponentRequestBuilderInterface;
@@ -34,6 +41,8 @@ abstract public function getRequestBuilder(): ComponentRequestBuilderInterface;
3441

3542
/**
3643
* This component has no response parser...
44+
*
45+
* @return \Solarium\Component\ResponseParser\ComponentParserInterface|null
3746
*/
3847
public function getResponseParser(): ?ComponentParserInterface
3948
{

src/Component/Analytics/Analytics.php

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the Solarium package.
7+
*
8+
* For the full copyright and license information, please view the COPYING
9+
* file that was distributed with this source code.
10+
*/
11+
512
namespace Solarium\Component\Analytics;
613

714
use Solarium\Component\AbstractComponent;

src/Component/Analytics/Facet/AbstractFacet.php

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the Solarium package.
7+
*
8+
* For the full copyright and license information, please view the COPYING
9+
* file that was distributed with this source code.
10+
*/
11+
512
namespace Solarium\Component\Analytics\Facet;
613

714
use Solarium\Core\Configurable;

src/Component/Analytics/Facet/ConfigurableInitTrait.php

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the Solarium package.
7+
*
8+
* For the full copyright and license information, please view the COPYING
9+
* file that was distributed with this source code.
10+
*/
11+
512
namespace Solarium\Component\Analytics\Facet;
613

714
/**

src/Component/Analytics/Facet/ObjectTrait.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the Solarium package.
7+
*
8+
* For the full copyright and license information, please view the COPYING
9+
* file that was distributed with this source code.
10+
*/
11+
512
namespace Solarium\Component\Analytics\Facet;
613

714
use Solarium\Core\Configurable;
@@ -47,7 +54,9 @@ public function ensureObject(string $class, $variable)
4754
&& (false !== $map = $refClass->getConstant('CLASSMAP'))
4855
&& (true === isset($map[$variable['type']]))
4956
) {
50-
return new $map[$variable['type']]($variable);
57+
$class = $map[$variable['type']];
58+
59+
return new $class($variable);
5160
}
5261
}
5362

src/Component/Analytics/Facet/Pivot.php

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the Solarium package.
7+
*
8+
* For the full copyright and license information, please view the COPYING
9+
* file that was distributed with this source code.
10+
*/
11+
512
namespace Solarium\Component\Analytics\Facet;
613

714
use Solarium\Component\Analytics\Facet\Sort\Sort;

src/Component/Analytics/Facet/PivotFacet.php

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the Solarium package.
7+
*
8+
* For the full copyright and license information, please view the COPYING
9+
* file that was distributed with this source code.
10+
*/
11+
512
namespace Solarium\Component\Analytics\Facet;
613

714
/**

0 commit comments

Comments
 (0)