diff --git a/CHANGELOG.md b/CHANGELOG.md index 89f44903a0..83b3c0594b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file based on the ### Improvements - Update Elasticsearch dependency to 1.7.0 and update plugin dependencies +- Update php-cs-fixer to 1.10 [#898](https://github.com/ruflin/Elastica/pull/898) ### Deprecated diff --git a/Dockerfile b/Dockerfile index 0177e8cddd..4220a0692a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,7 +37,7 @@ RUN composer global require "mayflower/php-codebrowser=~1.1" RUN composer global require "sebastian/phpcpd=~2.0" RUN composer global require "squizlabs/php_codesniffer=~2.3" RUN composer global require "phploc/phploc=~2.1" -RUN composer global require "fabpot/php-cs-fixer=1.8.1" +RUN composer global require "fabpot/php-cs-fixer=1.10.*" # Documentor dependencies diff --git a/docker-compose.yml b/docker-compose.yml index 674d6e9e09..bc188f5490 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ elastica: #build: . # In case the image must be built locally - image: ruflin/elastica + image: ruflin/elastica # comment out to build locally ports: - "9200:9200" volumes: diff --git a/lib/Elastica/Aggregation/ReverseNested.php b/lib/Elastica/Aggregation/ReverseNested.php index 5216ae8521..bd7a3ecdce 100644 --- a/lib/Elastica/Aggregation/ReverseNested.php +++ b/lib/Elastica/Aggregation/ReverseNested.php @@ -34,7 +34,7 @@ public function setPath($path) } /** - * {@inheritDoc} + * {@inheritdoc} */ public function toArray() { diff --git a/lib/Elastica/Bulk/ResponseSet.php b/lib/Elastica/Bulk/ResponseSet.php index 1837203f54..4021cbee6d 100644 --- a/lib/Elastica/Bulk/ResponseSet.php +++ b/lib/Elastica/Bulk/ResponseSet.php @@ -104,7 +104,7 @@ public function current() */ public function next() { - $this->_position++; + ++$this->_position; } /** diff --git a/lib/Elastica/Facet/Range.php b/lib/Elastica/Facet/Range.php index f81caf3d24..d21218a8bd 100644 --- a/lib/Elastica/Facet/Range.php +++ b/lib/Elastica/Facet/Range.php @@ -118,13 +118,13 @@ public function toArray() */ $fieldTypesSet = 0; if (isset($this->_params['field'])) { - $fieldTypesSet++; + ++$fieldTypesSet; } if (isset($this->_params['key_field'])) { - $fieldTypesSet++; + ++$fieldTypesSet; } if (isset($this->_params['key_script'])) { - $fieldTypesSet++; + ++$fieldTypesSet; } if ($fieldTypesSet === 0) { diff --git a/lib/Elastica/Multi/ResultSet.php b/lib/Elastica/Multi/ResultSet.php index 4d4186af77..f6a4cefb3a 100644 --- a/lib/Elastica/Multi/ResultSet.php +++ b/lib/Elastica/Multi/ResultSet.php @@ -128,7 +128,7 @@ public function current() */ public function next() { - $this->_position++; + ++$this->_position; } /** diff --git a/lib/Elastica/ResultSet.php b/lib/Elastica/ResultSet.php index ae4141b950..f1260e4f87 100644 --- a/lib/Elastica/ResultSet.php +++ b/lib/Elastica/ResultSet.php @@ -329,7 +329,7 @@ public function current() */ public function next() { - $this->_position++; + ++$this->_position; return $this->current(); } diff --git a/test/lib/Elastica/Test/Aggregation/SignificantTermsTest.php b/test/lib/Elastica/Test/Aggregation/SignificantTermsTest.php index 8960768bf1..854234593c 100644 --- a/test/lib/Elastica/Test/Aggregation/SignificantTermsTest.php +++ b/test/lib/Elastica/Test/Aggregation/SignificantTermsTest.php @@ -15,7 +15,7 @@ protected function _getIndexForTest() $colors = array('blue', 'blue', 'red', 'red', 'green', 'yellow', 'white', 'cyan', 'magenta'); $temperatures = array(1500, 1500, 1500, 1500, 2500, 3500, 4500, 5500, 6500, 7500, 7500, 8500, 9500); $docs = array(); - for ($i = 0;$i < 250;$i++) { + for ($i = 0;$i < 250;++$i) { $docs[] = new Document($i, array('color' => $colors[$i % count($colors)], 'temperature' => $temperatures[$i % count($temperatures)])); } $index->getType('test')->addDocuments($docs); diff --git a/test/lib/Elastica/Test/BulkTest.php b/test/lib/Elastica/Test/BulkTest.php index c3ff15bc6a..438bcb7e07 100644 --- a/test/lib/Elastica/Test/BulkTest.php +++ b/test/lib/Elastica/Test/BulkTest.php @@ -709,10 +709,10 @@ public function testMemoryUsage() $startMemory = memory_get_usage(); - for ($n = 1; $n < 10; $n++) { + for ($n = 1; $n < 10; ++$n) { $docs = array(); - for ($i = 1; $i <= 3000; $i++) { + for ($i = 1; $i <= 3000; ++$i) { $docs[] = new Document(uniqid(), $data); } diff --git a/test/lib/Elastica/Test/ClientTest.php b/test/lib/Elastica/Test/ClientTest.php index a5f2b46fff..568afc35e2 100644 --- a/test/lib/Elastica/Test/ClientTest.php +++ b/test/lib/Elastica/Test/ClientTest.php @@ -610,7 +610,7 @@ public function testCallback() $object->assertInstanceOf('Elastica\Exception\ConnectionException', $exception); $object->assertInstanceOf('Elastica\Client', $client); $object->assertFalse($connection->isEnabled()); - $count++; + ++$count; }; $client = $this->_getClient(array(), $callback); @@ -993,7 +993,7 @@ public function testUpdateDocumentPopulateFields() public function testAddDocumentsWithoutIds() { $docs = array(); - for ($i = 0; $i < 10; $i++) { + for ($i = 0; $i < 10; ++$i) { $docs[] = new Document(null, array('pos' => $i)); } diff --git a/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php b/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php index ee03587a1d..369d06f145 100644 --- a/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php +++ b/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php @@ -93,7 +93,7 @@ protected function getConnections($quantity = 1) $params = array(); $connections = array(); - for ($i = 0; $i < $quantity; $i++) { + for ($i = 0; $i < $quantity; ++$i) { $connections[] = new Connection($params); } diff --git a/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTest.php b/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTest.php index de8290ae85..44b5f026c4 100644 --- a/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTest.php +++ b/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTest.php @@ -19,7 +19,7 @@ public function testInvoke() $count = 0; $callback = function ($connections) use (&$count) { - $count++; + ++$count; }; $strategy = new CallbackStrategy($callback); diff --git a/test/lib/Elastica/Test/Filter/IdsTest.php b/test/lib/Elastica/Test/Filter/IdsTest.php index 8395f39a71..0d8d2051b8 100644 --- a/test/lib/Elastica/Test/Filter/IdsTest.php +++ b/test/lib/Elastica/Test/Filter/IdsTest.php @@ -15,14 +15,14 @@ protected function _getIndexForTest() // Add documents to first type $docs = array(); - for ($i = 1; $i < 100; $i++) { + for ($i = 1; $i < 100; ++$i) { $docs[] = new Document($i, array('name' => 'ruflin')); } $index->getType('helloworld1')->addDocuments($docs); // Add documents to second type $docs = array(); - for ($i = 1; $i < 100; $i++) { + for ($i = 1; $i < 100; ++$i) { $docs[] = new Document($i, array('name' => 'ruflin')); } // This is a special id that will only be in the second type diff --git a/test/lib/Elastica/Test/Query/BoolQueryTest.php b/test/lib/Elastica/Test/Query/BoolQueryTest.php index 211d0c23cf..a7d4668e3c 100644 --- a/test/lib/Elastica/Test/Query/BoolQueryTest.php +++ b/test/lib/Elastica/Test/Query/BoolQueryTest.php @@ -128,7 +128,7 @@ public function testEmptyBoolQuery() $type = new Type($index, 'test'); $docNumber = 3; - for ($i = 0; $i < $docNumber; $i++) { + for ($i = 0; $i < $docNumber; ++$i) { $doc = new Document($i, array('email' => 'test@test.com')); $type->addDocument($doc); } @@ -155,7 +155,7 @@ public function testOldObject() $type = new Type($index, 'test'); $docNumber = 3; - for ($i = 0; $i < $docNumber; $i++) { + for ($i = 0; $i < $docNumber; ++$i) { $doc = new Document($i, array('email' => 'test@test.com')); $type->addDocument($doc); } diff --git a/test/lib/Elastica/Test/Query/CommonTest.php b/test/lib/Elastica/Test/Query/CommonTest.php index 016213a8c2..223cd1ace7 100644 --- a/test/lib/Elastica/Test/Query/CommonTest.php +++ b/test/lib/Elastica/Test/Query/CommonTest.php @@ -42,7 +42,7 @@ public function testQuery() new Document(3, array('body' => 'foo bar baz bat')), ); //add documents to create common terms - for ($i = 4; $i < 24; $i++) { + for ($i = 4; $i < 24; ++$i) { $docs[] = new Document($i, array('body' => 'foo bar')); } $type->addDocuments($docs); diff --git a/test/lib/Elastica/Test/Query/QueryStringTest.php b/test/lib/Elastica/Test/Query/QueryStringTest.php index 5b549a3085..3105303d83 100644 --- a/test/lib/Elastica/Test/Query/QueryStringTest.php +++ b/test/lib/Elastica/Test/Query/QueryStringTest.php @@ -23,7 +23,7 @@ public function testSearchMultipleFields() $fields = array(); $max = rand() % 10 + 1; - for ($i = 0; $i < $max; $i++) { + for ($i = 0; $i < $max; ++$i) { $fields[] = md5(rand()); } diff --git a/test/lib/Elastica/Test/QueryBuilder/DSL/AbstractDSLTest.php b/test/lib/Elastica/Test/QueryBuilder/DSL/AbstractDSLTest.php index 3e44f4633c..30cd09c317 100644 --- a/test/lib/Elastica/Test/QueryBuilder/DSL/AbstractDSLTest.php +++ b/test/lib/Elastica/Test/QueryBuilder/DSL/AbstractDSLTest.php @@ -55,7 +55,7 @@ protected function _assertParametersEquals($left, $right) { $this->assertEquals(count($left), count($right), 'Parameters count mismatch'); - for ($i = 0; $i < count($left); $i++) { + for ($i = 0; $i < count($left); ++$i) { $this->assertEquals($left[$i]->getName(), $right[$i]->getName(), 'Parameters names mismatch'); $this->assertEquals($left[$i]->isOptional(), $right[$i]->isOptional(), 'Parameters optionality mismatch'); $this->assertEquals($this->_getHintName($left[$i]), $this->_getHintName($right[$i]), 'Parameters typehints mismatch'); diff --git a/test/lib/Elastica/Test/ScanAndScrollTest.php b/test/lib/Elastica/Test/ScanAndScrollTest.php index 9f06f9e61b..bfe61f627f 100644 --- a/test/lib/Elastica/Test/ScanAndScrollTest.php +++ b/test/lib/Elastica/Test/ScanAndScrollTest.php @@ -62,7 +62,7 @@ private function _prepareSearch() $index->refresh(); $docs = array(); - for ($x = 1; $x <= 12; $x++) { + for ($x = 1; $x <= 12; ++$x) { $docs[] = new Document($x, array('id' => $x, 'key' => 'value')); } diff --git a/test/lib/Elastica/Test/ScrollTest.php b/test/lib/Elastica/Test/ScrollTest.php index df5b03178c..fa60e9e27c 100644 --- a/test/lib/Elastica/Test/ScrollTest.php +++ b/test/lib/Elastica/Test/ScrollTest.php @@ -49,7 +49,7 @@ public function testForeach() $this->fail('too many iterations'); } - $count++; + ++$count; } } @@ -88,7 +88,7 @@ private function _prepareSearch() $index->refresh(); $docs = array(); - for ($x = 1; $x <= 11; $x++) { + for ($x = 1; $x <= 11; ++$x) { $docs[] = new Document($x, array('id' => $x, 'key' => 'value')); } diff --git a/test/lib/Elastica/Test/SearchTest.php b/test/lib/Elastica/Test/SearchTest.php index 905f846247..12dae08d5e 100644 --- a/test/lib/Elastica/Test/SearchTest.php +++ b/test/lib/Elastica/Test/SearchTest.php @@ -251,7 +251,7 @@ public function testSearchScrollRequest() $type = $index->getType('scrolltest'); $docs = array(); - for ($x = 1; $x <= 10; $x++) { + for ($x = 1; $x <= 10; ++$x) { $docs[] = new Document($x, array('id' => $x, 'testscroll' => 'jbafford')); } @@ -355,7 +355,7 @@ public function testArrayConfigSearch() $index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true); $docs = array(); - for ($i = 0; $i < 11; $i++) { + for ($i = 0; $i < 11; ++$i) { $docs[] = new Document($i, array('id' => 1, 'email' => 'test@test.com', 'username' => 'test')); } diff --git a/test/lib/Elastica/Test/Tool/CrossIndexTest.php b/test/lib/Elastica/Test/Tool/CrossIndexTest.php index f8fbf28002..b83730c6ac 100644 --- a/test/lib/Elastica/Test/Tool/CrossIndexTest.php +++ b/test/lib/Elastica/Test/Tool/CrossIndexTest.php @@ -123,7 +123,7 @@ public function testCopy() private function _addDocs(Type $type, $docs) { $insert = array(); - for ($i = 1; $i <= $docs; $i++) { + for ($i = 1; $i <= $docs; ++$i) { $insert[] = new Document($i, array('_id' => $i, 'key' => 'value')); } diff --git a/test/lib/Elastica/Test/Transport/TransportBenchmarkTest.php b/test/lib/Elastica/Test/Transport/TransportBenchmarkTest.php index 11a16a349a..1dcb1e4afc 100644 --- a/test/lib/Elastica/Test/Transport/TransportBenchmarkTest.php +++ b/test/lib/Elastica/Test/Transport/TransportBenchmarkTest.php @@ -46,7 +46,7 @@ public function testAddDocument(array $config, $transport) $index->create(array(), true); $times = array(); - for ($i = 0; $i < $this->_max; $i++) { + for ($i = 0; $i < $this->_max; ++$i) { $data = $this->getData($i); $doc = new Document($i, $data); $result = $type->addDocument($doc); @@ -73,7 +73,7 @@ public function testRandomRead(array $config, $transport) $type->search('test'); $times = array(); - for ($i = 0; $i < $this->_max; $i++) { + for ($i = 0; $i < $this->_max; ++$i) { $test = rand(1, $this->_max); $query = new Query(); $query->setQuery(new \Elastica\Query\MatchAll()); @@ -95,9 +95,9 @@ public function testBulk(array $config, $transport) $type = $this->getType($config); $times = array(); - for ($i = 0; $i < $this->_max; $i++) { + for ($i = 0; $i < $this->_max; ++$i) { $docs = array(); - for ($j = 0; $j < 10; $j++) { + for ($j = 0; $j < 10; ++$j) { $data = $this->getData($i.$j); $docs[] = new Document($i, $data); } @@ -142,7 +142,7 @@ public function testGetMapping(array $config, $transport) $index->refresh(); $times = array(); - for ($i = 0; $i < $this->_max; $i++) { + for ($i = 0; $i < $this->_max; ++$i) { $response = $type->request('_mapping', \Elastica\Request::GET); $times[] = $response->getQueryTime(); } @@ -195,7 +195,7 @@ protected function getData($test) 'test' => $test, 'name' => array(), ); - for ($i = 0; $i < $this->_maxData; $i++) { + for ($i = 0; $i < $this->_maxData; ++$i) { $data['name'][] = uniqid(); }