@@ -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 |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | if (preg_match($regex, $re->getMessage(), $output)) { |
93 | 93 | $name = $output['name']; |
94 | 94 | |
95 | - $this->logger->info('Dropping index ' . $name); |
|
95 | + $this->logger->info('Dropping index '.$name); |
|
96 | 96 | $result = $this->collection->dropIndex($name); |
97 | 97 | |
98 | - $this->logger->info('Result from dropping index ' . $name, $result); |
|
98 | + $this->logger->info('Result from dropping index '.$name, $result); |
|
99 | 99 | |
100 | 100 | $this->ensureIndex($fields, $options, $callback); |
101 | 101 | } |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | $query = [$field => ['$gt' => $min, '$lte' => $max]]; |
520 | 520 | |
521 | 521 | $this->logger->info( |
522 | - 'Counting ' . $field, |
|
522 | + 'Counting '.$field, |
|
523 | 523 | [ |
524 | 524 | 'filter' => [ |
525 | 525 | $field => ['$gt' => $min, '$lte' => $max] |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | ] |
576 | 576 | )->toArray(); |
577 | 577 | |
578 | - return ArrayAccessor::dget($result, '0.' . $field); |
|
578 | + return ArrayAccessor::dget($result, '0.'.$field); |
|
579 | 579 | |
580 | 580 | } |
581 | 581 | |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | ] |
613 | 613 | )->toArray(); |
614 | 614 | |
615 | - return ArrayAccessor::dget($result, '0.' . $field); |
|
615 | + return ArrayAccessor::dget($result, '0.'.$field); |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | /** |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | { |
626 | 626 | |
627 | 627 | $this->logger->info( |
628 | - 'Distinct over ' . $field, |
|
628 | + 'Distinct over '.$field, |
|
629 | 629 | [ |
630 | 630 | 'filter' => $filter, |
631 | 631 | 'options' => $options, |
@@ -667,28 +667,28 @@ discard block |
||
667 | 667 | * Sort |
668 | 668 | */ |
669 | 669 | if (isset($options[Query::SORT]) && !is_array($options[Query::SORT])) { |
670 | - throw new \InvalidArgumentException(Query::SORT . ' option must be an array'); |
|
670 | + throw new \InvalidArgumentException(Query::SORT.' option must be an array'); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | /** |
674 | 674 | * Proj |
675 | 675 | */ |
676 | 676 | if (isset($options[Query::PROJECTION]) && !is_array($options[Query::PROJECTION])) { |
677 | - throw new \InvalidArgumentException(Query::PROJECTION . ' option must be an array'); |
|
677 | + throw new \InvalidArgumentException(Query::PROJECTION.' option must be an array'); |
|
678 | 678 | } |
679 | 679 | |
680 | 680 | /** |
681 | 681 | * limit |
682 | 682 | */ |
683 | 683 | if (isset($options[Query::LIMIT]) && !is_integer($options[Query::LIMIT])) { |
684 | - throw new \InvalidArgumentException(Query::LIMIT . " option must be an integer"); |
|
684 | + throw new \InvalidArgumentException(Query::LIMIT." option must be an integer"); |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | /** |
688 | 688 | * offset |
689 | 689 | */ |
690 | 690 | if (isset($options[Query::OFFSET]) && !is_integer($options[Query::OFFSET])) { |
691 | - throw new \InvalidArgumentException(Query::OFFSET . ' option must be an array'); |
|
691 | + throw new \InvalidArgumentException(Query::OFFSET.' option must be an array'); |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | // 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 |
@@ -38,7 +38,7 @@ |
||
38 | 38 | |
39 | 39 | $manager = $this->getContainer()->get('document.manager'); |
40 | 40 | |
41 | - $callback = function ($name) use ($style) { |
|
41 | + $callback = function($name) use ($style) { |
|
42 | 42 | $style->comment(sprintf('%s : Ok', $name)); |
43 | 43 | }; |
44 | 44 |
@@ -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 | } |