Skip to content

Commit a209ea1

Browse files
committed
Proper docblocks for filter arrays
1 parent ba2777a commit a209ea1

File tree

6 files changed

+35
-8
lines changed

6 files changed

+35
-8
lines changed

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,8 @@
3333
"Devdot\\LogArtisan\\ServiceProvider"
3434
]
3535
}
36+
},
37+
"require-dev": {
38+
"phpstan/phpstan": "^1.10"
3639
}
3740
}

phpstan.neon

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
parameters:
2+
3+
paths:
4+
- src/
5+
6+
ignoreErrors:
7+
-
8+
message: '#Function config not found#'
9+
-
10+
message: '#Call to an undefined method Illuminate\\Contracts\\Foundation\\Application::configurationIsCached\(\)#'
11+
path: src/Commands/AboutLog.php
12+
-
13+
message: '#Call to static method add\(\) on an unknown class Illuminate\\Foundation\\Console\\AboutCommand#'
14+
path: src/ServiceProvider.php
15+
-
16+
message: '#Call to method info\(\) on an unknown class Psr\\Log\\LoggerInterface.#'
17+
path: src/Commands/ClearLog.php

src/Commands/SearchLog.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
class SearchLog extends ShowLog {
1010
protected $description = 'Search through all log entries';
1111

12+
/**
13+
* @var array{count?: int, level?: string, search: string} Search is always set on SearchLog
14+
*/
15+
protected array $filter = [
16+
'search' => '',
17+
];
18+
1219
public function __construct() {
1320
// basically, we use the parent class and add an arugment
1421
parent::__construct();

src/Commands/ShowLog.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,9 @@ class ShowLog extends Command
4747
protected int $terminalWidth;
4848

4949
/**
50-
* @var array<string, int|string|null>
50+
* @var array{count?: int, level?: string, search?: string}
5151
*/
52-
protected array $filter = [
53-
'count' => null,
54-
'level' => null,
55-
];
52+
protected array $filter = [];
5653

5754
/**
5855
* Execute the console command.
@@ -102,7 +99,7 @@ public function handle()
10299
$multidriver = new DriverMultiple('', $channels);
103100

104101
// info line at top
105-
$this->line('Showing <fg=gray>'.$this->filter['count'].'</> entries from log channel <fg=gray>'.implode(', ', $channels).'</>'.($this->filter['level'] ? ' at level <fg=gray>'.$this->filter['level'].'</fg=gray>' : ''));
102+
$this->line('Showing <fg=gray>'.$this->filter['count'].'</> entries from log channel <fg=gray>'.implode(', ', $channels).'</>'.(isset($this->filter['level']) ? ' at level <fg=gray>'.$this->filter['level'].'</fg=gray>' : ''));
106103

107104
// check if we have files at all
108105
if(count($multidriver->getFilenames()) === 0) {

src/Models/Driver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function getLogs(): array {
5050
}
5151

5252
/**
53-
* @param array<string, int|string> $filter
53+
* @param array{count?: int, level?: string, search?: string} $filter Filter array as provided by ShowLog
5454
* @return array<LogRecord>
5555
*/
5656
public function getRecords(array $filter = []): array {
@@ -63,7 +63,7 @@ public function getRecords(array $filter = []): array {
6363
}
6464

6565
/**
66-
* @param array<string, int|string> $filter
66+
* @param array{count?: int, level?: string, search?: string} $filter Filter array as provided by ShowLog
6767
* @return array<LogRecord>
6868
*/
6969
protected function getFilteredRecords(array $filter): array {

src/Models/DriverMultiple.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ public function getLogs(): array {
6666
return $this->logs;
6767
}
6868

69+
/**
70+
* @param array{count?: int, level?: string, search?: string} $filter Filter array as provided by ShowLog
71+
*/
6972
protected function accumulateRecords(array $filter = []): void {
7073
$this->records = [];
7174
foreach($this->drivers as $driver) {

0 commit comments

Comments
 (0)