From a25cbccfc55bd0da18c4196e45325acbc46f97c2 Mon Sep 17 00:00:00 2001 From: exaby73 Date: Wed, 30 Oct 2024 12:33:33 +0530 Subject: [PATCH] feat: Explicitly mark formatter as nullable --- src/Bolt/BoltDriver.php | 2 +- src/Bolt/Session.php | 2 +- src/Common/GeneratorHelper.php | 2 +- src/Databags/HttpPsrBindings.php | 4 ++-- src/DriverFactory.php | 8 ++++---- src/Exception/Neo4jException.php | 2 +- src/Http/HttpDriver.php | 2 +- src/Neo4j/Neo4jDriver.php | 2 +- src/Neo4j/RoutingTable.php | 2 +- src/Types/AbstractCypherSequence.php | 2 +- src/Types/Map.php | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Bolt/BoltDriver.php b/src/Bolt/BoltDriver.php index 23bb1bad..8a52e353 100644 --- a/src/Bolt/BoltDriver.php +++ b/src/Bolt/BoltDriver.php @@ -65,7 +65,7 @@ public function __construct( * * @psalm-suppress MixedReturnTypeCoercion */ - public static function create(string|UriInterface $uri, ?DriverConfiguration $configuration = null, ?AuthenticateInterface $authenticate = null, FormatterInterface $formatter = null): self + public static function create(string|UriInterface $uri, ?DriverConfiguration $configuration = null, ?AuthenticateInterface $authenticate = null, ?FormatterInterface $formatter = null): self { if (is_string($uri)) { $uri = Uri::create($uri); diff --git a/src/Bolt/Session.php b/src/Bolt/Session.php index 0cf01535..1f1fdfa7 100644 --- a/src/Bolt/Session.php +++ b/src/Bolt/Session.php @@ -76,7 +76,7 @@ public function runStatements(iterable $statements, ?TransactionConfiguration $c /** * @param iterable|null $statements */ - public function openTransaction(iterable $statements = null, ?TransactionConfiguration $config = null): UnmanagedTransactionInterface + public function openTransaction(?iterable $statements = null, ?TransactionConfiguration $config = null): UnmanagedTransactionInterface { return $this->beginTransaction($statements, $this->mergeTsxConfig($config)); } diff --git a/src/Common/GeneratorHelper.php b/src/Common/GeneratorHelper.php index 80d6dad3..7d1be1af 100644 --- a/src/Common/GeneratorHelper.php +++ b/src/Common/GeneratorHelper.php @@ -30,7 +30,7 @@ final class GeneratorHelper * * @return T */ - public static function getReturnFromGenerator(Generator $generator, float $timeout = null) + public static function getReturnFromGenerator(Generator $generator, ?float $timeout = null) { $start = microtime(true); while ($generator->valid()) { diff --git a/src/Databags/HttpPsrBindings.php b/src/Databags/HttpPsrBindings.php index 544356f0..12b0048b 100644 --- a/src/Databags/HttpPsrBindings.php +++ b/src/Databags/HttpPsrBindings.php @@ -47,7 +47,7 @@ final class HttpPsrBindings * @param callable():StreamFactoryInterface|StreamFactoryInterface|null $streamFactory * @param callable():RequestFactoryInterface|RequestFactoryInterface|null $requestFactory */ - public function __construct(callable|ClientInterface|null $client = null, callable|StreamFactoryInterface $streamFactory = null, callable|RequestFactoryInterface $requestFactory = null) + public function __construct(callable|ClientInterface|null $client = null, callable|StreamFactoryInterface|null $streamFactory = null, callable|RequestFactoryInterface|null $requestFactory = null) { $this->client = $client ?? static fn (): ClientInterface => Psr18ClientDiscovery::find(); $this->streamFactory = $streamFactory ?? static fn (): StreamFactoryInterface => Psr17FactoryDiscovery::findStreamFactory(); @@ -61,7 +61,7 @@ public function __construct(callable|ClientInterface|null $client = null, callab * @param callable():StreamFactoryInterface|StreamFactoryInterface|null $streamFactory * @param callable():RequestFactoryInterface|RequestFactoryInterface|null $requestFactory */ - public static function create(callable|ClientInterface $client = null, callable|StreamFactoryInterface $streamFactory = null, callable|RequestFactoryInterface $requestFactory = null): self + public static function create(callable|ClientInterface|null $client = null, callable|StreamFactoryInterface|null $streamFactory = null, callable|RequestFactoryInterface|null $requestFactory = null): self { return new self($client, $streamFactory, $requestFactory); } diff --git a/src/DriverFactory.php b/src/DriverFactory.php index 56bca058..85d7f3b4 100644 --- a/src/DriverFactory.php +++ b/src/DriverFactory.php @@ -45,7 +45,7 @@ final class DriverFactory * : DriverInterface * ) */ - public static function create(string|UriInterface $uri, ?DriverConfiguration $configuration = null, ?AuthenticateInterface $authenticate = null, FormatterInterface $formatter = null): DriverInterface + public static function create(string|UriInterface $uri, ?DriverConfiguration $configuration = null, ?AuthenticateInterface $authenticate = null, ?FormatterInterface $formatter = null): DriverInterface { if (is_string($uri)) { $uri = Uri::create($uri); @@ -76,7 +76,7 @@ public static function create(string|UriInterface $uri, ?DriverConfiguration $co * : DriverInterface * ) */ - private static function createBoltDriver(string|UriInterface $uri, ?DriverConfiguration $configuration, ?AuthenticateInterface $authenticate, FormatterInterface $formatter = null): DriverInterface + private static function createBoltDriver(string|UriInterface $uri, ?DriverConfiguration $configuration, ?AuthenticateInterface $authenticate, ?FormatterInterface $formatter = null): DriverInterface { if ($formatter !== null) { return BoltDriver::create($uri, $configuration, $authenticate, $formatter); @@ -96,7 +96,7 @@ private static function createBoltDriver(string|UriInterface $uri, ?DriverConfig * : DriverInterface * ) */ - private static function createNeo4jDriver(string|UriInterface $uri, ?DriverConfiguration $configuration, ?AuthenticateInterface $authenticate, FormatterInterface $formatter = null): DriverInterface + private static function createNeo4jDriver(string|UriInterface $uri, ?DriverConfiguration $configuration, ?AuthenticateInterface $authenticate, ?FormatterInterface $formatter = null): DriverInterface { if ($formatter !== null) { return Neo4jDriver::create($uri, $configuration, $authenticate, $formatter); @@ -118,7 +118,7 @@ private static function createNeo4jDriver(string|UriInterface $uri, ?DriverConfi * * @pure */ - private static function createHttpDriver(string|UriInterface $uri, ?DriverConfiguration $configuration, ?AuthenticateInterface $authenticate, FormatterInterface $formatter = null): DriverInterface + private static function createHttpDriver(string|UriInterface $uri, ?DriverConfiguration $configuration, ?AuthenticateInterface $authenticate, ?FormatterInterface $formatter = null): DriverInterface { if ($formatter !== null) { return HttpDriver::create($uri, $configuration, $authenticate, $formatter); diff --git a/src/Exception/Neo4jException.php b/src/Exception/Neo4jException.php index 10717375..89a746fb 100644 --- a/src/Exception/Neo4jException.php +++ b/src/Exception/Neo4jException.php @@ -34,7 +34,7 @@ final class Neo4jException extends RuntimeException /** * @param non-empty-list $errors */ - public function __construct(array $errors, Throwable $previous = null) + public function __construct(array $errors, ?Throwable $previous = null) { $error = $errors[0]; $message = sprintf(self::MESSAGE_TEMPLATE, $error->getCode(), $error->getMessage() ?? 'NULL'); diff --git a/src/Http/HttpDriver.php b/src/Http/HttpDriver.php index 4a03bd5b..7ff63ca9 100644 --- a/src/Http/HttpDriver.php +++ b/src/Http/HttpDriver.php @@ -70,7 +70,7 @@ public function __construct( * * @pure */ - public static function create(string|UriInterface $uri, ?DriverConfiguration $configuration = null, ?AuthenticateInterface $authenticate = null, FormatterInterface $formatter = null): self + public static function create(string|UriInterface $uri, ?DriverConfiguration $configuration = null, ?AuthenticateInterface $authenticate = null, ?FormatterInterface $formatter = null): self { if (is_string($uri)) { $uri = Uri::create($uri); diff --git a/src/Neo4j/Neo4jDriver.php b/src/Neo4j/Neo4jDriver.php index 24cf9f71..7c3f7473 100644 --- a/src/Neo4j/Neo4jDriver.php +++ b/src/Neo4j/Neo4jDriver.php @@ -68,7 +68,7 @@ public function __construct( * * @psalm-suppress MixedReturnTypeCoercion */ - public static function create(string|UriInterface $uri, ?DriverConfiguration $configuration = null, ?AuthenticateInterface $authenticate = null, FormatterInterface $formatter = null, ?AddressResolverInterface $resolver = null): self + public static function create(string|UriInterface $uri, ?DriverConfiguration $configuration = null, ?AuthenticateInterface $authenticate = null, ?FormatterInterface $formatter = null, ?AddressResolverInterface $resolver = null): self { if (is_string($uri)) { $uri = Uri::create($uri); diff --git a/src/Neo4j/RoutingTable.php b/src/Neo4j/RoutingTable.php index 791b91c7..3b5b2b76 100644 --- a/src/Neo4j/RoutingTable.php +++ b/src/Neo4j/RoutingTable.php @@ -45,7 +45,7 @@ public function getTtl(): int * * @return list */ - public function getWithRole(RoutingRoles $role = null): array + public function getWithRole(?RoutingRoles $role = null): array { /** @psalm-var list $tbr */ $tbr = []; diff --git a/src/Types/AbstractCypherSequence.php b/src/Types/AbstractCypherSequence.php index 7b7a54f6..1225f45c 100644 --- a/src/Types/AbstractCypherSequence.php +++ b/src/Types/AbstractCypherSequence.php @@ -248,7 +248,7 @@ public function reversed(): self * * @psalm-mutation-free */ - public function slice(int $offset, int $length = null): self + public function slice(int $offset, ?int $length = null): self { return $this->withOperation(function () use ($offset, $length) { if ($length !== 0) { diff --git a/src/Types/Map.php b/src/Types/Map.php index 779e995b..2ca1c775 100644 --- a/src/Types/Map.php +++ b/src/Types/Map.php @@ -186,7 +186,7 @@ public function pairs(): ArrayList * * @return static */ - public function ksorted(callable $comparator = null): Map + public function ksorted(?callable $comparator = null): Map { return $this->withOperation(function () use ($comparator) { $pairs = $this->pairs()->sorted(static function (Pair $x, Pair $y) use ($comparator) {