Skip to content

Commit e5e14c8

Browse files
committed
use constructor property promotion
1 parent 7fc548d commit e5e14c8

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

Exception/ParseException.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,19 @@
1818
*/
1919
class ParseException extends RuntimeException
2020
{
21-
private ?string $parsedFile;
22-
private int $parsedLine;
23-
private ?string $snippet;
24-
private string $rawMessage;
25-
2621
/**
27-
* @param string $message The error message
22+
* @param string $rawMessage The error message
2823
* @param int $parsedLine The line where the error occurred
2924
* @param string|null $snippet The snippet of code near the problem
3025
* @param string|null $parsedFile The file name where the error occurred
3126
*/
32-
public function __construct(string $message, int $parsedLine = -1, ?string $snippet = null, ?string $parsedFile = null, ?\Throwable $previous = null)
33-
{
34-
$this->parsedFile = $parsedFile;
35-
$this->parsedLine = $parsedLine;
36-
$this->snippet = $snippet;
37-
$this->rawMessage = $message;
38-
27+
public function __construct(
28+
private string $rawMessage,
29+
private int $parsedLine = -1,
30+
private ?string $snippet = null,
31+
private ?string $parsedFile = null,
32+
?\Throwable $previous = null,
33+
) {
3934
$this->updateRepr();
4035

4136
parent::__construct($this->message, 0, $previous);

Tag/TaggedValue.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@
1717
*/
1818
final class TaggedValue
1919
{
20-
private string $tag;
21-
private mixed $value;
22-
23-
public function __construct(string $tag, mixed $value)
24-
{
25-
$this->tag = $tag;
26-
$this->value = $value;
20+
public function __construct(
21+
private string $tag,
22+
private mixed $value,
23+
) {
2724
}
2825

2926
public function getTag(): string

0 commit comments

Comments
 (0)