Skip to content

Commit 840fb8e

Browse files
committed
rector
1 parent 96f6ff1 commit 840fb8e

File tree

10 files changed

+44
-40
lines changed

10 files changed

+44
-40
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
class (@olegbaturin)
99
- Chg #137: Add separate parameters for each of `HtmlRenderer` settings in constructor. Mark `$settings` parameter as
1010
deprecated (@vjik)
11+
- Enh #138: Raise the minimum PHP version to 8.1 and minor refactoring (@vjik)
1112

1213
## 3.3.0 July 11, 2024
1314

rector.php

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,19 @@
66
use Rector\Config\RectorConfig;
77
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
88
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
9-
use Rector\Set\ValueObject\LevelSetList;
9+
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
1010

11-
return static function (RectorConfig $rectorConfig): void {
12-
$rectorConfig->paths([
11+
return RectorConfig::configure()
12+
->withPaths([
1313
__DIR__ . '/src',
1414
__DIR__ . '/tests',
15-
]);
16-
17-
// register a single rule
18-
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
19-
20-
// define sets of rules
21-
$rectorConfig->sets([
22-
LevelSetList::UP_TO_PHP_80,
23-
]);
24-
25-
$rectorConfig->skip([
15+
])
16+
->withPhpSets(php81: true)
17+
->withRules([
18+
InlineConstructorDefaultToPropertyRector::class,
19+
])
20+
->withSkip([
2621
ClosureToArrowFunctionRector::class,
22+
NullToStrictStringFuncCallArgRector::class,
2723
RemoveExtraParametersRector::class,
2824
]);
29-
};

src/CompositeException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ final class CompositeException extends Exception
1515
/**
1616
* @var Throwable[]
1717
*/
18-
private array $rest;
18+
private readonly array $rest;
1919

2020
public function __construct(
21-
private Throwable $first,
21+
private readonly Throwable $first,
2222
Throwable ...$rest,
2323
) {
2424
$this->rest = $rest;

src/ErrorData.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ final class ErrorData implements Stringable
1717
* @param array<string, string|string[]> $headers The headers to add to the response.
1818
*/
1919
public function __construct(
20-
private string $content,
21-
private array $headers = [],
20+
private readonly string $content,
21+
private readonly array $headers = [],
2222
) {
2323
}
2424

src/ErrorHandler.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ final class ErrorHandler
4747
* @param int $exitShutdownHandlerDepth Depth of the exit() shutdown handler to ensure it's executed last.
4848
*/
4949
public function __construct(
50-
private LoggerInterface $logger,
51-
private ThrowableRendererInterface $defaultRenderer,
52-
private ?EventDispatcherInterface $eventDispatcher = null,
53-
private int $exitShutdownHandlerDepth = 2
50+
private readonly LoggerInterface $logger,
51+
private readonly ThrowableRendererInterface $defaultRenderer,
52+
private readonly ?EventDispatcherInterface $eventDispatcher = null,
53+
private readonly int $exitShutdownHandlerDepth = 2
5454
) {
5555
}
5656

src/Event/ApplicationError.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
*/
1212
final class ApplicationError
1313
{
14-
public function __construct(private Throwable $throwable)
15-
{
14+
public function __construct(
15+
private readonly Throwable $throwable,
16+
) {
1617
}
1718

1819
public function getThrowable(): Throwable

src/Exception/ErrorException.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,15 @@ class ErrorException extends \ErrorException implements FriendlyExceptionInterfa
4040
];
4141

4242
/** @psalm-param DebugBacktraceType $backtrace */
43-
public function __construct(string $message = '', int $code = 0, int $severity = 1, string $filename = __FILE__, int $line = __LINE__, Exception $previous = null, private array $backtrace = [])
44-
{
43+
public function __construct(
44+
string $message = '',
45+
int $code = 0,
46+
int $severity = 1,
47+
string $filename = __FILE__,
48+
int $line = __LINE__,
49+
Exception $previous = null,
50+
private readonly array $backtrace = [],
51+
) {
4552
parent::__construct($message, $code, $severity, $filename, $line, $previous);
4653
$this->addXDebugTraceToFatalIfAvailable();
4754
}

src/Middleware/ErrorCatcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
final class ErrorCatcher implements MiddlewareInterface
2222
{
2323
public function __construct(
24-
private ThrowableResponseFactoryInterface $throwableResponseFactory,
25-
private ?EventDispatcherInterface $eventDispatcher = null,
24+
private readonly ThrowableResponseFactoryInterface $throwableResponseFactory,
25+
private readonly ?EventDispatcherInterface $eventDispatcher = null,
2626
) {
2727
}
2828

src/Middleware/ExceptionResponder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ final class ExceptionResponder implements MiddlewareInterface
5555
* catching exceptions that can be thrown in the process of body generation.
5656
*/
5757
public function __construct(
58-
private array $exceptionMap,
59-
private ResponseFactoryInterface $responseFactory,
60-
private Injector $injector,
61-
private bool $checkResponseBody = false,
58+
private readonly array $exceptionMap,
59+
private readonly ResponseFactoryInterface $responseFactory,
60+
private readonly Injector $injector,
61+
private readonly bool $checkResponseBody = false,
6262
) {
6363
}
6464

src/Renderer/HtmlRenderer.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,36 +51,36 @@
5151
*/
5252
final class HtmlRenderer implements ThrowableRendererInterface
5353
{
54-
private GithubMarkdown $markdownParser;
54+
private readonly GithubMarkdown $markdownParser;
5555

5656
/**
5757
* @var string The full path to the default template directory.
5858
*/
59-
private string $defaultTemplatePath;
59+
private readonly string $defaultTemplatePath;
6060

6161
/**
6262
* @var string The full path of the template file for rendering exceptions without call stack information.
6363
*
6464
* This template should be used in production.
6565
*/
66-
private string $template;
66+
private readonly string $template;
6767

6868
/**
6969
* @var string The full path of the template file for rendering exceptions with call stack information.
7070
*
7171
* This template should be used in development.
7272
*/
73-
private string $verboseTemplate;
73+
private readonly string $verboseTemplate;
7474

7575
/**
7676
* @var int The maximum number of source code lines to be displayed. Defaults to 19.
7777
*/
78-
private int $maxSourceLines;
78+
private readonly int $maxSourceLines;
7979

8080
/**
8181
* @var int The maximum number of trace source code lines to be displayed. Defaults to 13.
8282
*/
83-
private int $maxTraceLines;
83+
private readonly int $maxTraceLines;
8484

8585
/**
8686
* @var string|null The trace header line with placeholders to be be substituted. Defaults to null.
@@ -94,7 +94,7 @@ final class HtmlRenderer implements ThrowableRendererInterface
9494
* <a href="ide://open?file={file}&line={line}">{icon}</a>
9595
* ```
9696
*/
97-
private ?string $traceHeaderLine;
97+
private readonly ?string $traceHeaderLine;
9898

9999
/**
100100
* @var string[]|null The list of vendor paths is determined automatically.

0 commit comments

Comments
 (0)