Skip to content

Commit

Permalink
use constructor property promotion
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Feb 21, 2024
1 parent 7fc548d commit e5e14c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
21 changes: 8 additions & 13 deletions Exception/ParseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,19 @@
*/
class ParseException extends RuntimeException
{
private ?string $parsedFile;
private int $parsedLine;
private ?string $snippet;
private string $rawMessage;

/**
* @param string $message The error message
* @param string $rawMessage The error message
* @param int $parsedLine The line where the error occurred
* @param string|null $snippet The snippet of code near the problem
* @param string|null $parsedFile The file name where the error occurred
*/
public function __construct(string $message, int $parsedLine = -1, ?string $snippet = null, ?string $parsedFile = null, ?\Throwable $previous = null)
{
$this->parsedFile = $parsedFile;
$this->parsedLine = $parsedLine;
$this->snippet = $snippet;
$this->rawMessage = $message;

public function __construct(
private string $rawMessage,
private int $parsedLine = -1,
private ?string $snippet = null,
private ?string $parsedFile = null,
?\Throwable $previous = null,
) {
$this->updateRepr();

parent::__construct($this->message, 0, $previous);
Expand Down
11 changes: 4 additions & 7 deletions Tag/TaggedValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@
*/
final class TaggedValue
{
private string $tag;
private mixed $value;

public function __construct(string $tag, mixed $value)
{
$this->tag = $tag;
$this->value = $value;
public function __construct(
private string $tag,
private mixed $value,
) {
}

public function getTag(): string
Expand Down

0 comments on commit e5e14c8

Please sign in to comment.