Skip to content

Commit

Permalink
use rector
Browse files Browse the repository at this point in the history
  • Loading branch information
transistive committed Mar 28, 2024
1 parent ae4c897 commit b802e51
Show file tree
Hide file tree
Showing 65 changed files with 256 additions and 230 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"symfony/uid": "^5.0",
"symfony/var-dumper": "^5.0",
"cache/integration-tests": "dev-master",
"kubawerlos/php-cs-fixer-custom-fixers": "3.13.*"
"kubawerlos/php-cs-fixer-custom-fixers": "3.13.*",
"rector/rector": "^1.0"
},
"autoload": {
"psr-4": {
Expand Down
25 changes: 25 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Neo4j PHP Client and Driver package.
*
* (c) Nagels <https://nagels.tech>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;

return RectorConfig::configure()
->withPaths([
__DIR__.'/src',
__DIR__.'/tests',
])
->withPhpSets(php81: true)
->withRules([
AddVoidReturnTypeWhereNoReturnRector::class,
]);
4 changes: 2 additions & 2 deletions src/Authentication/BasicAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ final class BasicAuth implements AuthenticateInterface
* @psalm-external-mutation-free
*/
public function __construct(
private string $username,
private string $password
private readonly string $username,
private readonly string $password
) {}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Authentication/KerberosAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class KerberosAuth implements AuthenticateInterface
* @psalm-external-mutation-free
*/
public function __construct(
private string $token
private readonly string $token
) {}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Authentication/OpenIDConnectAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class OpenIDConnectAuth implements AuthenticateInterface
* @psalm-external-mutation-free
*/
public function __construct(
private string $token
private readonly string $token
) {}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Basic/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class Client implements ClientInterface
* @param ClientInterface<SummarizedResult<CypherMap>> $client
*/
public function __construct(
private ClientInterface $client
private readonly ClientInterface $client
) {}

public function run(string $statement, iterable $parameters = [], ?string $alias = null): SummarizedResult
Expand Down
2 changes: 1 addition & 1 deletion src/Basic/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class Driver implements DriverInterface
* @psalm-external-mutation-free
*/
public function __construct(
private DriverInterface $driver
private readonly DriverInterface $driver
) {}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Basic/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class Session implements SessionInterface
* @param SessionInterface<SummarizedResult<CypherMap>> $session
*/
public function __construct(
private SessionInterface $session
private readonly SessionInterface $session
) {}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Basic/UnmanagedTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class UnmanagedTransaction implements UnmanagedTransactionInterface
* @param UnmanagedTransactionInterface<SummarizedResult<CypherMap>> $tsx
*/
public function __construct(
private UnmanagedTransactionInterface $tsx
private readonly UnmanagedTransactionInterface $tsx
) {}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Bolt/BoltConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ public function getImplementation(): array
*/
public function __construct(
private V4_4|V5 $boltProtocol,
private Connection $connection,
private AuthenticateInterface $auth,
private string $userAgent,
private readonly Connection $connection,
private readonly AuthenticateInterface $auth,
private readonly string $userAgent,
/** @psalm-readonly */
private ConnectionConfiguration $config
private readonly ConnectionConfiguration $config
) {}

public function getEncryptionLevel(): string
Expand Down
8 changes: 4 additions & 4 deletions src/Bolt/BoltDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ final class BoltDriver implements DriverInterface
* @psalm-mutation-free
*/
public function __construct(
private UriInterface $parsedUrl,
private ConnectionPool $pool,
private FormatterInterface $formatter
private readonly UriInterface $parsedUrl,
private readonly ConnectionPool $pool,
private readonly FormatterInterface $formatter
) {}

/**
Expand Down Expand Up @@ -103,7 +103,7 @@ public function verifyConnectivity(?SessionConfiguration $config = null): bool
$config ??= SessionConfiguration::default();
try {
GeneratorHelper::getReturnFromGenerator($this->pool->acquire($config));
} catch (Throwable $e) {
} catch (Throwable) {
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Bolt/BoltResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ final class BoltResult implements Iterator
private array $finishedCallbacks = [];

public function __construct(
private BoltConnection $connection,
private int $fetchSize,
private int $qid
private readonly BoltConnection $connection,
private readonly int $fetchSize,
private readonly int $qid
) {}

public function getFetchSize(): int
Expand Down
12 changes: 6 additions & 6 deletions src/Bolt/BoltUnmanagedTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ final class BoltUnmanagedTransaction implements UnmanagedTransactionInterface
*/
public function __construct(
/** @psalm-readonly */
private ?string $database,
private readonly ?string $database,
/**
* @psalm-readonly
*/
private FormatterInterface $formatter,
private readonly FormatterInterface $formatter,
/** @psalm-readonly */
private BoltConnection $connection,
private SessionConfiguration $config,
private TransactionConfiguration $tsxConfig,
private BookmarkHolder $bookmarkHolder
private readonly BoltConnection $connection,
private readonly SessionConfiguration $config,
private readonly TransactionConfiguration $tsxConfig,
private readonly BookmarkHolder $bookmarkHolder
) {}

public function commit(iterable $statements = []): CypherList
Expand Down
4 changes: 2 additions & 2 deletions src/Bolt/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class Connection
* @param ''|'s'|'ssc' $ssl
*/
public function __construct(
private IConnection $connection,
private string $ssl
private readonly IConnection $connection,
private readonly string $ssl
) {}

public function getIConnection(): IConnection
Expand Down
6 changes: 3 additions & 3 deletions src/Bolt/ConnectionPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ final class ConnectionPool implements ConnectionPoolInterface
private array $activeConnections = [];

public function __construct(
private SemaphoreInterface $semaphore,
private BoltFactory $factory,
private ConnectionRequestData $data
private readonly SemaphoreInterface $semaphore,
private readonly BoltFactory $factory,
private readonly ConnectionRequestData $data
) {}

public static function create(UriInterface $uri, AuthenticateInterface $auth, DriverConfiguration $conf, SemaphoreInterface $semaphore): self
Expand Down
8 changes: 4 additions & 4 deletions src/Bolt/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
final class Session implements SessionInterface
{
/** @psalm-readonly */
private BookmarkHolder $bookmarkHolder;
private readonly BookmarkHolder $bookmarkHolder;

/**
* @param ConnectionPool|Neo4jConnectionPool $pool
Expand All @@ -51,12 +51,12 @@ final class Session implements SessionInterface
*/
public function __construct(
/** @psalm-readonly */
private SessionConfiguration $config,
private ConnectionPoolInterface $pool,
private readonly SessionConfiguration $config,
private readonly ConnectionPoolInterface $pool,
/**
* @psalm-readonly
*/
private FormatterInterface $formatter
private readonly FormatterInterface $formatter
) {
$this->bookmarkHolder = new BookmarkHolder(Bookmark::from($config->getBookmarks()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Bolt/SocketConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
final class SocketConnectionFactory implements BasicConnectionFactoryInterface
{
public function __construct(
private StreamConnectionFactory $factory
private readonly StreamConnectionFactory $factory
) {}

public function create(UriConfiguration $config): Connection
Expand Down
10 changes: 5 additions & 5 deletions src/Bolt/UriConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ final class UriConfiguration
* @param ''|'s'|'ssc' $sslLevel
*/
public function __construct(
private string $host,
private ?int $port,
private string $sslLevel,
private array $sslConfiguration,
private ?float $timeout
private readonly string $host,
private readonly ?int $port,
private readonly string $sslLevel,
private readonly array $sslConfiguration,
private readonly ?float $timeout
) {}

public function getHost(): string
Expand Down
6 changes: 3 additions & 3 deletions src/BoltFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class BoltFactory
* @psalm-external-mutation-free
*/
public function __construct(
private BasicConnectionFactoryInterface $connectionFactory,
private ProtocolFactory $protocolFactory,
private SslConfigurationFactory $sslConfigurationFactory
private readonly BasicConnectionFactoryInterface $connectionFactory,
private readonly ProtocolFactory $protocolFactory,
private readonly SslConfigurationFactory $sslConfigurationFactory
) {}

public static function create(): self
Expand Down
6 changes: 3 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ final class Client implements ClientInterface
* @param DriverSetupManager<ResultFormat> $driverSetups
*/
public function __construct(
private DriverSetupManager $driverSetups,
private SessionConfiguration $defaultSessionConfiguration,
private TransactionConfiguration $defaultTransactionConfiguration
private readonly DriverSetupManager $driverSetups,
private readonly SessionConfiguration $defaultSessionConfiguration,
private readonly TransactionConfiguration $defaultTransactionConfiguration
) {}

public function getDriverSetups(): DriverSetupManager
Expand Down
14 changes: 7 additions & 7 deletions src/Common/ConnectionConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ final class ConnectionConfiguration
* @param ''|'s'|'ssc' $encryptionLevel
*/
public function __construct(
private string $serverAgent,
private UriInterface $serverAddress,
private string $serverVersion,
private ConnectionProtocol $protocol,
private AccessMode $accessMode,
private ?DatabaseInfo $databaseInfo,
private string $encryptionLevel
private readonly string $serverAgent,
private readonly UriInterface $serverAddress,
private readonly string $serverVersion,
private readonly ConnectionProtocol $protocol,
private readonly AccessMode $accessMode,
private readonly ?DatabaseInfo $databaseInfo,
private readonly string $encryptionLevel
) {}

public function getServerAgent(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Common/SingleThreadedSemaphore.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SingleThreadedSemaphore implements SemaphoreInterface
private static array $instances = [];

private function __construct(
private int $max
private readonly int $max
) {}

public static function create(string $key, int $max): self
Expand Down
10 changes: 5 additions & 5 deletions src/Common/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
final class Uri implements UriInterface, Stringable
{
public function __construct(
private string $scheme,
private string $userInfo,
private readonly string $scheme,
private readonly string $userInfo,
private string $host,
private ?int $port,
private readonly ?int $port,
private string $path,
private string $query,
private string $fragment
private readonly string $query,
private readonly string $fragment
) {}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Databags/Bookmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
final class Bookmark
{
/** @var list<string> */
private array $values;
private readonly array $values;

/**
* @param list<string> $bookmarks
Expand Down
8 changes: 4 additions & 4 deletions src/Databags/ConnectionRequestData.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
final class ConnectionRequestData
{
public function __construct(
private UriInterface $uri,
private AuthenticateInterface $auth,
private string $userAgent,
private SslConfiguration $config
private readonly UriInterface $uri,
private readonly AuthenticateInterface $auth,
private readonly string $userAgent,
private readonly SslConfiguration $config
) {}

public function getUri(): UriInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Databags/DatabaseInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
final class DatabaseInfo extends AbstractCypherObject
{
public function __construct(
private string $name
private readonly string $name
) {}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Databags/DriverSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
final class DriverSetup
{
public function __construct(
private UriInterface $uri,
private AuthenticateInterface $auth
private readonly UriInterface $uri,
private readonly AuthenticateInterface $auth
) {}

public function getAuth(): AuthenticateInterface
Expand Down
6 changes: 3 additions & 3 deletions src/Databags/InputPosition.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
final class InputPosition
{
public function __construct(
private int $column,
private int $line,
private int $offset
private readonly int $column,
private readonly int $line,
private readonly int $offset
) {}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/Databags/Neo4jError.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
final class Neo4jError
{
public function __construct(
private string $code,
private ?string $message,
private string $classification,
private string $category,
private string $title
private readonly string $code,
private readonly ?string $message,
private readonly string $classification,
private readonly string $category,
private readonly string $title
) {}

/**
Expand Down
Loading

0 comments on commit b802e51

Please sign in to comment.