@@ -5,8 +5,6 @@ |
||
5 | 5 | |
6 | 6 | use MongoDB\BulkWriteResult; |
7 | 7 | use MongoDB\Collection; |
8 | -use MongoDB\Operation\InsertOne; |
|
9 | -use Psr\Log\LoggerInterface; |
|
10 | 8 | use Psr\Log\NullLogger; |
11 | 9 | use Pouzor\MongoDBBundle\Constants\DriverClasses; |
12 | 10 | use Pouzor\MongoDBBundle\Constants\Query; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * Repository constructor. |
54 | 54 | * @param $name |
55 | - * @param $manager |
|
55 | + * @param \Pouzor\MongoDBBundle\DocumentManager\DocumentManager $manager |
|
56 | 56 | */ |
57 | 57 | public function __construct($name, $manager) |
58 | 58 | { |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | /** |
546 | 546 | * Return the max value for a field in a collection |
547 | 547 | * |
548 | - * @param $field |
|
548 | + * @param string $field |
|
549 | 549 | * @param array $query |
550 | 550 | * @param array $options |
551 | 551 | * @return mixed |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | /** |
583 | 583 | * Return the min value for a field in a collection |
584 | 584 | * |
585 | - * @param $field |
|
585 | + * @param string $field |
|
586 | 586 | * @param array $query |
587 | 587 | * @param array $options |
588 | 588 | * @return \Traversable |
@@ -85,10 +85,10 @@ discard block |
||
85 | 85 | if (preg_match($regex, $re->getMessage(), $output)) { |
86 | 86 | $name = $output['name']; |
87 | 87 | |
88 | - $this->logger->info('Dropping index ' . $name); |
|
88 | + $this->logger->info('Dropping index '.$name); |
|
89 | 89 | $result = $this->collection->dropIndex($name); |
90 | 90 | |
91 | - $this->logger->info('Result from dropping index ' . $name, $result); |
|
91 | + $this->logger->info('Result from dropping index '.$name, $result); |
|
92 | 92 | |
93 | 93 | $this->ensureIndex($fields, $options, $callback); |
94 | 94 | } |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | $query = [$field => ['$gt' => $min, '$lte' => $max]]; |
525 | 525 | |
526 | 526 | $this->logger->info( |
527 | - 'Counting ' . $field, |
|
527 | + 'Counting '.$field, |
|
528 | 528 | [ |
529 | 529 | 'filter' => [ |
530 | 530 | $field => ['$gt' => $min, '$lte' => $max] |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | ] |
581 | 581 | )->toArray(); |
582 | 582 | |
583 | - return ArrayAccessor::dget($result, '0.' . $field); |
|
583 | + return ArrayAccessor::dget($result, '0.'.$field); |
|
584 | 584 | |
585 | 585 | } |
586 | 586 | |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | ] |
618 | 618 | )->toArray(); |
619 | 619 | |
620 | - return ArrayAccessor::dget($result, '0.' . $field); |
|
620 | + return ArrayAccessor::dget($result, '0.'.$field); |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | /** |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | { |
631 | 631 | |
632 | 632 | $this->logger->info( |
633 | - 'Distinct over ' . $field, |
|
633 | + 'Distinct over '.$field, |
|
634 | 634 | [ |
635 | 635 | 'filter' => $filter, |
636 | 636 | 'options' => $options, |
@@ -672,28 +672,28 @@ discard block |
||
672 | 672 | * Sort |
673 | 673 | */ |
674 | 674 | if (isset($options[Query::SORT]) && !is_array($options[Query::SORT])) { |
675 | - throw new \InvalidArgumentException(Query::SORT . ' option must be an array'); |
|
675 | + throw new \InvalidArgumentException(Query::SORT.' option must be an array'); |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | /** |
679 | 679 | * Proj |
680 | 680 | */ |
681 | 681 | if (isset($options[Query::PROJECTION]) && !is_array($options[Query::PROJECTION])) { |
682 | - throw new \InvalidArgumentException(Query::PROJECTION . ' option must be an array'); |
|
682 | + throw new \InvalidArgumentException(Query::PROJECTION.' option must be an array'); |
|
683 | 683 | } |
684 | 684 | |
685 | 685 | /** |
686 | 686 | * limit |
687 | 687 | */ |
688 | 688 | if (isset($options[Query::LIMIT]) && !is_integer($options[Query::LIMIT])) { |
689 | - throw new \InvalidArgumentException(Query::LIMIT . " option must be an integer"); |
|
689 | + throw new \InvalidArgumentException(Query::LIMIT." option must be an integer"); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | /** |
693 | 693 | * offset |
694 | 694 | */ |
695 | 695 | if (isset($options[Query::OFFSET]) && !is_integer($options[Query::OFFSET])) { |
696 | - throw new \InvalidArgumentException(Query::OFFSET . ' option must be an integer'); |
|
696 | + throw new \InvalidArgumentException(Query::OFFSET.' option must be an integer'); |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | // TODO validate other options |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $keys = explode('.', $path); |
57 | 57 | foreach ($keys as $k) { |
58 | 58 | if (isset($data[$k])) { |
59 | - $data =& $data[$k]; |
|
59 | + $data = & $data[$k]; |
|
60 | 60 | } else { |
61 | 61 | return $default; |
62 | 62 | } |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | $last = array_pop($keys); |
95 | 95 | foreach ($keys as $k) { |
96 | 96 | if (isset($data[$k]) && is_array($data[$k])) { |
97 | - $data =& $data[$k]; |
|
97 | + $data = & $data[$k]; |
|
98 | 98 | } else { |
99 | 99 | $data[$k] = array(); |
100 | - $data =& $data[$k]; |
|
100 | + $data = & $data[$k]; |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | $data[$last] = $value; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $last = array_pop($keys); |
133 | 133 | foreach ($keys as $k) { |
134 | 134 | if (isset($data[$k]) && is_array($data[$k])) { |
135 | - $data =& $data[$k]; |
|
135 | + $data = & $data[$k]; |
|
136 | 136 | } else { |
137 | 137 | return null; |
138 | 138 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $last = array_pop($keys); |
180 | 180 | foreach ($keys as $k) { |
181 | 181 | if (isset($data[$k]) && is_array($data[$k])) { |
182 | - $data =& $data[$k]; |
|
182 | + $data = & $data[$k]; |
|
183 | 183 | } else { |
184 | 184 | return; |
185 | 185 | } |
@@ -195,8 +195,9 @@ |
||
195 | 195 | */ |
196 | 196 | public static function get_key_exist($array, $key, $default = null) { |
197 | 197 | |
198 | - if (isset($array[$key])) |
|
199 | - return $array[$key]; |
|
198 | + if (isset($array[$key])) { |
|
199 | + return $array[$key]; |
|
200 | + } |
|
200 | 201 | |
201 | 202 | return $default; |
202 | 203 |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | ->beforeNormalization() |
71 | 71 | // Handle readPreferenceTag XML nodes |
72 | 72 | ->ifTrue( |
73 | - function ($v) { |
|
73 | + function($v) { |
|
74 | 74 | return isset($v['readPreferenceTag']); |
75 | 75 | } |
76 | 76 | ) |
77 | 77 | ->then( |
78 | - function ($v) { |
|
78 | + function($v) { |
|
79 | 79 | // Equivalent of fixXmlConfig() for inner node |
80 | 80 | if (isset($v['readPreferenceTag']['name'])) { |
81 | 81 | $v['readPreferenceTag'] = array($v['readPreferenceTag']); |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | ->end() |
98 | 98 | ->validate() |
99 | 99 | ->ifTrue( |
100 | - function ($v) { |
|
100 | + function($v) { |
|
101 | 101 | return count($v['readPreferenceTags']) === 0; |
102 | 102 | } |
103 | 103 | ) |
104 | 104 | ->then( |
105 | - function ($v) { |
|
105 | + function($v) { |
|
106 | 106 | unset($v['readPreferenceTags']); |
107 | 107 | |
108 | 108 | return $v; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | // note that this method is called loadInternal and not load |
22 | 22 | protected function loadInternal(array $mergedConfig, ContainerBuilder $container) |
23 | 23 | { |
24 | - $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
|
24 | + $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
25 | 25 | $loader->load('services.yml'); |
26 | 26 | |
27 | 27 | foreach ($mergedConfig['connections'] as $name => $con) { |
@@ -30,15 +30,15 @@ discard block |
||
30 | 30 | file_get_contents($con['schema']) |
31 | 31 | ); |
32 | 32 | |
33 | - $def = $container->register('document.manager.' . $name, DocumentManager::class); |
|
33 | + $def = $container->register('document.manager.'.$name, DocumentManager::class); |
|
34 | 34 | $def->addTag('document.manager', ['name' => $name]); |
35 | 35 | $def->setArguments([$con, new Reference('logger')]); |
36 | 36 | $def->addTag('monolog.logger', ['channel' => 'odm.mongo']); |
37 | 37 | } |
38 | 38 | |
39 | 39 | if (isset($mergedConfig['default_connection']) && $container->hasDefinition( |
40 | - 'document.manager.' . $mergedConfig['default_connection'])) { |
|
41 | - $container->setAlias('document.manager', 'document.manager.' . $mergedConfig['default_connection']); |
|
40 | + 'document.manager.'.$mergedConfig['default_connection'])) { |
|
41 | + $container->setAlias('document.manager', 'document.manager.'.$mergedConfig['default_connection']); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
@@ -39,7 +39,7 @@ |
||
39 | 39 | $rebuild = $input->getOption('rebuild'); |
40 | 40 | $collection = $input->getOption('collection'); |
41 | 41 | |
42 | - $callback = function ($name) use ($style) { |
|
42 | + $callback = function($name) use ($style) { |
|
43 | 43 | $style->comment(sprintf('%s : Ok', $name)); |
44 | 44 | }; |
45 | 45 |