Skip to content

Commit 4a212b1

Browse files
♻️ doc types first pass (#994)
* ♻️ doc types first pass * Fix --------- Co-authored-by: erikn69 <[email protected]>
1 parent f7cbe09 commit 4a212b1

19 files changed

+39
-101
lines changed

src/Audit.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ trait Audit
1616
/**
1717
* Audit data.
1818
*
19-
* @var array
19+
* @var array<string,mixed>
2020
*/
2121
protected $data = [];
2222

2323
/**
2424
* The Audit attributes that belong to the metadata.
2525
*
26-
* @var array
26+
* @var array<int,string>
2727
*/
2828
protected $metadata = [];
2929

3030
/**
3131
* The Auditable attributes that were modified.
3232
*
33-
* @var array
33+
* @var array<int,string>
3434
*/
3535
protected $modified = [];
3636

@@ -118,8 +118,6 @@ public function resolveData(): array
118118
/**
119119
* Get the formatted value of an Eloquent model.
120120
*
121-
* @param Model $model
122-
* @param string $key
123121
* @param mixed $value
124122
*
125123
* @return mixed
@@ -162,6 +160,11 @@ protected function getFormattedValue(Model $model, string $key, $value)
162160
return $value;
163161
}
164162

163+
/**
164+
* @param Model $model
165+
* @param mixed $value
166+
* @return mixed
167+
*/
165168
private function castDatetimeUTC($model, $value)
166169
{
167170
if (!is_string($value)) {
@@ -222,8 +225,6 @@ public function getDataValue(string $key)
222225
/**
223226
* Decode attribute value.
224227
*
225-
* @param Contracts\Auditable $auditable
226-
* @param string $attribute
227228
* @param mixed $value
228229
*
229230
* @return mixed
@@ -306,10 +307,10 @@ public function getModified(bool $json = false, int $options = 0, int $depth = 5
306307
/**
307308
* Get the Audit tags as an array.
308309
*
309-
* @return array
310+
* @return array<string>
310311
*/
311312
public function getTags(): array
312313
{
313-
return preg_split('/,/', $this->tags, -1, PREG_SPLIT_NO_EMPTY);
314+
return preg_split('/,/', $this->tags, -1, PREG_SPLIT_NO_EMPTY)?: [];
314315
}
315316
}

src/AuditableObserver.php

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ class AuditableObserver
2020
/**
2121
* Handle the retrieved event.
2222
*
23-
* @param \OwenIt\Auditing\Contracts\Auditable $model
24-
*
2523
* @return void
2624
*/
2725
public function retrieved(Auditable $model)
@@ -32,8 +30,6 @@ public function retrieved(Auditable $model)
3230
/**
3331
* Handle the created event.
3432
*
35-
* @param \OwenIt\Auditing\Contracts\Auditable $model
36-
*
3733
* @return void
3834
*/
3935
public function created(Auditable $model)
@@ -44,8 +40,6 @@ public function created(Auditable $model)
4440
/**
4541
* Handle the updated event.
4642
*
47-
* @param \OwenIt\Auditing\Contracts\Auditable $model
48-
*
4943
* @return void
5044
*/
5145
public function updated(Auditable $model)
@@ -59,8 +53,6 @@ public function updated(Auditable $model)
5953
/**
6054
* Handle the deleted event.
6155
*
62-
* @param \OwenIt\Auditing\Contracts\Auditable $model
63-
*
6456
* @return void
6557
*/
6658
public function deleted(Auditable $model)
@@ -71,8 +63,6 @@ public function deleted(Auditable $model)
7163
/**
7264
* Handle the restoring event.
7365
*
74-
* @param \OwenIt\Auditing\Contracts\Auditable $model
75-
*
7666
* @return void
7767
*/
7868
public function restoring(Auditable $model)
@@ -86,8 +76,6 @@ public function restoring(Auditable $model)
8676
/**
8777
* Handle the restored event.
8878
*
89-
* @param \OwenIt\Auditing\Contracts\Auditable $model
90-
*
9179
* @return void
9280
*/
9381
public function restored(Auditable $model)
@@ -99,7 +87,7 @@ public function restored(Auditable $model)
9987
static::$restoring = false;
10088
}
10189

102-
protected function dispatchAudit(Auditable $model)
90+
protected function dispatchAudit(Auditable $model): void
10391
{
10492
if (!$model->readyForAuditing()) {
10593
return;
@@ -121,10 +109,6 @@ protected function dispatchAudit(Auditable $model)
121109

122110
/**
123111
* Fire the Auditing event.
124-
*
125-
* @param \OwenIt\Auditing\Contracts\Auditable $model
126-
*
127-
* @return bool
128112
*/
129113
protected function fireDispatchingAuditEvent(Auditable $model): bool
130114
{

src/Auditor.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ public function execute(Auditable $model): void
9494

9595
/**
9696
* Create an instance of the Database audit driver.
97-
*
98-
* @return \OwenIt\Auditing\Drivers\Database
9997
*/
10098
protected function createDatabaseDriver(): Database
10199
{
@@ -104,11 +102,6 @@ protected function createDatabaseDriver(): Database
104102

105103
/**
106104
* Fire the Auditing event.
107-
*
108-
* @param \OwenIt\Auditing\Contracts\Auditable $model
109-
* @param \OwenIt\Auditing\Contracts\AuditDriver $driver
110-
*
111-
* @return bool
112105
*/
113106
protected function fireAuditingEvent(Auditable $model, AuditDriver $driver): bool
114107
{

src/Console/InstallCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class InstallCommand extends Command
2020
/**
2121
* {@inheritdoc}
2222
*/
23-
public function handle()
23+
public function handle(): void
2424
{
2525
$this->comment('Publishing Auditing Configuration...');
2626
$this->callSilent('vendor:publish', ['--tag' => 'config']);

src/Contracts/AttributeRedactor.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ interface AttributeRedactor extends AttributeModifier
88
* Redact an attribute value.
99
*
1010
* @param mixed $value
11-
*
12-
* @return string
1311
*/
1412
public static function redact($value): string;
1513
}

src/Contracts/Audit.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function user();
3838
/**
3939
* Audit data resolver.
4040
*
41-
* @return array
41+
* @return array<string,mixed>
4242
*/
4343
public function resolveData(): array;
4444

@@ -55,21 +55,21 @@ public function getDataValue(string $key);
5555
* Get the Audit metadata.
5656
*
5757
* @param bool $json
58-
* @param int $options
59-
* @param int $depth
58+
* @param int $options
59+
* @param int<1, max> $depth
6060
*
61-
* @return array|string
61+
* @return array<string,mixed>|string
6262
*/
6363
public function getMetadata(bool $json = false, int $options = 0, int $depth = 512);
6464

6565
/**
6666
* Get the Auditable modified attributes.
6767
*
6868
* @param bool $json
69-
* @param int $options
70-
* @param int $depth
69+
* @param int $options
70+
* @param int<1, max> $depth
7171
*
72-
* @return array|string
72+
* @return array<string,mixed>|string
7373
*/
7474
public function getModified(bool $json = false, int $options = 0, int $depth = 512);
7575
}

src/Contracts/AuditDriver.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,11 @@ interface AuditDriver
66
{
77
/**
88
* Perform an audit.
9-
*
10-
* @param \OwenIt\Auditing\Contracts\Auditable $model
11-
*
12-
* @return \OwenIt\Auditing\Contracts\Audit
139
*/
1410
public function audit(Auditable $model): ?Audit;
1511

1612
/**
1713
* Remove older audits that go over the threshold.
18-
*
19-
* @param \OwenIt\Auditing\Contracts\Auditable $model
20-
*
21-
* @return bool
2214
*/
2315
public function prune(Auditable $model): bool;
2416
}

src/Contracts/Auditable.php

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ public function audits(): MorphMany;
1515

1616
/**
1717
* Set the Audit event.
18-
*
19-
* @param string $event
20-
*
21-
* @return Auditable
2218
*/
2319
public function setAuditEvent(string $event): Auditable;
2420

@@ -32,14 +28,12 @@ public function getAuditEvent();
3228
/**
3329
* Get the events that trigger an Audit.
3430
*
35-
* @return array
31+
* @return array<string>
3632
*/
3733
public function getAuditEvents(): array;
3834

3935
/**
4036
* Is the model ready for auditing?
41-
*
42-
* @return bool
4337
*/
4438
public function readyForAuditing(): bool;
4539

@@ -48,35 +42,31 @@ public function readyForAuditing(): bool;
4842
*
4943
* @throws \OwenIt\Auditing\Exceptions\AuditingException
5044
*
51-
* @return array
45+
* @return array<string,mixed>
5246
*/
5347
public function toAudit(): array;
5448

5549
/**
5650
* Get the (Auditable) attributes included in audit.
5751
*
58-
* @return array
52+
* @return array<string>
5953
*/
6054
public function getAuditInclude(): array;
6155

6256
/**
6357
* Get the (Auditable) attributes excluded from audit.
6458
*
65-
* @return array
59+
* @return array<string>
6660
*/
6761
public function getAuditExclude(): array;
6862

6963
/**
7064
* Get the strict audit status.
71-
*
72-
* @return bool
7365
*/
7466
public function getAuditStrict(): bool;
7567

7668
/**
7769
* Get the audit (Auditable) timestamps status.
78-
*
79-
* @return bool
8070
*/
8171
public function getAuditTimestamps(): bool;
8272

@@ -89,43 +79,35 @@ public function getAuditDriver();
8979

9080
/**
9181
* Get the Audit threshold.
92-
*
93-
* @return int
9482
*/
9583
public function getAuditThreshold(): int;
9684

9785
/**
9886
* Get the Attribute modifiers.
9987
*
100-
* @return array
88+
* @return array<string,string>
10189
*/
10290
public function getAttributeModifiers(): array;
10391

10492
/**
10593
* Transform the data before performing an audit.
10694
*
107-
* @param array $data
108-
*
109-
* @return array
95+
* @param array<string,mixed> $data
96+
* @return array<string,mixed>
11097
*/
11198
public function transformAudit(array $data): array;
11299

113100
/**
114101
* Generate an array with the model tags.
115102
*
116-
* @return array
103+
* @return array<string>
117104
*/
118105
public function generateTags(): array;
119106

120107
/**
121108
* Transition to another model state from an Audit.
122109
*
123-
* @param Audit $audit
124-
* @param bool $old
125-
*
126110
* @throws \OwenIt\Auditing\Exceptions\AuditableTransitionException
127-
*
128-
* @return Auditable
129111
*/
130112
public function transitionTo(Audit $audit, bool $old = false): Auditable;
131113
}

src/Events/AuditCustom.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ class AuditCustom
1515

1616
/**
1717
* Create a new Auditing event instance.
18-
*
19-
* @param \OwenIt\Auditing\Contracts\Auditable $model
2018
*/
2119
public function __construct(Auditable $model)
2220
{

src/Events/Audited.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ class Audited
3131

3232
/**
3333
* Create a new Audited event instance.
34-
*
35-
* @param \OwenIt\Auditing\Contracts\Auditable $model
36-
* @param \OwenIt\Auditing\Contracts\AuditDriver $driver
37-
* @param \OwenIt\Auditing\Contracts\Audit|null $audit
3834
*/
3935
public function __construct(Auditable $model, AuditDriver $driver, ?Audit $audit = null)
4036
{

0 commit comments

Comments
 (0)