Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
arukompas authored and github-actions[bot] committed Dec 14, 2023
1 parent 647b0c4 commit ca84af0
Show file tree
Hide file tree
Showing 25 changed files with 60 additions and 60 deletions.
2 changes: 1 addition & 1 deletion src/Concerns/LogFile/HasMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function setMetadata(string $attribute, $value): void
$this->metadata[$attribute] = $value;
}

public function getMetadata(string $attribute = null, $default = null): mixed
public function getMetadata(?string $attribute = null, $default = null): mixed
{
if (! isset($this->metadata)) {
$this->loadMetadata();
Expand Down
14 changes: 7 additions & 7 deletions src/Concerns/LogIndex/CanFilterIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ trait CanFilterIndex
protected ?int $limit = null;
protected ?int $skip = null;

public function setQuery(string $query = null): self
public function setQuery(?string $query = null): self
{
if ($this->query !== $query) {
$this->query = $query;
Expand All @@ -29,7 +29,7 @@ public function getQuery(): ?string
return $this->query;
}

public function forDateRange(int|CarbonInterface $from = null, int|CarbonInterface $to = null): self
public function forDateRange(int|CarbonInterface|null $from = null, int|CarbonInterface|null $to = null): self
{
if ($from instanceof CarbonInterface) {
$from = $from->timestamp;
Expand All @@ -45,7 +45,7 @@ public function forDateRange(int|CarbonInterface $from = null, int|CarbonInterfa
return $this;
}

public function forLevels(string|array $levels = null): self
public function forLevels(string|array|null $levels = null): self
{
if (is_string($levels)) {
$levels = [$levels];
Expand All @@ -60,7 +60,7 @@ public function forLevels(string|array $levels = null): self
return $this;
}

public function exceptLevels(string|array $levels = null): self
public function exceptLevels(string|array|null $levels = null): self
{
if (is_null($levels)) {
$this->excludeLevels = null;
Expand All @@ -73,7 +73,7 @@ public function exceptLevels(string|array $levels = null): self
return $this;
}

public function forLevel(string $level = null): self
public function forLevel(?string $level = null): self
{
return $this->forLevels($level);
}
Expand All @@ -84,7 +84,7 @@ public function isLevelSelected(string $level): bool
&& (is_null($this->excludeLevels) || ! in_array($level, $this->excludeLevels));
}

public function skip(int $skip = null): self
public function skip(?int $skip = null): self
{
$this->skip = $skip;

Expand All @@ -96,7 +96,7 @@ public function getSkip(): ?int
return $this->skip;
}

public function limit(int $limit = null): self
public function limit(?int $limit = null): self
{
$this->limit = $limit;

Expand Down
4 changes: 2 additions & 2 deletions src/Concerns/LogReader/CanFilterUsingIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ public function limit(int $number): static
return $this;
}

public function search(string $query = null): static
public function search(?string $query = null): static
{
return $this->setQuery($query);
}

protected function setQuery(string $query = null): static
protected function setQuery(?string $query = null): static
{
$this->closeFile();

Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/LogReader/CanSetDirectionUsingIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function forward(): static
return $this->setDirection(Direction::Forward);
}

public function setDirection(string $direction = null): static
public function setDirection(?string $direction = null): static
{
$direction = $direction === Direction::Backward
? Direction::Backward
Expand Down
8 changes: 4 additions & 4 deletions src/LogFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class LogFile
private ?string $type = null;
private array $_logIndexCache;

public function __construct(string $path, string $type = null)
public function __construct(string $path, ?string $type = null)
{
$this->path = $path;
$this->name = basename($path);
Expand Down Expand Up @@ -59,7 +59,7 @@ public function type(): LogType
return new LogType($this->type ?? LogType::DEFAULT);
}

public function index(string $query = null): LogIndex
public function index(?string $query = null): LogIndex
{
if (! isset($this->_logIndexCache[$query])) {
$this->_logIndexCache[$query] = new LogIndex($this, $query);
Expand Down Expand Up @@ -171,7 +171,7 @@ public function latestTimestamp(): int
return $this->getMetadata('latest_timestamp') ?? $this->mtime();
}

public function scan(int $maxBytesToScan = null, bool $force = false): void
public function scan(?int $maxBytesToScan = null, bool $force = false): void
{
$this->logs()->scan($maxBytesToScan, $force);
}
Expand All @@ -184,7 +184,7 @@ public function requiresScan(): bool
/**
* @throws InvalidRegularExpression
*/
public function search(string $query = null): LogReaderInterface
public function search(?string $query = null): LogReaderInterface
{
return $this->logs()->search($query);
}
Expand Down
6 changes: 3 additions & 3 deletions src/LogIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(
$this->loadMetadata();
}

public function addToIndex(int $filePosition, int|CarbonInterface $timestamp, string $severity, int $index = null): int
public function addToIndex(int $filePosition, int|CarbonInterface $timestamp, string $severity, ?int $index = null): int
{
$logIndex = $index ?? $this->nextLogIndexToCreate ?? 0;

Expand Down Expand Up @@ -75,7 +75,7 @@ public function getPositionForIndex(int $indexToFind): ?int
return null;
}

public function get(int $limit = null): array
public function get(?int $limit = null): array
{
$results = [];
$itemsAdded = 0;
Expand Down Expand Up @@ -157,7 +157,7 @@ public function get(int $limit = null): array
return $results;
}

public function getFlatIndex(int $limit = null): array
public function getFlatIndex(?int $limit = null): array
{
$results = [];
$itemsAdded = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/LogLevels/HorizonStatusLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function __construct(string $value)
$this->value = $value;
}

public static function from(string $value = null): LevelInterface
public static function from(?string $value = null): LevelInterface
{
return new static($value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/LogLevels/HttpStatusCodeLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public function __construct(
) {
}

public static function from(string $value = null): LevelInterface
public static function from(?string $value = null): LevelInterface
{
return new static($value);
}
Expand Down
4 changes: 2 additions & 2 deletions src/LogLevels/LaravelLogLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class LaravelLogLevel implements LevelInterface

public string $value;

public function __construct(string $value = null)
public function __construct(?string $value = null)
{
$this->value = $value ?? self::None;
}
Expand All @@ -36,7 +36,7 @@ public static function cases(): array
];
}

public static function from(string $value = null): self
public static function from(?string $value = null): self
{
return new self($value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/LogLevels/LevelClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function __construct(
) {
}

public static function from(string $value = null): LevelClass
public static function from(?string $value = null): LevelClass
{
return new static($value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/LogLevels/LevelInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface LevelInterface
{
public function __construct(string $value);

public static function from(string $value = null): self;
public static function from(?string $value = null): self;

public static function caseValues(): array;

Expand Down
4 changes: 2 additions & 2 deletions src/LogLevels/NginxStatusLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class NginxStatusLevel implements LevelInterface

public string $value;

public function __construct(string $value = null)
public function __construct(?string $value = null)
{
$this->value = $value ?? self::Error;
}
Expand All @@ -34,7 +34,7 @@ public static function cases(): array
];
}

public static function from(string $value = null): self
public static function from(?string $value = null): self
{
return new self($value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/LogLevels/PostgresLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function __construct(string $value)
$this->value = $value;
}

public static function from(string $value = null): LevelInterface
public static function from(?string $value = null): LevelInterface
{
return new static($value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/LogLevels/RedisLogLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function __construct(string $value)
$this->value = $value;
}

public static function from(string $value = null): LevelInterface
public static function from(?string $value = null): LevelInterface
{
return new static($value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/LogLevels/SupervisorLogLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(string $value)
$this->value = $value;
}

public static function from(string $value = null): LevelInterface
public static function from(?string $value = null): LevelInterface
{
return new static($value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Logs/HorizonLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function fillMatches(array $matches = []): void
]);
}

public static function matches(string $text, int &$timestamp = null, string &$level = null): bool
public static function matches(string $text, ?int &$timestamp = null, ?string &$level = null): bool
{
return parent::matches($text, $timestamp, $level)
|| (str_contains($text, 'Horizon started successfully') && throw new SkipLineException);
Expand Down
4 changes: 2 additions & 2 deletions src/Logs/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Log
public ?int $filePosition;
public ?int $index;

public function __construct(string $text, string $fileIdentifier = null, int $filePosition = null, int $index = null)
public function __construct(string $text, ?string $fileIdentifier = null, ?int $filePosition = null, ?int $index = null)
{
$this->text = rtrim($text);
$this->fileIdentifier = $fileIdentifier;
Expand All @@ -60,7 +60,7 @@ public function __construct(string $text, string $fileIdentifier = null, int $fi
unset($matches);
}

public static function matches(string $text, int &$timestamp = null, string &$level = null): bool
public static function matches(string $text, ?int &$timestamp = null, ?string &$level = null): bool
{
$matches = [];
$result = preg_match(static::$regex, $text, $matches) === 1;
Expand Down
6 changes: 3 additions & 3 deletions src/Readers/IndexedLogReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function lazyScanning($lazy = true): static
*
* @throws CannotOpenFileException
*/
public function scan(int $maxBytesToScan = null, bool $force = false): static
public function scan(?int $maxBytesToScan = null, bool $force = false): static
{
if (is_null($maxBytesToScan)) {
$maxBytesToScan = LogViewer::lazyScanChunkSize();
Expand Down Expand Up @@ -188,7 +188,7 @@ public function getLevelCounts(): array
*
* @throws CannotOpenFileException
*/
public function get(int $limit = null): array
public function get(?int $limit = null): array
{
if (! is_null($limit) && method_exists($this, 'limit')) {
$this->limit($limit);
Expand Down Expand Up @@ -230,7 +230,7 @@ public function total(): int
return $this->index()->count();
}

public function paginate(int $perPage = 25, int $page = null)
public function paginate(int $perPage = 25, ?int $page = null)
{
$page = $page ?: Paginator::resolveCurrentPage('page');

Expand Down
10 changes: 5 additions & 5 deletions src/Readers/LogReaderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static function clearInstance(LogFile $file): void;
public static function clearInstances(): void;

// Search/querying
public function search(string $query = null): static;
public function search(?string $query = null): static;

public function skip(int $number): static;

Expand All @@ -26,7 +26,7 @@ public function reverse(): static;

public function forward(): static;

public function setDirection(string $direction = null): static;
public function setDirection(?string $direction = null): static;

public function getLevelCounts(): array;

Expand All @@ -41,20 +41,20 @@ public function except($levels = null): static;
public function exceptLevels($levels = null): static;

// Retrieving actual logs
public function get(int $limit = null): array;
public function get(?int $limit = null): array;

public function next(): ?Log;

/** @return LengthAwarePaginator<Log> */
public function paginate(int $perPage = 25, int $page = null);
public function paginate(int $perPage = 25, ?int $page = null);

public function total(): int;

// Functional
public function reset(): static;

// We should decouple scanning from the LogReader
public function scan(int $maxBytesToScan = null, bool $force = false): static;
public function scan(?int $maxBytesToScan = null, bool $force = false): static;

public function numberOfNewBytes(): int;

Expand Down
10 changes: 5 additions & 5 deletions src/Readers/MultipleLogReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function allLevels(): self
return $this;
}

public function setDirection(string $direction = null): self
public function setDirection(?string $direction = null): self
{
$this->direction = $direction === Direction::Backward
? Direction::Backward
Expand Down Expand Up @@ -87,7 +87,7 @@ public function limit(int $number): self
return $this;
}

public function search(string $query = null): self
public function search(?string $query = null): self
{
$this->query = $query;

Expand Down Expand Up @@ -121,7 +121,7 @@ public function total(): int
});
}

public function paginate($perPage = 25, int $page = null): LengthAwarePaginator
public function paginate($perPage = 25, ?int $page = null): LengthAwarePaginator
{
$page = $page ?: Paginator::resolveCurrentPage('page');

Expand All @@ -140,7 +140,7 @@ public function paginate($perPage = 25, int $page = null): LengthAwarePaginator
*
* @return array|Log[]
*/
public function get(int $limit = null): array
public function get(?int $limit = null): array
{
$skip = $this->skip ?? null;
$limit = $limit ?? $this->limit ?? null;
Expand Down Expand Up @@ -204,7 +204,7 @@ public function percentScanned(): int
return 100 - intval($missingScansBytes / $totalFileBytes * 100);
}

public function scan(int $maxBytesToScan = null, bool $force = false): void
public function scan(?int $maxBytesToScan = null, bool $force = false): void
{
$fileSizeScanned = 0;
$stopScanningAfter = microtime(true) + LogViewer::lazyScanTimeout();
Expand Down
Loading

0 comments on commit ca84af0

Please sign in to comment.