Skip to content

Commit 7dde71d

Browse files
angyvolinpetr-buchin
authored andcommitted
add php-cs-fixer config, apply cs fixes
1 parent 422b030 commit 7dde71d

Some content is hidden

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

58 files changed

+174
-144
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
vendor/
22
site/
3-
composer.lock
3+
composer.lock
4+
.php_cs.cache

.php_cs.dist

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
return PhpCsFixer\Config::create()
4+
->setRules(array(
5+
'@Symfony' => true,
6+
'@Symfony:risky' => true,
7+
'array_syntax' => array('syntax' => 'short'),
8+
'no_unreachable_default_argument_value' => false,
9+
'braces' => array('allow_single_line_closure' => true),
10+
'heredoc_to_nowdoc' => false,
11+
'phpdoc_annotation_without_dot' => false,
12+
))
13+
->setRiskyAllowed(true)
14+
->setFinder(
15+
PhpCsFixer\Finder::create()
16+
->in([
17+
__DIR__.'/src',
18+
__DIR__.'/tests',
19+
])
20+
)
21+
;

src/Client.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,4 @@ public function selectDatabase($databaseName, array $options = [])
122122
{
123123
return new Database($this->manager, $databaseName, $options);
124124
}
125-
}
125+
}

src/Collection.php

+16-13
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function bulkWrite($requests, array $options = [])
121121
sprintf(
122122
'Option "writeConcern" is expected to be "%s", "%s" given.',
123123
WriteConcern::class,
124-
getType($options['writeConcern'])
124+
\Tequila\MongoDB\getType($options['writeConcern'])
125125
)
126126
);
127127
}
@@ -145,7 +145,7 @@ public function bulkWrite($requests, array $options = [])
145145
public function count(array $filter = [], array $options = [])
146146
{
147147
$cursor = $this->executeCommand(
148-
['count' => $this->collectionName, 'query' => (object)$filter],
148+
['count' => $this->collectionName, 'query' => (object) $filter],
149149
$options
150150
);
151151

@@ -154,7 +154,7 @@ public function count(array $filter = [], array $options = [])
154154
throw new UnexpectedResultException('Command "count" did not return expected "n" field.');
155155
}
156156

157-
return (int)$result['n'];
157+
return (int) $result['n'];
158158
}
159159

160160
/**
@@ -194,7 +194,7 @@ public function createIndexes(array $indexes, array $options = [])
194194
$options
195195
);
196196

197-
return array_map(function(Index $index) {
197+
return array_map(function (Index $index) {
198198
return $index->getName();
199199
}, $indexes);
200200
}
@@ -245,7 +245,7 @@ public function distinct($fieldName, array $filter = [], array $options = [])
245245

246246
$command = ['distinct' => $this->collectionName, 'key' => $fieldName];
247247
if ($filter) {
248-
$command['query'] = (object)$filter;
248+
$command['query'] = (object) $filter;
249249
}
250250
$options['typeMap'] = [];
251251

@@ -269,8 +269,8 @@ public function drop(array $options = [])
269269
{
270270
try {
271271
$cursor = $this->executeCommand(['drop' => $this->collectionName], $options);
272-
} catch(MongoDBRuntimeException $e) {
273-
if('ns not found' === $e->getMessage()) {
272+
} catch (MongoDBRuntimeException $e) {
273+
if ('ns not found' === $e->getMessage()) {
274274
return ['ok' => 0, 'errmsg' => $e->getMessage()];
275275
}
276276

@@ -387,20 +387,20 @@ public function findOneAndReplace(array $filter, $replacement, array $options =
387387
throw new InvalidArgumentException(
388388
sprintf(
389389
'$replacement must be an array or an object, "%s" given.',
390-
getType($replacement)
390+
\Tequila\MongoDB\getType($replacement)
391391
)
392392
);
393393
}
394394

395395
try {
396396
ensureValidDocument($replacement);
397-
} catch(InvalidArgumentException $e) {
397+
} catch (InvalidArgumentException $e) {
398398
throw new InvalidArgumentException(
399399
sprintf('Invalid $replacement document: %s', $e->getMessage())
400400
);
401401
}
402402

403-
$options = ['update' => (object)$replacement] + FindOneAndUpdateResolver::resolveStatic($options);
403+
$options = ['update' => (object) $replacement] + FindOneAndUpdateResolver::resolveStatic($options);
404404

405405
return $this->findAndModify($filter, $options);
406406
}
@@ -415,7 +415,7 @@ public function findOneAndUpdate(array $filter, array $update, array $options =
415415
{
416416
UpdateDocumentResolver::resolveStatic($update);
417417

418-
$options = ['update' => (object)$update] + FindOneAndUpdateResolver::resolveStatic($options);
418+
$options = ['update' => (object) $update] + FindOneAndUpdateResolver::resolveStatic($options);
419419

420420
return $this->findAndModify($filter, $options);
421421
}
@@ -556,7 +556,7 @@ private function findAndModify(array $filter, array $options)
556556
{
557557
$command = [
558558
'findAndModify' => $this->collectionName,
559-
'query' => (object)$filter,
559+
'query' => (object) $filter,
560560
];
561561

562562
$options += ['typeMap' => $this->typeMap];
@@ -577,6 +577,9 @@ private function findAndModify(array $filter, array $options)
577577
return \Tequila\MongoDB\applyTypeMap($result, $typeMap);
578578
}
579579

580+
/**
581+
* @param array $options
582+
*/
580583
private function resolveOptions(array $options)
581584
{
582585
$options += [
@@ -593,4 +596,4 @@ private function resolveOptions(array $options)
593596
$this->writeConcern = $options['writeConcern'];
594597
$this->typeMap = $options['typeMap'];
595598
}
596-
}
599+
}

src/Command.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct(array $options)
2525
}
2626

2727
/**
28-
* @inheritdoc
28+
* {@inheritdoc}
2929
*/
3030
public function getOptions(Server $server)
3131
{
@@ -43,4 +43,4 @@ public function setCompatibilityResolver(CompatibilityResolver $resolver)
4343
{
4444
$this->compatibilityResolver = $resolver;
4545
}
46-
}
46+
}

src/CommandExecutor.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function __construct(ReadConcern $readConcern, ReadPreference $readPrefer
6666
}
6767

6868
/**
69-
* @inheritdoc
69+
* {@inheritdoc}
7070
*/
7171
public function executeCommand(Manager $manager, $databaseName, array $command, array $options)
7272
{
@@ -139,4 +139,4 @@ private function getResolver(array $command)
139139

140140
return OptionsResolver::get($resolverClass);
141141
}
142-
}
142+
}

src/Database.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function __construct(Manager $manager, $databaseName, array $options = []
7070
'Option "%s" is expected to be an instance of %s, %s given.',
7171
$optionName,
7272
$validType,
73-
getType($options[$optionName])
73+
\Tequila\MongoDB\getType($options[$optionName])
7474
)
7575
);
7676
}
@@ -116,8 +116,8 @@ public function dropCollection($collectionName, array $options = [])
116116
{
117117
try {
118118
$cursor = $this->executeCommand(['drop' => $collectionName], $options);
119-
} catch(MongoDBRuntimeException $e) {
120-
if('ns not found' === $e->getMessage()) {
119+
} catch (MongoDBRuntimeException $e) {
120+
if ('ns not found' === $e->getMessage()) {
121121
return ['ok' => 0, 'errmsg' => $e->getMessage()];
122122
}
123123

src/Index.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public function __construct(array $key, array $options = [])
3737
$this->options = $options;
3838
}
3939

40+
/**
41+
* @return string
42+
*/
4043
public function __toString()
4144
{
4245
return $this->getName();
@@ -83,9 +86,9 @@ public static function generateIndexName(array $key)
8386
$nameParts = [];
8487
foreach ($key as $fieldName => $direction) {
8588
$nameParts[] = $fieldName;
86-
$nameParts[] = (string)$direction;
89+
$nameParts[] = (string) $direction;
8790
}
8891

8992
return implode('_', $nameParts);
9093
}
91-
}
94+
}

src/OptionsResolver/BulkWrite/DeleteResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ protected function configureOptions()
1515
->setDefined('limit')
1616
->setAllowedValues('limit', [0, 1]);
1717
}
18-
}
18+
}

src/OptionsResolver/BulkWrite/UpdateDocumentResolver.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function resolve(array $options = array())
1111
{
1212
try {
1313
return parent::resolve($options);
14-
} catch(InvalidArgumentException $e) {
14+
} catch (InvalidArgumentException $e) {
1515
throw new InvalidArgumentException(
1616
sprintf(
1717
'Invalid $update document: %s',
@@ -36,4 +36,4 @@ protected function configureOptions()
3636
'$bit',
3737
]);
3838
}
39-
}
39+
}

src/OptionsResolver/BulkWrite/UpdateResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ protected function configureOptions()
1919
$this->setAllowedTypes('upsert', 'bool');
2020
$this->setAllowedTypes('multi', 'bool');
2121
}
22-
}
22+
}

src/OptionsResolver/CollectionOptionsResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ public function configureOptions()
1616
WriteConcernConfigurator::configure($this);
1717
TypeMapConfigurator::configure($this);
1818
}
19-
}
19+
}

src/OptionsResolver/Command/AggregateResolver.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
class AggregateResolver extends OptionsResolver
1717
{
1818
/**
19-
* @inheritdoc
19+
* {@inheritdoc}
2020
*/
2121
public function resolve(array $options = [])
2222
{
@@ -65,7 +65,7 @@ public function resolve(array $options = [])
6565
unset($options['batchSize']);
6666
}
6767

68-
$options['cursor'] = (object)$options['cursor'];
68+
$options['cursor'] = (object) $options['cursor'];
6969
} else {
7070
if (isset($options['batchSize'])) {
7171
throw new InvalidArgumentException(
@@ -116,9 +116,9 @@ private function hasOutStage(array $options)
116116
return false;
117117
}
118118

119-
$pipeline = (array)$options['pipeline'];
119+
$pipeline = (array) $options['pipeline'];
120120
$lastStage = end($pipeline);
121121

122122
return '$out' === key($lastStage);
123123
}
124-
}
124+
}

src/OptionsResolver/Command/CompatibilityResolver.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(OptionsResolver $optionsResolver)
2828
}
2929

3030
/**
31-
* @inheritdoc
31+
* {@inheritdoc}
3232
*/
3333
public function resolveCompatibilities(Server $server, array $options)
3434
{
@@ -79,4 +79,4 @@ public function resolveCompatibilities(Server $server, array $options)
7979
}
8080
}
8181
}
82-
}
82+
}

src/OptionsResolver/Command/CountResolver.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ protected function configureOptions()
2525
->setAllowedTypes('skip', 'integer')
2626
->setAllowedTypes('hint', ['string', 'array', 'object']);
2727

28-
$this->setNormalizer('hint', function($value) {
28+
$this->setNormalizer('hint', function ($value) {
2929
if (is_array($value) || is_object($value)) {
30-
$value = Index::generateIndexName((array)$value);
30+
$value = Index::generateIndexName((array) $value);
3131
}
3232

3333
return $value;
3434
});
3535
}
36-
}
36+
}

src/OptionsResolver/Command/CreateCollectionResolver.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class CreateCollectionResolver extends OptionsResolver
1111
{
1212
/**
13-
* @inheritdoc
13+
* {@inheritdoc}
1414
*/
1515
public function resolve(array $options = [])
1616
{
@@ -37,7 +37,7 @@ public function resolve(array $options = [])
3737
}
3838

3939
/**
40-
* @inheritdoc
40+
* {@inheritdoc}
4141
*/
4242
protected function configureOptions()
4343
{
@@ -74,4 +74,4 @@ protected function configureOptions()
7474
])
7575
->setAllowedTypes('indexOptionDefaults', ['array', 'object']);
7676
}
77-
}
77+
}

src/OptionsResolver/Command/CreateIndexesResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ protected function configureOptions()
1111
{
1212
WriteConcernConfigurator::configure($this);
1313
}
14-
}
14+
}

src/OptionsResolver/Command/DistinctResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ protected function configureOptions()
1919
ReadPreferenceConfigurator::configure($this);
2020
TypeMapConfigurator::configure($this);
2121
}
22-
}
22+
}

src/OptionsResolver/Command/DropCollectionResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ protected function configureOptions()
1111
{
1212
WriteConcernConfigurator::configure($this);
1313
}
14-
}
14+
}

src/OptionsResolver/Command/DropDatabaseResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ protected function configureOptions()
1111
{
1212
WriteConcernConfigurator::configure($this);
1313
}
14-
}
14+
}

src/OptionsResolver/Command/DropIndexesResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ protected function configureOptions()
1111
{
1212
WriteConcernConfigurator::configure($this);
1313
}
14-
}
14+
}

src/OptionsResolver/Command/FindAndModifyResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ protected function configureOptions()
5858
->setAllowedTypes('fields', $documentTypes)
5959
->setAllowedTypes('upsert', 'bool');
6060
}
61-
}
61+
}

0 commit comments

Comments
 (0)