diff --git a/.php_cs b/.php_cs index 11ce3345d..e01869ce0 100644 --- a/.php_cs +++ b/.php_cs @@ -5,6 +5,12 @@ function php_cs() { ->exclude('benchmarks') ->exclude('docs') ->exclude('util') + ->exclude('.github') + ->exclude('util') + ->exclude('travis') + ->exclude('util/cache') + ->exclude('util/elasticsearch') + ->exclude('vendor') ->in(__DIR__); return Symfony\CS\Config\Config::create() diff --git a/src/Elasticsearch/Client.php b/src/Elasticsearch/Client.php index ac6d4a4d6..56b5ba1e5 100644 --- a/src/Elasticsearch/Client.php +++ b/src/Elasticsearch/Client.php @@ -1441,7 +1441,8 @@ public function extractArgument(&$params, $arg) } } - private function verifyNotNullOrEmpty($name, $var) { + private function verifyNotNullOrEmpty($name, $var) + { if ($var === null) { throw new InvalidArgumentException("$name cannot be null."); } diff --git a/src/Elasticsearch/ClientBuilder.php b/src/Elasticsearch/ClientBuilder.php index dbbbbc9f3..0814edb81 100644 --- a/src/Elasticsearch/ClientBuilder.php +++ b/src/Elasticsearch/ClientBuilder.php @@ -106,7 +106,8 @@ public static function create() * @throws Common\Exceptions\RuntimeException * @return \Elasticsearch\Client */ - public static function fromConfig($config, $quiet = false) { + public static function fromConfig($config, $quiet = false) + { $builder = new self; foreach ($config as $key => $value) { $method = "set$key"; diff --git a/src/Elasticsearch/ConnectionPool/SimpleConnectionPool.php b/src/Elasticsearch/ConnectionPool/SimpleConnectionPool.php index 97a43b7a9..5b6da46ca 100644 --- a/src/Elasticsearch/ConnectionPool/SimpleConnectionPool.php +++ b/src/Elasticsearch/ConnectionPool/SimpleConnectionPool.php @@ -32,5 +32,4 @@ public function nextConnection($force = false) public function scheduleCheck() { } - } diff --git a/src/Elasticsearch/Connections/Connection.php b/src/Elasticsearch/Connections/Connection.php index ac7e113a5..c1d174666 100644 --- a/src/Elasticsearch/Connections/Connection.php +++ b/src/Elasticsearch/Connections/Connection.php @@ -187,7 +187,6 @@ private function wrapHandler(callable $handler, LoggerInterface $logger, LoggerI if (isset($response['error']) === true) { if ($response['error'] instanceof ConnectException || $response['error'] instanceof RingException) { - $this->log->warning("Curl exception encountered."); $exception = $this->getCurlRetryException($request, $response); @@ -566,7 +565,7 @@ private function process4xxError($request, $response, $ignore) $exception = new Conflict409Exception($responseBody, $statusCode); } elseif ($statusCode === 400 && strpos($responseBody, 'script_lang not supported') !== false) { $exception = new ScriptLangNotSupportedException($responseBody. $statusCode); - } elseif ($statusCode === 408 ) { + } elseif ($statusCode === 408) { $exception = new RequestTimeout408Exception($responseBody, $statusCode); } @@ -628,15 +627,18 @@ private function process5xxError($request, $response, $ignore) throw $exception; } - private function tryDeserialize400Error($response) { + private function tryDeserialize400Error($response) + { return $this->tryDeserializeError($response, 'Elasticsearch\Common\Exceptions\BadRequest400Exception'); } - private function tryDeserialize500Error($response) { + private function tryDeserialize500Error($response) + { return $this->tryDeserializeError($response, 'Elasticsearch\Common\Exceptions\ServerErrorResponseException'); } - private function tryDeserializeError($response, $errorClass) { + private function tryDeserializeError($response, $errorClass) + { $error = $this->serializer->deserialize($response['body'], $response['transfer_stats']); if (is_array($error) === true) { // 2.0 structured exceptions @@ -655,7 +657,6 @@ private function tryDeserializeError($response, $errorClass) { $original = new $errorClass($response['body'], $response['status']); return new $errorClass("$type: $cause", $response['status'], $original); - } elseif (isset($error['error']) === true) { // <2.0 semi-structured exceptions $original = new $errorClass($response['body'], $response['status']); @@ -666,7 +667,6 @@ private function tryDeserializeError($response, $errorClass) { // <2.0 "i just blew up" nonstructured exception // $error is an array but we don't know the format, reuse the response body instead return new $errorClass($response['body'], $response['status']); - } // <2.0 "i just blew up" nonstructured exception diff --git a/src/Elasticsearch/Endpoints/Cat/Segments.php b/src/Elasticsearch/Endpoints/Cat/Segments.php index 89648bbfd..519d3c6ff 100644 --- a/src/Elasticsearch/Endpoints/Cat/Segments.php +++ b/src/Elasticsearch/Endpoints/Cat/Segments.php @@ -58,4 +58,4 @@ protected function getMethod() { return 'GET'; } -} \ No newline at end of file +} diff --git a/src/Elasticsearch/Endpoints/Indices/Flush.php b/src/Elasticsearch/Endpoints/Indices/Flush.php index 55a3eb279..93c0854bf 100644 --- a/src/Elasticsearch/Endpoints/Indices/Flush.php +++ b/src/Elasticsearch/Endpoints/Indices/Flush.php @@ -17,7 +17,8 @@ class Flush extends AbstractEndpoint { protected $synced = false; - public function setSynced($synced) { + public function setSynced($synced) + { $this->synced = $synced; } diff --git a/src/Elasticsearch/Endpoints/Indices/ShardStores.php b/src/Elasticsearch/Endpoints/Indices/ShardStores.php index 2976c91ac..438c2bb55 100644 --- a/src/Elasticsearch/Endpoints/Indices/ShardStores.php +++ b/src/Elasticsearch/Endpoints/Indices/ShardStores.php @@ -56,4 +56,4 @@ protected function getMethod() { return 'GET'; } -} \ No newline at end of file +} diff --git a/src/Elasticsearch/Endpoints/Indices/Upgrade/Get.php b/src/Elasticsearch/Endpoints/Indices/Upgrade/Get.php index 5c3e947e1..829c5bb4a 100644 --- a/src/Elasticsearch/Endpoints/Indices/Upgrade/Get.php +++ b/src/Elasticsearch/Endpoints/Indices/Upgrade/Get.php @@ -62,4 +62,4 @@ protected function getMethod() { return 'GET'; } -} \ No newline at end of file +} diff --git a/src/Elasticsearch/Endpoints/Indices/Upgrade/Post.php b/src/Elasticsearch/Endpoints/Indices/Upgrade/Post.php index eaddc78fe..2de64037b 100644 --- a/src/Elasticsearch/Endpoints/Indices/Upgrade/Post.php +++ b/src/Elasticsearch/Endpoints/Indices/Upgrade/Post.php @@ -62,4 +62,4 @@ protected function getMethod() { return 'POST'; } -} \ No newline at end of file +} diff --git a/src/Elasticsearch/Endpoints/Reindex.php b/src/Elasticsearch/Endpoints/Reindex.php index 9ea5d857e..265a6e27b 100644 --- a/src/Elasticsearch/Endpoints/Reindex.php +++ b/src/Elasticsearch/Endpoints/Reindex.php @@ -60,4 +60,4 @@ public function setBody($body) return $this; } -} \ No newline at end of file +} diff --git a/src/Elasticsearch/Endpoints/RenderSearchTemplate.php b/src/Elasticsearch/Endpoints/RenderSearchTemplate.php index 3ef06a03e..12a4ceade 100644 --- a/src/Elasticsearch/Endpoints/RenderSearchTemplate.php +++ b/src/Elasticsearch/Endpoints/RenderSearchTemplate.php @@ -74,4 +74,4 @@ protected function getMethod() { return 'GET'; } -} \ No newline at end of file +} diff --git a/src/Elasticsearch/Helper/Iterators/SearchHitIterator.php b/src/Elasticsearch/Helper/Iterators/SearchHitIterator.php index 3a40c0891..38695c337 100644 --- a/src/Elasticsearch/Helper/Iterators/SearchHitIterator.php +++ b/src/Elasticsearch/Helper/Iterators/SearchHitIterator.php @@ -14,12 +14,13 @@ * @link http://elastic.co * @see Iterator */ -class SearchHitIterator implements Iterator, \Countable { +class SearchHitIterator implements Iterator, \Countable +{ /** * @var SearchResponseIterator */ - private $search_responses; + private $search_responses; /** * @var int @@ -64,7 +65,7 @@ public function rewind() // The first page may be empty. In that case, the next page is fetched. $current_page = $this->search_responses->current(); - if($this->search_responses->valid() && empty($current_page['hits']['hits'])) { + if ($this->search_responses->valid() && empty($current_page['hits']['hits'])) { $this->search_responses->next(); } @@ -89,7 +90,7 @@ public function next() $this->current_key++; $this->current_hit_index++; $current_page = $this->search_responses->current(); - if(isset($current_page['hits']['hits'][$this->current_hit_index])) { + if (isset($current_page['hits']['hits'][$this->current_hit_index])) { $this->current_hit_data = $current_page['hits']['hits'][$this->current_hit_index]; } else { $this->search_responses->next(); @@ -137,14 +138,13 @@ public function key() */ private function readPageData() { - if($this->search_responses->valid()) { + if ($this->search_responses->valid()) { $current_page = $this->search_responses->current(); $this->current_hit_index = 0; $this->current_hit_data = $current_page['hits']['hits'][$this->current_hit_index]; } else { $this->current_hit_data = null; } - } /** diff --git a/src/Elasticsearch/Helper/Iterators/SearchResponseIterator.php b/src/Elasticsearch/Helper/Iterators/SearchResponseIterator.php index 49366ec06..239000c6c 100644 --- a/src/Elasticsearch/Helper/Iterators/SearchResponseIterator.php +++ b/src/Elasticsearch/Helper/Iterators/SearchResponseIterator.php @@ -15,7 +15,8 @@ * @link http://elastic.co * @see Iterator */ -class SearchResponseIterator implements Iterator { +class SearchResponseIterator implements Iterator +{ /** * @var Client @@ -67,7 +68,8 @@ public function __construct(Client $client, array $search_params) /** * Destructor */ - public function __destruct() { + public function __destruct() + { $this->clearScroll(); } diff --git a/src/Elasticsearch/Namespaces/IngestNamespace.php b/src/Elasticsearch/Namespaces/IngestNamespace.php index 643577c4e..864934650 100644 --- a/src/Elasticsearch/Namespaces/IngestNamespace.php +++ b/src/Elasticsearch/Namespaces/IngestNamespace.php @@ -1,6 +1,7 @@ resultOrFuture($response); } - } diff --git a/src/Elasticsearch/Namespaces/TasksNamespace.php b/src/Elasticsearch/Namespaces/TasksNamespace.php index f75fb4124..0b662b11f 100644 --- a/src/Elasticsearch/Namespaces/TasksNamespace.php +++ b/src/Elasticsearch/Namespaces/TasksNamespace.php @@ -1,10 +1,10 @@ resultOrFuture($response); } - - } diff --git a/tests/Elasticsearch/Tests/ClientTest.php b/tests/Elasticsearch/Tests/ClientTest.php index 01d203fe7..a5b0629ba 100644 --- a/tests/Elasticsearch/Tests/ClientTest.php +++ b/tests/Elasticsearch/Tests/ClientTest.php @@ -168,7 +168,7 @@ public function testArrayOfEmptyStringDelete() try { $client->delete([ - 'index' => ['','',''], + 'index' => ['', '', ''], 'type' => 'test', 'id' => 'test' ]); @@ -180,7 +180,7 @@ public function testArrayOfEmptyStringDelete() try { $client->delete([ 'index' => 'test', - 'type' => ['','',''], + 'type' => ['', '', ''], 'id' => 'test' ]); $this->fail("InvalidArgumentException was not thrown"); @@ -266,6 +266,4 @@ public function testMaxRetriesException() throw $e; } } - - } diff --git a/tests/Elasticsearch/Tests/ConnectionPool/StaticConnectionPoolTest.php b/tests/Elasticsearch/Tests/ConnectionPool/StaticConnectionPoolTest.php index 18a6afa11..d8466db9b 100644 --- a/tests/Elasticsearch/Tests/ConnectionPool/StaticConnectionPoolTest.php +++ b/tests/Elasticsearch/Tests/ConnectionPool/StaticConnectionPoolTest.php @@ -210,7 +210,8 @@ public function testAllExceptLastHostFailPingRevivesPreSkip() $this->assertEquals($goodConnection, $ret); } - public function testCustomConnectionPoolIT() { + public function testCustomConnectionPoolIT() + { $clientBuilder = \Elasticsearch\ClientBuilder::create(); $clientBuilder->setHosts(['localhost:1']); $client = $clientBuilder diff --git a/tests/Elasticsearch/Tests/Helper/Iterators/SearchResponseIteratorTest.php b/tests/Elasticsearch/Tests/Helper/Iterators/SearchResponseIteratorTest.php index a77962271..8b1ae893c 100644 --- a/tests/Elasticsearch/Tests/Helper/Iterators/SearchResponseIteratorTest.php +++ b/tests/Elasticsearch/Tests/Helper/Iterators/SearchResponseIteratorTest.php @@ -15,12 +15,13 @@ class SearchResponseIteratorTest extends \PHPUnit_Framework_TestCase { - public function tearDown() { + public function tearDown() + { m::close(); } - public function testWithNoResults() { - + public function testWithNoResults() + { $search_params = array( 'search_type' => 'scan', 'scroll' => '5m', @@ -77,7 +78,7 @@ public function testWithNoResults() { $responses = new SearchResponseIterator($mock_client, $search_params); - foreach($responses as $i => $response) { + foreach ($responses as $i => $response) { } $this->assertEquals(0, $i); @@ -178,10 +179,9 @@ public function testWithScan() $responses = new SearchResponseIterator($mock_client, $search_params); - foreach($responses as $i => $response) { + foreach ($responses as $i => $response) { } $this->assertEquals(2, $i); } - } diff --git a/tests/Elasticsearch/Tests/YamlRunnerTest.php b/tests/Elasticsearch/Tests/YamlRunnerTest.php index 47bfbbe69..f4349d577 100644 --- a/tests/Elasticsearch/Tests/YamlRunnerTest.php +++ b/tests/Elasticsearch/Tests/YamlRunnerTest.php @@ -359,7 +359,7 @@ public function testFutureModeYaml() } } - static function replaceWithStash($values, $stash) + public static function replaceWithStash($values, $stash) { if (count($stash) === 0) { return $values; @@ -372,7 +372,6 @@ static function replaceWithStash($values, $stash) $item = $stash[$item]; } } elseif (is_object($item) === true) { - $tItem = json_decode(json_encode($item), true); // Have to make sure we don't convert empty objects ( {} ) into arrays @@ -488,7 +487,6 @@ private function executeTestCase($test, $testFile, $future) if (empty($settings) === true) { $response = YamlRunnerTest::replaceWithStash($response, $stash); $this->assertTruthy($response, $settings); - } else { $settings = YamlRunnerTest::replaceWithStash($settings, $stash); echo "settings after replace: "; @@ -519,7 +517,6 @@ private function executeTestCase($test, $testFile, $future) print_r($stash); echo "\n"; ob_flush(); - } elseif ($operator === "length") { $expectedCount = $this->getValue($settings, key($settings)); $this->assertCount($expectedCount, $this->getNestedVar($response, key($settings))); @@ -578,7 +575,8 @@ private function executeTestCase($test, $testFile, $future) } } - private function handleCaughtException(\Exception $exception, $expectedError) { + private function handleCaughtException(\Exception $exception, $expectedError) + { $reflect = new ReflectionClass($exception); $caught = $reflect->getShortName(); $passed = false; @@ -627,7 +625,8 @@ private function handleCaughtException(\Exception $exception, $expectedError) { } - private static function checkExceptionRegex($expectedError, \Exception $exception) { + private static function checkExceptionRegex($expectedError, \Exception $exception) + { return isset($expectedError) === true && preg_match("/$expectedError/", $exception->getMessage()) === 1; } @@ -728,7 +727,8 @@ private function checkForTimestamp($file, $document) * @param $file * @return mixed */ - private function checkForList($document) { + private function checkForList($document) + { return str_replace("tasks.list", "tasks.get", $document); }