Skip to content
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

Add static_lambda CS rule #1870

Merged
merged 3 commits into from
Nov 18, 2020
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
1 change: 1 addition & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ return PhpCsFixer\Config::create()
'php_unit_test_class_requires_covers' => false,
'phpdoc_order' => true,
'phpdoc_types_order' => ['null_adjustment' => 'always_last'],
'static_lambda' => true,
'ternary_to_null_coalescing' => true,
'visibility_required' => ['property', 'method', 'const'],
'void_return' => true,
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Added `symfony/deprecation-contracts` package to handle deprecations [#1823](https://github.com/ruflin/Elastica/pull/1823)
* Added `list_syntax` CS rule [#1854](https://github.com/ruflin/Elastica/pull/1854)
* Added `native_constant_invocation` CS rule [#1833](https://github.com/ruflin/Elastica/pull/1833)
* Added `static_lambda` CS rule [#1870](https://github.com/ruflin/Elastica/pull/1870)
* Added `Elastica\Aggregation\DateRange::setTimezone()` [#1847](https://github.com/ruflin/Elastica/pull/1847)
### Changed
* Allow `string` such as `wait_for` to be passed to `AbstractUpdateAction::setRefresh` [#1791](https://github.com/ruflin/Elastica/pull/1791)
Expand Down
2 changes: 1 addition & 1 deletion src/Transport/AwsAuthV4.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private function getSigningMiddleware(): callable
$signer = new SignatureV4('es', $region);
$credProvider = $this->getCredentialProvider();

return Middleware::mapRequest(function (RequestInterface $req) use (
return Middleware::mapRequest(static function (RequestInterface $req) use (
$signer,
$credProvider
) {
Expand Down
2 changes: 1 addition & 1 deletion tests/BulkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ public function testUpsert(): void
$doc2 = new Document(2, ['name' => 'Beckenbauer'], $index);
$doc3 = new Document(3, ['name' => 'Baggio'], $index);
$doc4 = new Document(4, ['name' => 'Cruyff'], $index);
$documents = \array_map(function ($d) {
$documents = \array_map(static function ($d) {
$d->setDocAsUpsert(true);

return $d;
Expand Down
4 changes: 2 additions & 2 deletions tests/Connection/Strategy/CallbackStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testInvoke(): void
{
$count = 0;

$callback = function ($connections) use (&$count): Connection {
$callback = static function ($connections) use (&$count): Connection {
++$count;

return \current($connections);
Expand All @@ -42,7 +42,7 @@ public function testConnection(): void
{
$count = 0;

$config = ['connectionStrategy' => function ($connections) use (&$count): Connection {
$config = ['connectionStrategy' => static function ($connections) use (&$count): Connection {
++$count;

return \current($connections);
Expand Down
4 changes: 2 additions & 2 deletions tests/Connection/Strategy/RoundRobinTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function testWithOneFailConnection(): void
];

$count = 0;
$callback = function ($connection, $exception, $client) use (&$count): void {
$callback = static function ($connection, $exception, $client) use (&$count): void {
++$count;
};

Expand Down Expand Up @@ -102,7 +102,7 @@ public function testWithNoValidConnection(): void
];

$count = 0;
$client = $this->_getClient(['roundRobin' => true], function () use (&$count): void {
$client = $this->_getClient(['roundRobin' => true], static function () use (&$count): void {
++$count;
});

Expand Down
4 changes: 2 additions & 2 deletions tests/Connection/Strategy/SimpleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function testWithOneFailConnection(): void
];

$count = 0;
$callback = function ($connection, $exception, $client) use (&$count): void {
$callback = static function ($connection, $exception, $client) use (&$count): void {
++$count;
};

Expand Down Expand Up @@ -90,7 +90,7 @@ public function testWithNoValidConnection(): void
];

$count = 0;
$client = $this->_getClient([], function () use (&$count): void {
$client = $this->_getClient([], static function () use (&$count): void {
++$count;
});

Expand Down
2 changes: 1 addition & 1 deletion tests/Connection/Strategy/StrategyFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class StrategyFactoryTest extends Base
*/
public function testCreateCallbackStrategy(): void
{
$callback = function ($connections): void {
$callback = static function ($connections): void {
};

$strategy = StrategyFactory::create($callback);
Expand Down
2 changes: 1 addition & 1 deletion tests/StatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function testAliasExists(): void

$indicesWithAlias = $status->getIndicesWithAlias($aliasName);
$this->assertEquals([$indexName], \array_map(
function ($index) {
static function ($index) {
return $index->getName();
},
$indicesWithAlias
Expand Down