Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Fix code style and static analysis warnings #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(ConnectionManager $connectionManager, EventDispatche
/**
* Run a Cypher statement against the default database or the database specified.
*
* @param $query
* @param string $query
* @param null|array $parameters
* @param null|string $tag
* @param null|string $connectionAlias
Expand All @@ -74,7 +74,7 @@ public function run($query, $parameters = null, $tag = null, $connectionAlias =
throw $e;
}

return;
return null;
}

return $result;
Expand Down
2 changes: 1 addition & 1 deletion src/ClientBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function addConnection($alias, $uri, ConfigInterface $config = null)
$this->config['connections'][$alias]['uri'] = $uri;

if (null !== $config) {
if ($this->config['connections'][$alias]['config'] = $config);
$this->config['connections'][$alias]['config'] = $config;
}

return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/ClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface ClientInterface
/**
* Run a Cypher statement against the default database or the database specified.
*
* @param $query
* @param string $query
* @param null|array $parameters
* @param null|string $tag
* @param null|string $connectionAlias
Expand Down
2 changes: 1 addition & 1 deletion src/Connection/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private function buildDriver()
$port = isset($params['port']) ? (int) $params['port'] : BoltDriver::DEFAULT_TCP_PORT;
$uri = sprintf('%s://%s:%d', $params['scheme'], $params['host'], $port);
$config = null;
if (isset($params['user']) && isset($params['pass'])) {
if (isset($params['user'], $params['pass'])) {
$config = BoltConfiguration::create()->withCredentials($params['user'], $params['pass']);
}
$this->driver = BoltGraphDB::driver($uri, $config);
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/Neo4jException.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function classification()
{
$parts = explode('.', $this->statusCode);
if (!isset($parts[1])) {
throw new \InvalidArgumentException(sprintf('Could not parse exception classification "%"', $this->statusCode));
throw new \InvalidArgumentException(sprintf('Could not parse exception classification "%s"', $this->statusCode));
}

return $parts[1];
Expand Down
1 change: 1 addition & 0 deletions src/Formatter/RecordView.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public function hasValues()
}

/**
* @deprecated Use <code>get()</code> instead
* @param string $key
*
* @return \GraphAware\Neo4j\Client\Formatter\Type\Node|\GraphAware\Neo4j\Client\Formatter\Type\Relationship
Expand Down
7 changes: 2 additions & 5 deletions src/Formatter/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ class Response
public function setRawResponse($rawResponse)
{
$this->rawResponse = $rawResponse;

if (isset($rawResponse['errors'])) {
if (!empty($rawResponse['errors'])) {
$this->errors = $rawResponse['errors'][0];
}
if (!empty($rawResponse['errors'])) {
$this->errors = $rawResponse['errors'][0];
}
}

Expand Down
12 changes: 3 additions & 9 deletions src/Formatter/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use GraphAware\Common\Cypher\StatementInterface;
use GraphAware\Common\Result\AbstractRecordCursor;
use GraphAware\Common\Result\Record;
use GraphAware\Neo4j\Client\Formatter\Type\Node;
use GraphAware\Neo4j\Client\Formatter\Type\Path;
use GraphAware\Neo4j\Client\Formatter\Type\Relationship;
Expand All @@ -22,11 +21,6 @@

class Result extends AbstractRecordCursor
{
/**
* @var RecordView[]
*/
protected $records = [];

/**
* @var string[]
*/
Expand Down Expand Up @@ -103,10 +97,10 @@ public function setGraph(array $graph)
}

/**
* @param $data
* @param $graph
* @param array $data
* @param array $graph
*/
public function pushRecord($data, $graph)
public function pushRecord(array $data, array $graph)
{
$mapped = $this->array_map_deep($data, $graph);
$this->records[] = new RecordView($this->fields, $mapped);
Expand Down
2 changes: 2 additions & 0 deletions src/HttpDriver/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class Configuration extends BaseConfiguration implements ConfigInterface
protected $curlInterface;

/**
* @param HttpClient|null $httpClient
* @param RequestFactory|null $requestFactory
* @return Configuration
*/
public static function create(HttpClient $httpClient = null, RequestFactory $requestFactory = null)
Expand Down
4 changes: 0 additions & 4 deletions src/HttpDriver/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ class Driver implements DriverInterface
*/
public function __construct($uri, ConfigInterface $config = null)
{
if (null !== $config && !$config instanceof BaseConfiguration) {
throw new \RuntimeException(sprintf('Second argument to "%s" must be null or "%s"', __CLASS__, BaseConfiguration::class));
}

$this->uri = $uri;
$this->config = null !== $config ? $config : Configuration::create();
}
Expand Down
3 changes: 3 additions & 0 deletions src/HttpDriver/Result/ResultSummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class ResultSummary implements ResultSummaryInterface
*/
protected $updateStatistics;

/**
* @var array
*/
protected $notifications;

protected $type;
Expand Down
2 changes: 1 addition & 1 deletion src/HttpDriver/Result/StatementStatistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function constraintsRemoved()
}

/**
* @param $key
* @param string $key
*
* @return string
*/
Expand Down
2 changes: 1 addition & 1 deletion src/HttpDriver/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Session implements SessionInterface
public function __construct($uri, $httpClient, ConfigInterface $config)
{
if ($httpClient instanceof GuzzleClient) {
@trigger_error('Passing a Guzzle client to Session is deprecrated. Will be removed in 5.0. Use a HTTPlug client');
@trigger_error('Passing a Guzzle client to Session is deprecated. Will be removed in 5.0. Use a HTTPlug client', E_USER_DEPRECATED);
$httpClient = new Client($httpClient);
} elseif (!$httpClient instanceof HttpClient) {
throw new \RuntimeException('Second argument to Session::__construct must be an instance of Http\Client\HttpClient.');
Expand Down
8 changes: 5 additions & 3 deletions src/Stack.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ class Stack implements StackInterface
protected $hasWrites = false;

/**
* @param null $tag
* @param null|string $tag
* @param null|string $connectionAlias
*/
public function __construct($tag = null, $connectionAlias = null)
{
$this->tag = null !== $tag ? (string) $tag : null;
if (null !== $tag) {
$this->tag = (string)$tag;
}
$this->connectionAlias = $connectionAlias;
}

Expand Down Expand Up @@ -85,7 +87,7 @@ public function pushWrite($query, $parameters = null, $tag = null)
}

/**
* @param $query
* @param string $query
* @param array|null $parameters
* @param array|null $tag
*/
Expand Down
2 changes: 1 addition & 1 deletion src/StackInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function push($query, $parameters = null, $tag = null);
public function pushWrite($query, $parameters = null, $tag = null);

/**
* @param $query
* @param string $query
* @param array|null $parameters
* @param array|null $tag
*/
Expand Down