Skip to content
Merged
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
29 changes: 29 additions & 0 deletions .github/scripts/setup-symfony-env.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

set -ex

if [ -z "$1" ]; then
echo "Please specify the Symfony version to install"
exit 1
fi

echo "Installing Symfony version $1"

# This is not required for CI, but it allows to test the script locally
function cleanup {
echo "Cleaning up"
mv composer.origin.json composer.json
}

function install-specified-symfony-version {
local symfony_version=$1
cp composer.json composer.origin.json
rm composer.lock || true
rm -Rf vendor || true
sed -i 's/\^5.4 || \^6.0 || \^7.0/\^'$symfony_version'/g' composer.json
composer install
}

trap cleanup EXIT

install-specified-symfony-version $1
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: php-actions/composer@v6
with:
progress: yes
php_version: 8.0
php_version: 8.1
version: 2
- name: "PHP-CS-Fixer"
run: composer check-cs
Expand Down
22 changes: 14 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,25 @@ jobs:
strategy:
max-parallel: 10
matrix:
php: [ '8.0', '8.1', '8.2']
sf_version: [ '5.4.*', '6.0.*', '6.3.*' ]
php: [ '8.1', '8.2', '8.3']
sf_version: [ '5.4', '6.4', '7.1' ]
exclude:
- php: 8.0
sf_version: 6.3.*
- php: 8.1
sf_version: 7.1

steps:
- uses: actions/checkout@v2
- uses: php-actions/composer@v6
- name: Validate composer-5.4.json
run: composer validate --strict

- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
progress: yes
php_version: ${{matrix.php}}
version: 2
php-version: ${{ matrix.php }}

- name: Override Symfony version
run: composer run ci-symfony-install-version ${{ matrix.sf_version }}

- uses: php-actions/phpunit@v3
with:
configuration: phpunit.xml.dist
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
composer.lock
.phpunit.result.cache
.idea
.php-cs-fixer.cache
.php-cs-fixer.cache

composer.origin.json
21 changes: 11 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@
}
],
"require": {
"php": ">=8.0",
"laudis/neo4j-php-client": "^3.0.5",
"php": ">=8.1",
"laudis/neo4j-php-client": "^3.1",
"twig/twig": "^3.0",
"ext-json": "*",
"symfony/dependency-injection": "^5.4 || ^6.0",
"symfony/config": "^5.4 || ^6.0"
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
"symfony/config": "^5.4 || ^6.0 || ^7.0"
},
"require-dev": {
"matthiasnoback/symfony-dependency-injection-test": "^4.3",
"matthiasnoback/symfony-dependency-injection-test": "^4.3 || ^5.0",
"phpunit/phpunit": "^9.5",
"psalm/plugin-symfony": "^5.0",
"symfony/console": "^5.4 || ^6.0",
"symfony/framework-bundle": "^5.4 || ^6.0",
"symfony/http-kernel": "^5.4 || ^6.0",
"symfony/console": "^5.4 || ^6.0 || ^7.0",
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.0 || ^7.0",
"symfony/test-pack": "^1.1",
"symfony/yaml": "^5.4 || ^6.0",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0",
"vimeo/psalm": "^5.15.0",
"kubawerlos/php-cs-fixer-custom-fixers": "^3.0",
"friendsofphp/php-cs-fixer": "^3.30",
Expand All @@ -51,6 +51,7 @@
"scripts": {
"psalm": "php bin/console.php cache:warmup && vendor/bin/psalm --show-info=true",
"fix-cs": "vendor/bin/php-cs-fixer fix",
"check-cs": "vendor/bin/php-cs-fixer fix --dry-run"
"check-cs": "vendor/bin/php-cs-fixer fix --dry-run",
"ci-symfony-install-version": "./.github/scripts/setup-symfony-env.bash"
}
}
18 changes: 9 additions & 9 deletions src/ClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
*/
public function __construct(
private EventHandler $eventHandler,
private array|null $driverConfig,
private array|null $sessionConfiguration,
private array|null $transactionConfiguration,
private ?array $driverConfig,
private ?array $sessionConfiguration,
private ?array $transactionConfiguration,
private array $connections,
private string|null $defaultDriver,
private ClientInterface|null $client,
private StreamFactoryInterface|null $streamFactory,
private RequestFactoryInterface|null $requestFactory,
private ?string $defaultDriver,
private ?ClientInterface $client,
private ?StreamFactoryInterface $streamFactory,
private ?RequestFactoryInterface $requestFactory,
) {
}

Expand All @@ -56,15 +56,15 @@
/** @var ClientBuilder<SummarizedResult<CypherMap>> $builder */
$builder = ClientBuilder::create();

if ($this->driverConfig) {

Check warning on line 59 in src/ClientFactory.php

View workflow job for this annotation

GitHub Actions / Lint & Analyse

RiskyTruthyFalsyComparison

src/ClientFactory.php:59:13: RiskyTruthyFalsyComparison: Operand of type array{acquire_connection_timeout?: int|null, pool_size?: int|null, profiling?: bool, ssl?: array{mode: 'disable'|'enable'|'enable_with_self_signed'|'from_url'|null, verify_peer?: bool|null}|null, user_agent?: null|string}|null contains type array{acquire_connection_timeout?: int|null, pool_size?: int|null, profiling?: bool, ssl?: array{mode: 'disable'|'enable'|'enable_with_self_signed'|'from_url'|null, verify_peer?: bool|null}|null, user_agent?: null|string}, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)
$builder = $builder->withDefaultDriverConfiguration($this->makeDriverConfig());
}

if ($this->sessionConfiguration) {

Check warning on line 63 in src/ClientFactory.php

View workflow job for this annotation

GitHub Actions / Lint & Analyse

RiskyTruthyFalsyComparison

src/ClientFactory.php:63:13: RiskyTruthyFalsyComparison: Operand of type array{access_mode?: 'read'|'write'|null, database?: null|string, fetch_size?: int|null}|null contains type array{access_mode?: 'read'|'write'|null, database?: null|string, fetch_size?: int|null}, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)
$builder = $builder->withDefaultSessionConfiguration($this->makeSessionConfig());
}

if ($this->transactionConfiguration) {

Check warning on line 67 in src/ClientFactory.php

View workflow job for this annotation

GitHub Actions / Lint & Analyse

RiskyTruthyFalsyComparison

src/ClientFactory.php:67:13: RiskyTruthyFalsyComparison: Operand of type array{timeout?: int|null}|null contains type array{timeout?: int|null}, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)
$builder = $builder->withDefaultTransactionConfiguration($this->makeTransactionConfig());
}

Expand All @@ -77,7 +77,7 @@
);
}

if ($this->defaultDriver) {

Check warning on line 80 in src/ClientFactory.php

View workflow job for this annotation

GitHub Actions / Lint & Analyse

RiskyTruthyFalsyComparison

src/ClientFactory.php:80:13: RiskyTruthyFalsyComparison: Operand of type null|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)
$builder = $builder->withDefaultDriver($this->defaultDriver);
}

Expand Down Expand Up @@ -134,7 +134,7 @@
/**
* @param DriverAuthenticationArray|null $auth
*/
private function createAuth(array|null $auth, string $dsn): AuthenticateInterface
private function createAuth(?array $auth, string $dsn): AuthenticateInterface
{
if (null === $auth) {
return Authenticate::fromUrl(Uri::create($dsn));
Expand All @@ -155,7 +155,7 @@
/**
* @param SslConfigArray|null $ssl
*/
private function makeSslConfig(array|null $ssl): SslConfiguration
private function makeSslConfig(?array $ssl): SslConfiguration
{
if (null === $ssl) {
return new SslConfiguration(
Expand Down
2 changes: 1 addition & 1 deletion src/Collector/Neo4jDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(
) {
}

public function collect(Request $request, Response $response, \Throwable $exception = null): void
public function collect(Request $request, Response $response, ?\Throwable $exception = null): void
{
$this->data['successful_statements'] = array_map(
static fn (ResultSummary $summary) => $summary->toArray(),
Expand Down
4 changes: 2 additions & 2 deletions src/Event/FailureEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class FailureEvent extends Event

protected bool $shouldThrowException = true;

public function __construct(private string|null $alias, private Statement $statement, private Neo4jException $exception)
public function __construct(private ?string $alias, private Statement $statement, private Neo4jException $exception)
{
}

Expand All @@ -33,7 +33,7 @@ public function shouldThrowException(): bool
return $this->shouldThrowException;
}

public function getAlias(): string|null
public function getAlias(): ?string
{
return $this->alias;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Event/PostRunEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PostRunEvent extends Event
public const EVENT_ID = 'neo4j.post_run';

public function __construct(
private string|null $alias,
private ?string $alias,
private ResultSummary $result
) {
}
Expand All @@ -22,7 +22,7 @@ public function getResult(): ResultSummary
return $this->result;
}

public function getAlias(): string|null
public function getAlias(): ?string
{
return $this->alias;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Event/PreRunEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class PreRunEvent extends Event
{
public const EVENT_ID = 'neo4j.pre_run';

public function __construct(private string|null $alias, private Statement $statement)
public function __construct(private ?string $alias, private Statement $statement)
{
}

Expand All @@ -20,7 +20,7 @@ public function getStatement(): Statement
return $this->statement;
}

public function getAlias(): string|null
public function getAlias(): ?string
{
return $this->alias;
}
Expand Down
2 changes: 1 addition & 1 deletion src/EventHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(?EventDispatcherInterface $dispatcher)
*
* @return SummarizedResult<T>
*/
public function handle(callable $runHandler, Statement $statement, string|null $alias): SummarizedResult
public function handle(callable $runHandler, Statement $statement, ?string $alias): SummarizedResult
{
if (null === $this->dispatcher) {
return $runHandler($statement);
Expand Down
22 changes: 11 additions & 11 deletions src/SymfonyClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ public function __construct(
) {
}

public function run(string $statement, iterable $parameters = [], string $alias = null): ?SummarizedResult
public function run(string $statement, iterable $parameters = [], ?string $alias = null): ?SummarizedResult
{
return $this->runStatement(new Statement($statement, $parameters), $alias);
}

public function runStatement(Statement $statement, string $alias = null): ?SummarizedResult
public function runStatement(Statement $statement, ?string $alias = null): ?SummarizedResult
{
return $this->handler->handle(fn (Statement $statement) => $this->client->runStatement($statement, $alias), $statement, $alias);
}

public function runStatements(iterable $statements, string $alias = null): CypherList
public function runStatements(iterable $statements, ?string $alias = null): CypherList
{
$tbr = [];
foreach ($statements as $statement) {
Expand All @@ -50,7 +50,7 @@ public function runStatements(iterable $statements, string $alias = null): Cyphe
return CypherList::fromIterable($tbr);
}

public function beginTransaction(iterable $statements = null, string $alias = null, TransactionConfiguration $config = null): UnmanagedTransactionInterface
public function beginTransaction(?iterable $statements = null, ?string $alias = null, ?TransactionConfiguration $config = null): UnmanagedTransactionInterface
{
$tsx = new SymfonyTransaction($this->client->beginTransaction(null, $alias, $config), $this->handler, $alias);

Expand All @@ -68,7 +68,7 @@ public function getDriver(?string $alias): DriverInterface
return $this->client->getDriver($alias);
}

public function writeTransaction(callable $tsxHandler, string $alias = null, TransactionConfiguration $config = null)
public function writeTransaction(callable $tsxHandler, ?string $alias = null, ?TransactionConfiguration $config = null)
{
$sessionConfig = SessionConfiguration::default()->withAccessMode(AccessMode::READ());
$session = $this->client->getDriver($alias)->createSession($sessionConfig);
Expand All @@ -79,7 +79,7 @@ public function writeTransaction(callable $tsxHandler, string $alias = null, Tra
);
}

public function readTransaction(callable $tsxHandler, string $alias = null, TransactionConfiguration $config = null)
public function readTransaction(callable $tsxHandler, ?string $alias = null, ?TransactionConfiguration $config = null)
{
$sessionConfig = SessionConfiguration::default()->withAccessMode(AccessMode::WRITE());
$session = $this->client->getDriver($alias)->createSession($sessionConfig);
Expand All @@ -90,27 +90,27 @@ public function readTransaction(callable $tsxHandler, string $alias = null, Tran
);
}

public function transaction(callable $tsxHandler, string $alias = null, TransactionConfiguration $config = null)
public function transaction(callable $tsxHandler, ?string $alias = null, ?TransactionConfiguration $config = null)
{
return $this->writeTransaction($tsxHandler, $alias, $config);
}

public function verifyConnectivity(string $driver = null): bool
public function verifyConnectivity(?string $driver = null): bool
{
return $this->client->verifyConnectivity($driver);
}

public function bindTransaction(string $alias = null, TransactionConfiguration $config = null): void
public function bindTransaction(?string $alias = null, ?TransactionConfiguration $config = null): void
{
$this->client->bindTransaction($alias, $config);
}

public function commitBoundTransaction(string $alias = null, int $depth = 1): void
public function commitBoundTransaction(?string $alias = null, int $depth = 1): void
{
$this->client->commitBoundTransaction($alias, $depth);
}

public function rollbackBoundTransaction(string $alias = null, int $depth = 1): void
public function rollbackBoundTransaction(?string $alias = null, int $depth = 1): void
{
$this->client->rollbackBoundTransaction($alias, $depth);
}
Expand Down
2 changes: 1 addition & 1 deletion src/SymfonyTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SymfonyTransaction implements UnmanagedTransactionInterface
/**
* @param UnmanagedTransactionInterface<SummarizedResult<CypherMap>> $tsx
*/
public function __construct(private UnmanagedTransactionInterface $tsx, private EventHandler $handler, private string|null $alias)
public function __construct(private UnmanagedTransactionInterface $tsx, private EventHandler $handler, private ?string $alias)
{
}

Expand Down
Loading