Skip to content

Commit 88b8996

Browse files
committed
fixes
1 parent 5bb693c commit 88b8996

32 files changed

+256
-184
lines changed

.github/workflows/static-analysis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ jobs:
1919
php_version: 8.0
2020
version: 2
2121
- name: "PHP-CS-Fixer"
22-
run: vendor/bin/php-cs-fixer fix --dry-run
22+
run: composer check-cs
2323
- name: "PSalm"
24-
run: ./console debug:config && vendor/bin/psalm --show-info=true
24+
run: composer psalm

.github/workflows/tests.yml

-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ jobs:
1717
php: [ '8.0', '8.1', '8.2']
1818
sf_version: [ '5.4.*', '6.2.*', '6.3.*' ]
1919
exclude:
20-
- php: 7.4
21-
sf_version: 6.2.*
2220
- php: 8.0
2321
sf_version: 6.2.*
2422
- php: 7.4
@@ -39,5 +37,4 @@ jobs:
3937
php_version: ${{ matrix.php }}
4038
memory_limit: 1024M
4139
version: 9
42-
testsuite: Unit
4340
bootstrap: vendor/autoload.php

.php-cs-fixer.dist.php

+1-22
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
try {
2525
$finder = PhpCsFixer\Finder::create()
2626
->in(__DIR__.'/src')
27+
->in(__DIR__.'/config')
2728
->in(__DIR__.'/tests');
2829
} catch (Throwable $e) {
2930
echo $e->getMessage()."\n";
@@ -35,28 +36,6 @@
3536
->setRiskyAllowed(true)
3637
->setRules([
3738
'@Symfony' => true,
38-
39-
'array_syntax' => ['syntax' => 'short'],
40-
'linebreak_after_opening_tag' => true,
41-
'ordered_imports' => true,
42-
'phpdoc_order' => true,
43-
'phpdoc_to_comment' => false,
44-
'yoda_style' => false,
45-
'declare_strict_types' => true,
46-
'global_namespace_import' => [
47-
'import_classes' => true,
48-
'import_constants' => true,
49-
'import_functions' => true,
50-
],
51-
ConstructorEmptyBracesFixer::name() => true,
52-
IssetToArrayKeyExistsFixer::name() => true,
53-
MultilineCommentOpeningClosingAloneFixer::name() => true,
54-
MultilinePromotedPropertiesFixer::name() => true,
55-
PhpUnitAssertArgumentsOrderFixer::name() => true,
56-
PhpdocNoSuperfluousParamFixer::name() => true,
57-
PhpdocParamOrderFixer::name() => true,
58-
StringableInterfaceFixer::name() => true,
5939
])
6040
->setFinder($finder)
61-
->registerCustomFixers(new PhpCsFixerCustomFixers\Fixers())
6241
;

bin/console.php

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
use Neo4j\Neo4jBundle\Tests\App\TestKernel;
4+
use Symfony\Bundle\FrameworkBundle\Console\Application;
5+
6+
require __DIR__ . '/../vendor/autoload.php';
7+
8+
$console = new Application(new TestKernel('test', true));
9+
10+
$console->run();

composer.json

+9-12
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,9 @@
22
"name": "neo4j/neo4j-bundle",
33
"description": "Symfony integration for Neo4j",
44
"type": "symfony-bundle",
5-
"keywords": ["neo4j"],
5+
"keywords": ["neo4j", "symfony", "bundle", "graph", "database", "cypher"],
66
"license": "MIT",
77
"authors": [
8-
{
9-
"name": "Tobias Nyholm",
10-
"email": "[email protected]"
11-
},
12-
{
13-
"name": "Xavier Coureau",
14-
"email": "[email protected]"
15-
},
168
{
179
"name": "Ghlen Nagels",
1810
"email": "[email protected]"
@@ -24,7 +16,7 @@
2416
"twig/twig": "^3.0",
2517
"ext-json": "*",
2618
"symfony/dependency-injection": "^5.4 || ^6.0",
27-
"symfony/config": "^6.0"
19+
"symfony/config": "^5.4 || ^6.0"
2820
},
2921
"require-dev": {
3022
"matthiasnoback/symfony-dependency-injection-test": "^4.3",
@@ -35,9 +27,9 @@
3527
"symfony/http-kernel": "^5.4 || ^6.0",
3628
"symfony/test-pack": "^1.1",
3729
"symfony/yaml": "^5.4 || ^6.0",
38-
"vimeo/psalm": "^5.12",
30+
"vimeo/psalm": "^5.15.0",
3931
"kubawerlos/php-cs-fixer-custom-fixers": "^3.0",
40-
"friendsofphp/php-cs-fixer": "^3.0",
32+
"friendsofphp/php-cs-fixer": "^3.30",
4133
"psalm/plugin-phpunit": "^0.18"
4234
},
4335
"autoload": {
@@ -55,5 +47,10 @@
5547
"allow-plugins": {
5648
"php-http/discovery": false
5749
}
50+
},
51+
"scripts": {
52+
"psalm": "vendor/bin/psalm --show-info=true",
53+
"fix-cs": "vendor/bin/php-cs-fixer fix",
54+
"check-cs": "vendor/bin/php-cs-fixer fix --dry-run"
5855
}
5956
}

config/services.php

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
use Laudis\Neo4j\Basic\Driver;
4+
use Laudis\Neo4j\Basic\Session;
5+
use Laudis\Neo4j\Contracts\ClientInterface;
6+
use Laudis\Neo4j\Contracts\DriverInterface;
7+
use Laudis\Neo4j\Contracts\SessionInterface;
8+
use Laudis\Neo4j\Contracts\TransactionInterface;
9+
use Neo4j\Neo4jBundle\ClientFactory;
10+
use Neo4j\Neo4jBundle\EventHandler;
11+
use Neo4j\Neo4jBundle\EventListener\Neo4jProfileListener;
12+
use Neo4j\Neo4jBundle\SymfonyClient;
13+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
14+
15+
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
16+
17+
return static function (ContainerConfigurator $configurator) {
18+
$services = $configurator->services();
19+
20+
$services->set('neo4j.event_handler', EventHandler::class)
21+
->autowire()
22+
->autoconfigure();
23+
24+
$services->set('neo4j.client_factory', ClientFactory::class)
25+
->args([
26+
service('neo4j.event_handler'),
27+
]);
28+
29+
$services->set('neo4j.client', SymfonyClient::class)
30+
->factory([service('neo4j.client_factory'), 'create'])
31+
->public();
32+
33+
$services->set('neo4j.driver', Driver::class)
34+
->factory([service('neo4j.client'), 'getDriver'])
35+
->public();
36+
37+
$services->set('neo4j.session', Session::class)
38+
->factory([service('neo4j.driver'), 'createSession'])
39+
->share(false)
40+
->public();
41+
42+
$services->set('neo4j.transaction', TransactionInterface::class)
43+
->factory([service('neo4j.session'), 'beginTransaction'])
44+
->share(false)
45+
->public();
46+
47+
$services->alias(ClientInterface::class, 'neo4j.client');
48+
$services->alias(DriverInterface::class, 'neo4j.driver');
49+
$services->alias(SessionInterface::class, 'neo4j.session');
50+
$services->alias(TransactionInterface::class, 'neo4j.transaction');
51+
52+
$services->set('neo4j.subscriber', Neo4jProfileListener::class)
53+
->tag('kernel.event_subscriber');
54+
};

config/services.xml

-22
This file was deleted.

docker-compose.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
version: '3.7'
22
networks:
3-
neo-eloquent:
3+
neo4j-symfony:
44

55
services:
66
app:
7+
user: ${UID-1000}:${GID-1000}
78
build:
89
context: .
910
ports:
@@ -18,7 +19,7 @@ services:
1819
- NEO4J_PASSWORD=testtest
1920
working_dir: /opt/project
2021
networks:
21-
- neo-eloquent
22+
- neo4j-symfony
2223

2324
neo4j:
2425
environment:
@@ -28,5 +29,5 @@ services:
2829
- ${DOCKER_HOST_NEO4J_HTTP_PORT:-7474}:7474
2930
- ${DOCKER_HOST_NEO4J_BOLT_PORT:-7687}:7687
3031
networks:
31-
- neo-eloquent
32+
- neo4j-symfony
3233

docs/README.md

+33-14
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,46 @@
77
[![Total Downloads](https://img.shields.io/packagist/dt/neo4j/neo4j-bundle.svg?style=flat-square)](https://packagist.org/packages/neo4j/neo4j-bundle)
88

99

10-
## Install
10+
Installation
11+
============
1112

12-
Via Composer
13+
Make sure Composer is installed globally, as explained in the
14+
[installation chapter](https://getcomposer.org/doc/00-intro.md)
15+
of the Composer documentation.
1316

14-
``` bash
17+
Applications that use Symfony Flex
18+
----------------------------------
19+
20+
Open a command console, enter your project directory and execute:
21+
22+
```console
23+
$ composer require neo4j/neo4j-bundle
24+
```
25+
26+
Applications that don't use Symfony Flex
27+
----------------------------------------
28+
29+
### Step 1: Download the Bundle
30+
31+
Open a command console, enter your project directory and execute the
32+
following command to download the latest stable version of this bundle:
33+
34+
```console
1535
$ composer require neo4j/neo4j-bundle
1636
```
1737

18-
Enable the bundle in your kernel:
38+
### Step 2: Enable the Bundle
39+
40+
Then, enable the bundle by adding it to the list of registered bundles
41+
in the `config/bundles.php` file of your project:
1942

20-
``` php
21-
<?php
22-
// app/AppKernel.php
43+
```php
44+
// config/bundles.php
2345

24-
public function registerBundles()
25-
{
26-
$bundles = array(
27-
// ...
28-
new Neo4j\Neo4jBundle\Neo4jBundle(),
29-
);
30-
}
46+
return [
47+
// ...
48+
\Neo4j\Neo4jBundle\Neo4jBundle::class => ['all' => true],
49+
];
3150
```
3251

3352
## Documentation

psalm.xml

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
>
1111
<projectFiles>
1212
<directory name="src"/>
13+
<directory name="config"/>
1314
<directory name="tests"/>
1415
<ignoreFiles>
1516
<directory name="vendor"/>

public/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

src/ClientFactory.php

+11-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Neo4j\Neo4jBundle;
66

7-
use InvalidArgumentException;
87
use Laudis\Neo4j\Authentication\Authenticate;
98
use Laudis\Neo4j\ClientBuilder;
109
use Laudis\Neo4j\Common\Uri;
@@ -13,9 +12,11 @@
1312
use Laudis\Neo4j\Databags\HttpPsrBindings;
1413
use Laudis\Neo4j\Databags\SessionConfiguration;
1514
use Laudis\Neo4j\Databags\SslConfiguration;
15+
use Laudis\Neo4j\Databags\SummarizedResult;
1616
use Laudis\Neo4j\Databags\TransactionConfiguration;
1717
use Laudis\Neo4j\Enum\AccessMode;
1818
use Laudis\Neo4j\Enum\SslMode;
19+
use Laudis\Neo4j\Types\CypherMap;
1920
use Neo4j\Neo4jBundle\DependencyInjection\Configuration;
2021
use Psr\Http\Client\ClientInterface;
2122
use Psr\Http\Message\RequestFactoryInterface;
@@ -46,10 +47,12 @@ public function __construct(
4647
private ClientInterface|null $client,
4748
private StreamFactoryInterface|null $streamFactory,
4849
private RequestFactoryInterface|null $requestFactory,
49-
) {}
50+
) {
51+
}
5052

5153
public function create(): SymfonyClient
5254
{
55+
/** @var ClientBuilder<SummarizedResult<CypherMap>> $builder */
5356
$builder = ClientBuilder::create();
5457

5558
if ($this->driverConfig) {
@@ -73,7 +76,6 @@ public function create(): SymfonyClient
7376
);
7477
}
7578

76-
/** @psalm-suppress InvalidArgument */
7779
return new SymfonyClient($builder->build(), $this->eventHandler);
7880
}
7981

@@ -129,19 +131,19 @@ private function makeTransactionConfig(): TransactionConfiguration
129131
*/
130132
private function createAuth(array|null $auth, string $dsn): AuthenticateInterface
131133
{
132-
if ($auth === null) {
134+
if (null === $auth) {
133135
return Authenticate::disabled();
134136
}
135137

136138
return match ($auth['type'] ?? null) {
137139
'basic' => Authenticate::basic(
138-
$auth['username'] ?? throw new InvalidArgumentException('Missing username for basic authentication'),
139-
$auth['password'] ?? throw new InvalidArgumentException('Missing password for basic authentication')
140+
$auth['username'] ?? throw new \InvalidArgumentException('Missing username for basic authentication'),
141+
$auth['password'] ?? throw new \InvalidArgumentException('Missing password for basic authentication')
140142
),
141-
'kerberos' => Authenticate::kerberos($auth['token'] ?? throw new InvalidArgumentException('Missing token for kerberos authentication')),
143+
'kerberos' => Authenticate::kerberos($auth['token'] ?? throw new \InvalidArgumentException('Missing token for kerberos authentication')),
142144
'dsn', null => Authenticate::fromUrl(Uri::create($dsn)),
143145
'none' => Authenticate::disabled(),
144-
'oid' => Authenticate::oidc($auth['token'] ?? throw new InvalidArgumentException('Missing token for oid authentication')),
146+
'oid' => Authenticate::oidc($auth['token'] ?? throw new \InvalidArgumentException('Missing token for oid authentication')),
145147
};
146148
}
147149

@@ -150,7 +152,7 @@ private function createAuth(array|null $auth, string $dsn): AuthenticateInterfac
150152
*/
151153
private function makeSslConfig(array|null $ssl): SslConfiguration
152154
{
153-
if ($ssl === null) {
155+
if (null === $ssl) {
154156
return new SslConfiguration(
155157
mode: SslMode::DISABLE(),
156158
verifyPeer: false,

0 commit comments

Comments
 (0)