Skip to content

Commit 6819dca

Browse files
przepompowniadantleech
authored andcommitted
Use promoted properties
This change (by `ClassPropertyAssignToConstructorPromotionRector` Rector rule) does not touch properties with initializers as default value (to be done separately).
1 parent e493419 commit 6819dca

File tree

64 files changed

+89
-652
lines changed

Some content is hidden

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

64 files changed

+89
-652
lines changed

bin/serve.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
require __DIR__ . '/../vendor/autoload.php';
4848

49-
if ($argc === 1) {
49+
if (($argc ?? 0) === 1) {
5050
echo <<<DOC
5151
Usage: serve.php --address=127.0.0.1:9000 --type=tcp
5252

lib/Core/Command/ClosureCommand.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,8 @@
66

77
class ClosureCommand implements Command
88
{
9-
/**
10-
* @var Closure
11-
*/
12-
private $closure;
13-
14-
public function __construct(Closure $closure)
9+
public function __construct(private Closure $closure)
1510
{
16-
$this->closure = $closure;
1711
}
1812

1913
/**

lib/Core/Diagnostics/AggregateDiagnosticsProvider.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,9 @@ class AggregateDiagnosticsProvider implements DiagnosticsProvider
1616
*/
1717
private $providers;
1818

19-
/**
20-
* @var LoggerInterface
21-
*/
22-
private $logger;
23-
24-
public function __construct(LoggerInterface $logger, DiagnosticsProvider ...$providers)
19+
public function __construct(private LoggerInterface $logger, DiagnosticsProvider ...$providers)
2520
{
2621
$this->providers = $providers;
27-
$this->logger = $logger;
2822
}
2923

3024
/**

lib/Core/Diagnostics/ClosureDiagnosticsProvider.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,8 @@
99

1010
class ClosureDiagnosticsProvider implements DiagnosticsProvider
1111
{
12-
/**
13-
* @var Closure
14-
*/
15-
private $closure;
16-
17-
private string $name;
18-
19-
public function __construct(Closure $closure, string $name = 'closure')
12+
public function __construct(private Closure $closure, private string $name = 'closure')
2013
{
21-
$this->closure = $closure;
22-
$this->name = $name;
2314
}
2415

2516
public function provideDiagnostics(TextDocumentItem $textDocument, CancellationToken $cancel): Promise

lib/Core/Dispatcher/Dispatcher/ClosureDispatcher.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,11 @@
1010

1111
final class ClosureDispatcher implements Dispatcher
1212
{
13-
/**
14-
* @var Closure
15-
*/
16-
private $closure;
17-
1813
/**
1914
* @param Closure(Message): Promise<ResponseMessage|null> $closure
2015
*/
21-
public function __construct(Closure $closure)
16+
public function __construct(private Closure $closure)
2217
{
23-
$this->closure = $closure;
2418
}
2519

2620
/**

lib/Core/Dispatcher/Factory/ClosureDispatcherFactory.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,8 @@
1111

1212
final class ClosureDispatcherFactory implements DispatcherFactory
1313
{
14-
/**
15-
* @var Closure
16-
*/
17-
private $factory;
18-
19-
public function __construct(Closure $factory)
14+
public function __construct(private Closure $factory)
2015
{
21-
$this->factory = $factory;
2216
}
2317

2418
public function create(MessageTransmitter $transmitter, InitializeParams $initializeParams): Dispatcher

lib/Core/Handler/ClosureHandler.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,8 @@
66

77
final class ClosureHandler implements Handler
88
{
9-
/**
10-
* @var string
11-
*/
12-
private $methodName;
13-
14-
/**
15-
* @var Closure
16-
*/
17-
private $closure;
18-
19-
public function __construct(string $methodName, Closure $closure)
9+
public function __construct(private string $methodName, private Closure $closure)
2010
{
21-
$this->methodName = $methodName;
22-
$this->closure = $closure;
2311
}
2412

2513
/**

lib/Core/Handler/HandlerMethodRunner.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717

1818
final class HandlerMethodRunner implements MethodRunner
1919
{
20-
/**
21-
* @var Handlers
22-
*/
23-
private $handlers;
24-
2520
/**
2621
* @var HandlerMethodResolver
2722
*/
@@ -43,12 +38,11 @@ final class HandlerMethodRunner implements MethodRunner
4338
private $argumentResolver;
4439

4540
public function __construct(
46-
Handlers $handlers,
41+
private Handlers $handlers,
4742
?ArgumentResolver $argumentResolver = null,
4843
?LoggerInterface $logger = null,
4944
?HandlerMethodResolver $resolver = null
5045
) {
51-
$this->handlers = $handlers;
5246
$this->resolver = $resolver ?: new HandlerMethodResolver();
5347
$this->logger = $logger ?: new NullLogger();
5448
$this->argumentResolver = $argumentResolver ?: new PassThroughArgumentResolver();

lib/Core/Middleware/RequestHandler.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,10 @@
99

1010
final class RequestHandler
1111
{
12-
/**
13-
* @var array<Middleware>
14-
*/
15-
private $queue;
16-
17-
public function __construct(array $queue = [])
18-
{
19-
$this->queue = $queue;
12+
public function __construct(
13+
/** @var array<Middleware> */
14+
private array $queue = []
15+
) {
2016
}
2117

2218
/**

lib/Core/Rpc/NotificationMessage.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,10 @@
44

55
final class NotificationMessage extends Message
66
{
7-
/**
8-
* @var string
9-
*/
10-
public $method;
11-
12-
/**
13-
* @var array<string,mixed>|null
14-
*/
15-
public $params;
16-
17-
public function __construct(string $method, ?array $params = null)
18-
{
19-
$this->method = $method;
20-
$this->params = $params;
7+
public function __construct(
8+
public string $method,
9+
/** @var array<string,mixed>|null */
10+
public ?array $params = null
11+
) {
2112
}
2213
}

0 commit comments

Comments
 (0)