Skip to content

Commit

Permalink
Up phpstan baseline
Browse files Browse the repository at this point in the history
  • Loading branch information
SerafimArts committed Sep 11, 2024
1 parent 94ba992 commit c0c95a6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
16 changes: 7 additions & 9 deletions src/ErrorInformationRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,21 @@ class ErrorInformationRenderer
*/
public const DEFAULT_HIGHLIGHT_CHAR = '^';

private PositionInterface $position;
private readonly PositionInterface $position;

private LineReader $reader;
private readonly LineReader $reader;

private string $sourceTemplate = self::DEFAULT_SOURCE_TEMPLATE;

private string $errorTemplate = self::DEFAULT_ERROR_TEMPLATE;

private string $highlightChar = self::DEFAULT_HIGHLIGHT_CHAR;

private TokenInterface $token;

public function __construct(ReadableInterface $source, TokenInterface $token)
{
$this->token = $token;

$this->position = Position::fromOffset($source, $token->getOffset());
public function __construct(
ReadableInterface $source,
private readonly TokenInterface $token,
) {
$this->position = Position::fromOffset($source, $this->token->getOffset());

$this->reader = new LineReader($source);
}
Expand Down
17 changes: 8 additions & 9 deletions src/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ abstract class RuntimeException extends \RuntimeException implements RuntimeExce

private ?ReadableInterface $source = null;

private string $original;

public function __construct(string $message = '', int $code = 0, ?\Throwable $previous = null)
{
$this->original = $message;

parent::__construct($message, $code, $previous);
public function __construct(
private readonly string $original = '',
int $code = 0,
?\Throwable $previous = null,
) {
parent::__construct($this->original, $code, $previous);
}

public function getOriginalMessage(): string
Expand Down Expand Up @@ -52,12 +51,12 @@ protected function sync(): void
{
$file = $this->getSource();

if ($file instanceof FileInterface && $this->token) {
if ($file instanceof FileInterface && $this->token !== null) {
$this->file = $file->getPathname();
$this->line = $this->getPosition()->getLine();
}

if ($this->source && $this->token) {
if ($this->source !== null && $this->token !== null) {
$this->message = $this->original . $this->getMessageSuffix($this->source, $this->token);
}
}
Expand Down
9 changes: 3 additions & 6 deletions src/UndefinedToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@
*/
final class UndefinedToken implements TokenInterface
{
private PositionInterface $position;

public function __construct(PositionInterface $position)
{
$this->position = $position;
}
public function __construct(
private readonly PositionInterface $position,
) {}

public function getName(): string
{
Expand Down

0 comments on commit c0c95a6

Please sign in to comment.