for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Kunstmaan\NodeSearchBundle\Helper;
use Elasticsearch\ClientBuilder;
use Elasticsearch\Common\Exceptions\NoNodesAvailableException;
/**
* Class ElasticSearchUtil
*/
final class ElasticSearchUtil
{
/** @var array */
private static $esClientInfo;
* @return bool
public static function useVersion6()
$info = self::getESVersionInfo();
if (null !== $info) {
$versionParts = explode('.', $info['version']['number']);
$majorVersion = $versionParts[0];
return ($majorVersion > 2 && PHP_MAJOR_VERSION === 7 && !class_exists('\Elastica\Tool\CrossIndex'));
}
return false;
* @return array
private static function getESVersionInfo()
try {
if (null === self::$esClientInfo) {
$client = ClientBuilder::create()->build();
self::$esClientInfo = $client->info();
} catch (NoNodesAvailableException $e) {
self::$esClientInfo = null;
null
array
$esClientInfo
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..
return self::$esClientInfo;
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..