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

Commit bc92bf5

Browse files
authored
Merge pull request #92 from GensDeConfiance/cs-fixes
Cs fixes 2nd try
2 parents cf77c1c + f90ff34 commit bc92bf5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+442
-226
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.gitignore

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
vendor/
2-
test.php
1+
.php_cs.cache
32
bin/*
4-
tests/_reports
5-
tests/database_settings.yml
63
cache/
7-
neoclient.yml
84
composer.lock
5+
neoclient.yml
6+
test.php
7+
tests/_reports
8+
tests/database_settings.yml
9+
vendor/

.php_cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the GraphAware Neo4j Client package.
5+
*
6+
* (c) GraphAware Limited <http://graphaware.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
$header = <<<'EOF'
13+
This file is part of the GraphAware Neo4j Client package.
14+
15+
(c) GraphAware Limited <http://graphaware.com>
16+
17+
For the full copyright and license information, please view the LICENSE
18+
file that was distributed with this source code.
19+
EOF;
20+
21+
$finder = PhpCsFixer\Finder::create()
22+
->in(__DIR__.'/src/')
23+
->in(__DIR__.'/tests/')
24+
;
25+
26+
return PhpCsFixer\Config::create()
27+
->setRules([
28+
'@Symfony' => true,
29+
30+
'array_syntax' => ['syntax' => 'short'],
31+
'header_comment' => ['header' => $header],
32+
'linebreak_after_opening_tag' => true,
33+
'ordered_imports' => true,
34+
'phpdoc_order' => true,
35+
36+
// 'modernize_types_casting' => true,
37+
// 'no_useless_return' => true,
38+
// 'phpdoc_add_missing_param_annotation' => true,
39+
// 'protected_to_private' => true,
40+
// 'strict_param' => true,
41+
])
42+
->setFinder($finder)
43+
;

README.md

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
## Introduction
1111

12-
Neo4j-PHP-Client is the most advanced and flexible [Neo4j](http://neo4j.com) Client for PHP.
12+
Neo4j-PHP-Client is the most advanced and flexible [Neo4j](http://neo4j.com) Client for PHP.
1313

1414
### What is Neo4j?
1515

@@ -94,20 +94,20 @@ NB: The build method will process configuration settings and return you a `Clien
9494
#### Sending a Cypher Query
9595

9696
```php
97-
$client->run("CREATE (n:Person)");
97+
$client->run('CREATE (n:Person)');
9898
```
9999

100100
#### Sending a Cypher Query with parameters
101101

102102
```php
103-
$client->run("CREATE (n:Person) SET n += {infos}", ['infos' => ['name' => 'Ales', 'age' => 34]]);
103+
$client->run('CREATE (n:Person) SET n += {infos}', ['infos' => ['name' => 'Ales', 'age' => 34]]);
104104
```
105105

106106
#### Reading a Result
107107

108108
```php
109-
$result = $client->run("MATCH (n:Person) RETURN n");
110-
// a result contains always a collection (array) of Record objects
109+
$result = $client->run('MATCH (n:Person) RETURN n');
110+
// a result always contains a collection (array) of Record objects
111111

112112
// get all records
113113
$records = $result->getRecords();
@@ -120,7 +120,7 @@ $record = $result->getRecord();
120120
A `Record` object contains the values of one record from your Cypher query :
121121

122122
```php
123-
$query = "MATCH (n:Person)-[:FOLLOWS]->(friend) RETURN n.name, collect(friend) as friends";
123+
$query = 'MATCH (n:Person)-[:FOLLOWS]->(friend) RETURN n.name, collect(friend) as friends';
124124
$result = $client->run($query);
125125

126126
foreach ($result->getRecords() as $record) {
@@ -135,7 +135,6 @@ Ideally, you would stack your statements and issue them all at once in order to
135135
You can create Cypher statement stacks that act as a Bag and run this stack with the client, example :
136136

137137
```php
138-
139138
$stack = $client->stack();
140139

141140
$stack->push('CREATE (n:Person {uuid: {uuid} })', ['uuid' => '123-fff']);
@@ -204,7 +203,7 @@ Each record contains one row of values returned by the Cypher query :
204203

205204
```
206205
207-
$query = "MATCH (n:Person) n, n.name as name, n.age as age";
206+
$query = 'MATCH (n:Person) n, n.name as name, n.age as age';
208207
$result = $client->run($query);
209208
210209
foreach ($result->records() as $record) {
@@ -280,9 +279,9 @@ A `Result` is a collection of `Record` objects, every **row** you see in the bro
280279
In contrary to the previous versions of the client, there is no more automatic merging of all the records into one big record, so you will need to iterate all the records from the `Result` :
281280

282281
```php
283-
$query = "MATCH (n:Address)
282+
$query = 'MATCH (n:Address)
284283
RETURN n.address as addr, n, collect(id(n)) as ids
285-
LIMIT 5";
284+
LIMIT 5';
286285
$result = $client->run($query);
287286

288287
foreach ($result->records() as $record) {
@@ -349,7 +348,6 @@ The Client provides a Transaction object that ease how you would work with trans
349348
#### Creating a Transaction
350349

351350
```php
352-
353351
$tx = $client->transaction();
354352
```
355353

@@ -358,7 +356,7 @@ At this stage, nothing has been sent to the server yet (the statement BEGIN has
358356
#### Stack a query
359357

360358
```
361-
$tx->push("CREATE (n:Person) RETURN id(n)");
359+
$tx->push('CREATE (n:Person) RETURN id(n)');
362360
```
363361

364362
Again, until now nothing has been sent.
@@ -368,19 +366,16 @@ Again, until now nothing has been sent.
368366
Sometimes you want to get an immediate result of a statement inside the transaction, this can be done with the `run` method :
369367

370368
```php
371-
372-
$result = $tx->run("CREATE (n:Person) SET n.name = {name} RETURN id(n)", ['name' => 'Michal']);
369+
$result = $tx->run('CREATE (n:Person) SET n.name = {name} RETURN id(n)', ['name' => 'Michal']);
373370

374371
echo $result->getRecord()->value("id(n)");
375372
```
376373

377374
If the transaction has not yet begun, the BEGIN of the transaction will be done automatically.
378-
```
379375

380376
#### You can also push or run Stacks
381377

382378
```php
383-
384379
$stack = $client->stack();
385380
$stack->push('CREATE (n:Person {uuid: {uuid} })', ['uuid' => '123-fff']);
386381
$stack->push('MATCH (n:Person {uuid: {uuid1} }), (n2:Person {uuid: {uuid2} }) MERGE (n)-[:FOLLOWS]->(n2)', ['uuid1' => '123-fff', 'uuid2' => '456-ddd']);
@@ -401,7 +396,7 @@ $stack->push('CREATE (n:Person {uuid: {uuid} })', ['uuid' => '123-fff']);
401396
$stack->push('MATCH (n:Person {uuid: {uuid1} }), (n2:Person {uuid: {uuid2} }) MERGE (n)-[:FOLLOWS]->(n2)', ['uuid1' => '123-fff', 'uuid2' => '456-ddd']);
402397

403398
$tx->pushStack($stack);
404-
$tx->pushQuery("MATCH (n) RETURN count(n)");
399+
$tx->pushQuery('MATCH (n) RETURN count(n)');
405400

406401
$results = $tx->commit();
407402
```
@@ -521,7 +516,3 @@ $session = $driver->session();
521516
### License
522517

523518
The library is released under the MIT License, refer to the LICENSE file bundled with this package.
524-
525-
526-
527-

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"php-http/guzzle6-adapter": "^1.0"
3737
},
3838
"require-dev": {
39-
"phpunit/phpunit": "4.*",
39+
"friendsofphp/php-cs-fixer": "^2.0",
40+
"phpunit/phpunit": "^4.0",
4041
"symfony/stopwatch": "^3.0"
4142
},
4243
"autoload": {

src/Client.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
/**
3+
/*
44
* This file is part of the GraphAware Neo4j Client package.
55
*
66
* (c) GraphAware Limited <http://graphaware.com>
@@ -52,16 +52,16 @@ public function __construct(ConnectionManager $connectionManager, EventDispatche
5252
* @param null|string $tag
5353
* @param null|string $connectionAlias
5454
*
55-
* @return \GraphAware\Common\Result\Result|null
56-
*
5755
* @throws \GraphAware\Neo4j\Client\Exception\Neo4jExceptionInterface
56+
*
57+
* @return \GraphAware\Common\Result\Result|null
5858
*/
5959
public function run($query, $parameters = null, $tag = null, $connectionAlias = null)
6060
{
6161
$connection = $this->connectionManager->getConnection($connectionAlias);
62-
$params = null !== $parameters ? $parameters : array();
62+
$params = null !== $parameters ? $parameters : [];
6363
$statement = Statement::create($query, $params, $tag);
64-
$this->eventDispatcher->dispatch(Neo4jClientEvents::NEO4J_PRE_RUN, new PreRunEvent(array($statement)));
64+
$this->eventDispatcher->dispatch(Neo4jClientEvents::NEO4J_PRE_RUN, new PreRunEvent([$statement]));
6565

6666
try {
6767
$result = $connection->run($query, $parameters, $tag);
@@ -85,9 +85,9 @@ public function run($query, $parameters = null, $tag = null, $connectionAlias =
8585
* @param null|array $parameters
8686
* @param null|string $tag
8787
*
88-
* @return \GraphAware\Common\Result\Result
89-
*
9088
* @throws Neo4jException
89+
*
90+
* @return \GraphAware\Common\Result\Result
9191
*/
9292
public function runWrite($query, $parameters = null, $tag = null)
9393
{
@@ -103,9 +103,9 @@ public function runWrite($query, $parameters = null, $tag = null)
103103
* @param null|array $parameters
104104
* @param null|string $tag
105105
*
106-
* @return \GraphAware\Common\Result\Result
107-
*
108106
* @throws Neo4jException
107+
*
108+
* @return \GraphAware\Common\Result\Result
109109
*/
110110
public function sendWriteQuery($query, $parameters = null, $tag = null)
111111
{
@@ -126,9 +126,9 @@ public function stack($tag = null, $connectionAlias = null)
126126
/**
127127
* @param StackInterface $stack
128128
*
129-
* @return ResultCollection|null
130-
*
131129
* @throws Neo4jException
130+
*
131+
* @return ResultCollection|null
132132
*/
133133
public function runStack(StackInterface $stack)
134134
{

src/ClientBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
/**
3+
/*
44
* This file is part of the GraphAware Neo4j Client package.
55
*
66
* (c) GraphAware Limited <http://graphaware.com>
@@ -89,7 +89,7 @@ public function preflightEnv($variable)
8989
public function setMaster($connectionAlias)
9090
{
9191
if (!isset($this->config['connections']) || !array_key_exists($connectionAlias, $this->config['connections'])) {
92-
throw new \InvalidArgumentException(sprintf('The connection "%s" is not registered', (string) $connectionAlias));
92+
throw new \InvalidArgumentException(sprintf('The connection "%s" is not registered', (string) $connectionAlias));
9393
}
9494

9595
$this->config['connections'] = array_map(function ($connectionSettings) {

0 commit comments

Comments
 (0)