diff --git a/.github/scripts/setup-symfony-env.bash b/.github/scripts/setup-symfony-env.bash new file mode 100755 index 0000000..0f84efe --- /dev/null +++ b/.github/scripts/setup-symfony-env.bash @@ -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 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index dcff7f6..ca1cfde 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f75f202..c89878a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/.gitignore b/.gitignore index 726a685..a18abad 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ composer.lock .phpunit.result.cache .idea -.php-cs-fixer.cache \ No newline at end of file +.php-cs-fixer.cache + +composer.origin.json diff --git a/composer.json b/composer.json index d825c55..63870d2 100644 --- a/composer.json +++ b/composer.json @@ -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", @@ -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" } } diff --git a/src/ClientFactory.php b/src/ClientFactory.php index 05a2e37..972f7e1 100644 --- a/src/ClientFactory.php +++ b/src/ClientFactory.php @@ -40,14 +40,14 @@ class ClientFactory */ 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, ) { } @@ -134,7 +134,7 @@ private function makeTransactionConfig(): TransactionConfiguration /** * @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)); @@ -155,7 +155,7 @@ private function createAuth(array|null $auth, string $dsn): AuthenticateInterfac /** * @param SslConfigArray|null $ssl */ - private function makeSslConfig(array|null $ssl): SslConfiguration + private function makeSslConfig(?array $ssl): SslConfiguration { if (null === $ssl) { return new SslConfiguration( diff --git a/src/Collector/Neo4jDataCollector.php b/src/Collector/Neo4jDataCollector.php index 9014743..2e3f739 100644 --- a/src/Collector/Neo4jDataCollector.php +++ b/src/Collector/Neo4jDataCollector.php @@ -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(), diff --git a/src/Event/FailureEvent.php b/src/Event/FailureEvent.php index f5e1c61..2981193 100644 --- a/src/Event/FailureEvent.php +++ b/src/Event/FailureEvent.php @@ -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) { } @@ -33,7 +33,7 @@ public function shouldThrowException(): bool return $this->shouldThrowException; } - public function getAlias(): string|null + public function getAlias(): ?string { return $this->alias; } diff --git a/src/Event/PostRunEvent.php b/src/Event/PostRunEvent.php index 75e9a96..b0bf84b 100644 --- a/src/Event/PostRunEvent.php +++ b/src/Event/PostRunEvent.php @@ -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 ) { } @@ -22,7 +22,7 @@ public function getResult(): ResultSummary return $this->result; } - public function getAlias(): string|null + public function getAlias(): ?string { return $this->alias; } diff --git a/src/Event/PreRunEvent.php b/src/Event/PreRunEvent.php index cd59239..6ab3f4d 100644 --- a/src/Event/PreRunEvent.php +++ b/src/Event/PreRunEvent.php @@ -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) { } @@ -20,7 +20,7 @@ public function getStatement(): Statement return $this->statement; } - public function getAlias(): string|null + public function getAlias(): ?string { return $this->alias; } diff --git a/src/EventHandler.php b/src/EventHandler.php index 34579c5..ce2a83c 100644 --- a/src/EventHandler.php +++ b/src/EventHandler.php @@ -36,7 +36,7 @@ public function __construct(?EventDispatcherInterface $dispatcher) * * @return SummarizedResult */ - 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); diff --git a/src/SymfonyClient.php b/src/SymfonyClient.php index efceb9d..615f748 100644 --- a/src/SymfonyClient.php +++ b/src/SymfonyClient.php @@ -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) { @@ -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); @@ -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); @@ -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); @@ -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); } diff --git a/src/SymfonyTransaction.php b/src/SymfonyTransaction.php index fee502b..bc8a46a 100644 --- a/src/SymfonyTransaction.php +++ b/src/SymfonyTransaction.php @@ -18,7 +18,7 @@ class SymfonyTransaction implements UnmanagedTransactionInterface /** * @param UnmanagedTransactionInterface> $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) { }