Skip to content

Commit

Permalink
feat: Explicitly mark formatter as nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
exaby73 committed Oct 30, 2024
1 parent ba07b4d commit a25cbcc
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Bolt/BoltDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Bolt/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function runStatements(iterable $statements, ?TransactionConfiguration $c
/**
* @param iterable<Statement>|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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/GeneratorHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
4 changes: 2 additions & 2 deletions src/Databags/HttpPsrBindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions src/DriverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class DriverFactory
* : DriverInterface<OGMResults>
* )
*/
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);
Expand Down Expand Up @@ -76,7 +76,7 @@ public static function create(string|UriInterface $uri, ?DriverConfiguration $co
* : DriverInterface<OGMResults>
* )
*/
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);
Expand All @@ -96,7 +96,7 @@ private static function createBoltDriver(string|UriInterface $uri, ?DriverConfig
* : DriverInterface<OGMResults>
* )
*/
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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/Neo4jException.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class Neo4jException extends RuntimeException
/**
* @param non-empty-list<Neo4jError> $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');
Expand Down
2 changes: 1 addition & 1 deletion src/Http/HttpDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Neo4j/Neo4jDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Neo4j/RoutingTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getTtl(): int
*
* @return list<string>
*/
public function getWithRole(RoutingRoles $role = null): array
public function getWithRole(?RoutingRoles $role = null): array
{
/** @psalm-var list<string> $tbr */
$tbr = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Types/AbstractCypherSequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Types/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function pairs(): ArrayList
*
* @return static<TValue>
*/
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) {
Expand Down

0 comments on commit a25cbcc

Please sign in to comment.