Skip to content

Commit b802e51

Browse files
committed
use rector
1 parent ae4c897 commit b802e51

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+256
-230
lines changed

Diff for: composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
"symfony/uid": "^5.0",
5656
"symfony/var-dumper": "^5.0",
5757
"cache/integration-tests": "dev-master",
58-
"kubawerlos/php-cs-fixer-custom-fixers": "3.13.*"
58+
"kubawerlos/php-cs-fixer-custom-fixers": "3.13.*",
59+
"rector/rector": "^1.0"
5960
},
6061
"autoload": {
6162
"psr-4": {

Diff for: rector.php

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the Neo4j PHP Client and Driver package.
7+
*
8+
* (c) Nagels <https://nagels.tech>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
use Rector\Config\RectorConfig;
15+
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
16+
17+
return RectorConfig::configure()
18+
->withPaths([
19+
__DIR__.'/src',
20+
__DIR__.'/tests',
21+
])
22+
->withPhpSets(php81: true)
23+
->withRules([
24+
AddVoidReturnTypeWhereNoReturnRector::class,
25+
]);

Diff for: src/Authentication/BasicAuth.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ final class BasicAuth implements AuthenticateInterface
3434
* @psalm-external-mutation-free
3535
*/
3636
public function __construct(
37-
private string $username,
38-
private string $password
37+
private readonly string $username,
38+
private readonly string $password
3939
) {}
4040

4141
/**

Diff for: src/Authentication/KerberosAuth.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ final class KerberosAuth implements AuthenticateInterface
3333
* @psalm-external-mutation-free
3434
*/
3535
public function __construct(
36-
private string $token
36+
private readonly string $token
3737
) {}
3838

3939
/**

Diff for: src/Authentication/OpenIDConnectAuth.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ final class OpenIDConnectAuth implements AuthenticateInterface
3030
* @psalm-external-mutation-free
3131
*/
3232
public function __construct(
33-
private string $token
33+
private readonly string $token
3434
) {}
3535

3636
/**

Diff for: src/Basic/Client.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ final class Client implements ClientInterface
2929
* @param ClientInterface<SummarizedResult<CypherMap>> $client
3030
*/
3131
public function __construct(
32-
private ClientInterface $client
32+
private readonly ClientInterface $client
3333
) {}
3434

3535
public function run(string $statement, iterable $parameters = [], ?string $alias = null): SummarizedResult

Diff for: src/Basic/Driver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class Driver implements DriverInterface
3434
* @psalm-external-mutation-free
3535
*/
3636
public function __construct(
37-
private DriverInterface $driver
37+
private readonly DriverInterface $driver
3838
) {}
3939

4040
/**

Diff for: src/Basic/Session.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ final class Session implements SessionInterface
3030
* @param SessionInterface<SummarizedResult<CypherMap>> $session
3131
*/
3232
public function __construct(
33-
private SessionInterface $session
33+
private readonly SessionInterface $session
3434
) {}
3535

3636
/**

Diff for: src/Basic/UnmanagedTransaction.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class UnmanagedTransaction implements UnmanagedTransactionInterface
2828
* @param UnmanagedTransactionInterface<SummarizedResult<CypherMap>> $tsx
2929
*/
3030
public function __construct(
31-
private UnmanagedTransactionInterface $tsx
31+
private readonly UnmanagedTransactionInterface $tsx
3232
) {}
3333

3434
/**

Diff for: src/Bolt/BoltConnection.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ public function getImplementation(): array
6565
*/
6666
public function __construct(
6767
private V4_4|V5 $boltProtocol,
68-
private Connection $connection,
69-
private AuthenticateInterface $auth,
70-
private string $userAgent,
68+
private readonly Connection $connection,
69+
private readonly AuthenticateInterface $auth,
70+
private readonly string $userAgent,
7171
/** @psalm-readonly */
72-
private ConnectionConfiguration $config
72+
private readonly ConnectionConfiguration $config
7373
) {}
7474

7575
public function getEncryptionLevel(): string

Diff for: src/Bolt/BoltDriver.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ final class BoltDriver implements DriverInterface
4747
* @psalm-mutation-free
4848
*/
4949
public function __construct(
50-
private UriInterface $parsedUrl,
51-
private ConnectionPool $pool,
52-
private FormatterInterface $formatter
50+
private readonly UriInterface $parsedUrl,
51+
private readonly ConnectionPool $pool,
52+
private readonly FormatterInterface $formatter
5353
) {}
5454

5555
/**
@@ -103,7 +103,7 @@ public function verifyConnectivity(?SessionConfiguration $config = null): bool
103103
$config ??= SessionConfiguration::default();
104104
try {
105105
GeneratorHelper::getReturnFromGenerator($this->pool->acquire($config));
106-
} catch (Throwable $e) {
106+
} catch (Throwable) {
107107
return false;
108108
}
109109

Diff for: src/Bolt/BoltResult.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ final class BoltResult implements Iterator
3737
private array $finishedCallbacks = [];
3838

3939
public function __construct(
40-
private BoltConnection $connection,
41-
private int $fetchSize,
42-
private int $qid
40+
private readonly BoltConnection $connection,
41+
private readonly int $fetchSize,
42+
private readonly int $qid
4343
) {}
4444

4545
public function getFetchSize(): int

Diff for: src/Bolt/BoltUnmanagedTransaction.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ final class BoltUnmanagedTransaction implements UnmanagedTransactionInterface
4949
*/
5050
public function __construct(
5151
/** @psalm-readonly */
52-
private ?string $database,
52+
private readonly ?string $database,
5353
/**
5454
* @psalm-readonly
5555
*/
56-
private FormatterInterface $formatter,
56+
private readonly FormatterInterface $formatter,
5757
/** @psalm-readonly */
58-
private BoltConnection $connection,
59-
private SessionConfiguration $config,
60-
private TransactionConfiguration $tsxConfig,
61-
private BookmarkHolder $bookmarkHolder
58+
private readonly BoltConnection $connection,
59+
private readonly SessionConfiguration $config,
60+
private readonly TransactionConfiguration $tsxConfig,
61+
private readonly BookmarkHolder $bookmarkHolder
6262
) {}
6363

6464
public function commit(iterable $statements = []): CypherList

Diff for: src/Bolt/Connection.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class Connection
2424
* @param ''|'s'|'ssc' $ssl
2525
*/
2626
public function __construct(
27-
private IConnection $connection,
28-
private string $ssl
27+
private readonly IConnection $connection,
28+
private readonly string $ssl
2929
) {}
3030

3131
public function getIConnection(): IConnection

Diff for: src/Bolt/ConnectionPool.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ final class ConnectionPool implements ConnectionPoolInterface
3939
private array $activeConnections = [];
4040

4141
public function __construct(
42-
private SemaphoreInterface $semaphore,
43-
private BoltFactory $factory,
44-
private ConnectionRequestData $data
42+
private readonly SemaphoreInterface $semaphore,
43+
private readonly BoltFactory $factory,
44+
private readonly ConnectionRequestData $data
4545
) {}
4646

4747
public static function create(UriInterface $uri, AuthenticateInterface $auth, DriverConfiguration $conf, SemaphoreInterface $semaphore): self

Diff for: src/Bolt/Session.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
final class Session implements SessionInterface
4242
{
4343
/** @psalm-readonly */
44-
private BookmarkHolder $bookmarkHolder;
44+
private readonly BookmarkHolder $bookmarkHolder;
4545

4646
/**
4747
* @param ConnectionPool|Neo4jConnectionPool $pool
@@ -51,12 +51,12 @@ final class Session implements SessionInterface
5151
*/
5252
public function __construct(
5353
/** @psalm-readonly */
54-
private SessionConfiguration $config,
55-
private ConnectionPoolInterface $pool,
54+
private readonly SessionConfiguration $config,
55+
private readonly ConnectionPoolInterface $pool,
5656
/**
5757
* @psalm-readonly
5858
*/
59-
private FormatterInterface $formatter
59+
private readonly FormatterInterface $formatter
6060
) {
6161
$this->bookmarkHolder = new BookmarkHolder(Bookmark::from($config->getBookmarks()));
6262
}

Diff for: src/Bolt/SocketConnectionFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
final class SocketConnectionFactory implements BasicConnectionFactoryInterface
2121
{
2222
public function __construct(
23-
private StreamConnectionFactory $factory
23+
private readonly StreamConnectionFactory $factory
2424
) {}
2525

2626
public function create(UriConfiguration $config): Connection

Diff for: src/Bolt/UriConfiguration.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ final class UriConfiguration
1919
* @param ''|'s'|'ssc' $sslLevel
2020
*/
2121
public function __construct(
22-
private string $host,
23-
private ?int $port,
24-
private string $sslLevel,
25-
private array $sslConfiguration,
26-
private ?float $timeout
22+
private readonly string $host,
23+
private readonly ?int $port,
24+
private readonly string $sslLevel,
25+
private readonly array $sslConfiguration,
26+
private readonly ?float $timeout
2727
) {}
2828

2929
public function getHost(): string

Diff for: src/BoltFactory.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ class BoltFactory
3838
* @psalm-external-mutation-free
3939
*/
4040
public function __construct(
41-
private BasicConnectionFactoryInterface $connectionFactory,
42-
private ProtocolFactory $protocolFactory,
43-
private SslConfigurationFactory $sslConfigurationFactory
41+
private readonly BasicConnectionFactoryInterface $connectionFactory,
42+
private readonly ProtocolFactory $protocolFactory,
43+
private readonly SslConfigurationFactory $sslConfigurationFactory
4444
) {}
4545

4646
public static function create(): self

Diff for: src/Client.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ final class Client implements ClientInterface
5050
* @param DriverSetupManager<ResultFormat> $driverSetups
5151
*/
5252
public function __construct(
53-
private DriverSetupManager $driverSetups,
54-
private SessionConfiguration $defaultSessionConfiguration,
55-
private TransactionConfiguration $defaultTransactionConfiguration
53+
private readonly DriverSetupManager $driverSetups,
54+
private readonly SessionConfiguration $defaultSessionConfiguration,
55+
private readonly TransactionConfiguration $defaultTransactionConfiguration
5656
) {}
5757

5858
public function getDriverSetups(): DriverSetupManager

Diff for: src/Common/ConnectionConfiguration.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ final class ConnectionConfiguration
2727
* @param ''|'s'|'ssc' $encryptionLevel
2828
*/
2929
public function __construct(
30-
private string $serverAgent,
31-
private UriInterface $serverAddress,
32-
private string $serverVersion,
33-
private ConnectionProtocol $protocol,
34-
private AccessMode $accessMode,
35-
private ?DatabaseInfo $databaseInfo,
36-
private string $encryptionLevel
30+
private readonly string $serverAgent,
31+
private readonly UriInterface $serverAddress,
32+
private readonly string $serverVersion,
33+
private readonly ConnectionProtocol $protocol,
34+
private readonly AccessMode $accessMode,
35+
private readonly ?DatabaseInfo $databaseInfo,
36+
private readonly string $encryptionLevel
3737
) {}
3838

3939
public function getServerAgent(): string

Diff for: src/Common/SingleThreadedSemaphore.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class SingleThreadedSemaphore implements SemaphoreInterface
2727
private static array $instances = [];
2828

2929
private function __construct(
30-
private int $max
30+
private readonly int $max
3131
) {}
3232

3333
public static function create(string $key, int $max): self

Diff for: src/Common/Uri.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
final class Uri implements UriInterface, Stringable
3333
{
3434
public function __construct(
35-
private string $scheme,
36-
private string $userInfo,
35+
private readonly string $scheme,
36+
private readonly string $userInfo,
3737
private string $host,
38-
private ?int $port,
38+
private readonly ?int $port,
3939
private string $path,
40-
private string $query,
41-
private string $fragment
40+
private readonly string $query,
41+
private readonly string $fragment
4242
) {}
4343

4444
/**

Diff for: src/Databags/Bookmark.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
final class Bookmark
1919
{
2020
/** @var list<string> */
21-
private array $values;
21+
private readonly array $values;
2222

2323
/**
2424
* @param list<string> $bookmarks

Diff for: src/Databags/ConnectionRequestData.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
final class ConnectionRequestData
2323
{
2424
public function __construct(
25-
private UriInterface $uri,
26-
private AuthenticateInterface $auth,
27-
private string $userAgent,
28-
private SslConfiguration $config
25+
private readonly UriInterface $uri,
26+
private readonly AuthenticateInterface $auth,
27+
private readonly string $userAgent,
28+
private readonly SslConfiguration $config
2929
) {}
3030

3131
public function getUri(): UriInterface

Diff for: src/Databags/DatabaseInfo.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
final class DatabaseInfo extends AbstractCypherObject
2424
{
2525
public function __construct(
26-
private string $name
26+
private readonly string $name
2727
) {}
2828

2929
/**

Diff for: src/Databags/DriverSetup.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
final class DriverSetup
2525
{
2626
public function __construct(
27-
private UriInterface $uri,
28-
private AuthenticateInterface $auth
27+
private readonly UriInterface $uri,
28+
private readonly AuthenticateInterface $auth
2929
) {}
3030

3131
public function getAuth(): AuthenticateInterface

Diff for: src/Databags/InputPosition.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
final class InputPosition
2222
{
2323
public function __construct(
24-
private int $column,
25-
private int $line,
26-
private int $offset
24+
private readonly int $column,
25+
private readonly int $line,
26+
private readonly int $offset
2727
) {}
2828

2929
/**

Diff for: src/Databags/Neo4jError.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
final class Neo4jError
2727
{
2828
public function __construct(
29-
private string $code,
30-
private ?string $message,
31-
private string $classification,
32-
private string $category,
33-
private string $title
29+
private readonly string $code,
30+
private readonly ?string $message,
31+
private readonly string $classification,
32+
private readonly string $category,
33+
private readonly string $title
3434
) {}
3535

3636
/**

0 commit comments

Comments
 (0)