diff --git a/src/Audit.php b/src/Audit.php index a99d80fa..6f152041 100644 --- a/src/Audit.php +++ b/src/Audit.php @@ -16,21 +16,21 @@ trait Audit /** * Audit data. * - * @var array + * @var array */ protected $data = []; /** * The Audit attributes that belong to the metadata. * - * @var array + * @var array */ protected $metadata = []; /** * The Auditable attributes that were modified. * - * @var array + * @var array */ protected $modified = []; @@ -118,8 +118,6 @@ public function resolveData(): array /** * Get the formatted value of an Eloquent model. * - * @param Model $model - * @param string $key * @param mixed $value * * @return mixed @@ -162,6 +160,11 @@ protected function getFormattedValue(Model $model, string $key, $value) return $value; } + /** + * @param Model $model + * @param mixed $value + * @return mixed + */ private function castDatetimeUTC($model, $value) { if (!is_string($value)) { @@ -216,8 +219,6 @@ public function getDataValue(string $key) /** * Decode attribute value. * - * @param Contracts\Auditable $auditable - * @param string $attribute * @param mixed $value * * @return mixed @@ -291,9 +292,9 @@ public function getModified(bool $json = false, int $options = 0, int $depth = 5 /** * Get the Audit tags as an array. * - * @return array + * @return array|false */ - public function getTags(): array + public function getTags(): array|false { return preg_split('/,/', $this->tags, -1, PREG_SPLIT_NO_EMPTY); } diff --git a/src/AuditableObserver.php b/src/AuditableObserver.php index 42867c14..a43d4df8 100644 --- a/src/AuditableObserver.php +++ b/src/AuditableObserver.php @@ -20,8 +20,6 @@ class AuditableObserver /** * Handle the retrieved event. * - * @param \OwenIt\Auditing\Contracts\Auditable $model - * * @return void */ public function retrieved(Auditable $model) @@ -32,8 +30,6 @@ public function retrieved(Auditable $model) /** * Handle the created event. * - * @param \OwenIt\Auditing\Contracts\Auditable $model - * * @return void */ public function created(Auditable $model) @@ -44,8 +40,6 @@ public function created(Auditable $model) /** * Handle the updated event. * - * @param \OwenIt\Auditing\Contracts\Auditable $model - * * @return void */ public function updated(Auditable $model) @@ -59,8 +53,6 @@ public function updated(Auditable $model) /** * Handle the deleted event. * - * @param \OwenIt\Auditing\Contracts\Auditable $model - * * @return void */ public function deleted(Auditable $model) @@ -71,8 +63,6 @@ public function deleted(Auditable $model) /** * Handle the restoring event. * - * @param \OwenIt\Auditing\Contracts\Auditable $model - * * @return void */ public function restoring(Auditable $model) @@ -86,8 +76,6 @@ public function restoring(Auditable $model) /** * Handle the restored event. * - * @param \OwenIt\Auditing\Contracts\Auditable $model - * * @return void */ public function restored(Auditable $model) @@ -99,7 +87,7 @@ public function restored(Auditable $model) static::$restoring = false; } - protected function dispatchAudit(Auditable $model) + protected function dispatchAudit(Auditable $model): void { if (!$model->readyForAuditing()) { return; @@ -121,10 +109,6 @@ protected function dispatchAudit(Auditable $model) /** * Fire the Auditing event. - * - * @param \OwenIt\Auditing\Contracts\Auditable $model - * - * @return bool */ protected function fireDispatchingAuditEvent(Auditable $model): bool { diff --git a/src/Auditor.php b/src/Auditor.php index 1f85d389..38bf92fd 100644 --- a/src/Auditor.php +++ b/src/Auditor.php @@ -94,8 +94,6 @@ public function execute(Auditable $model): void /** * Create an instance of the Database audit driver. - * - * @return \OwenIt\Auditing\Drivers\Database */ protected function createDatabaseDriver(): Database { @@ -104,11 +102,6 @@ protected function createDatabaseDriver(): Database /** * Fire the Auditing event. - * - * @param \OwenIt\Auditing\Contracts\Auditable $model - * @param \OwenIt\Auditing\Contracts\AuditDriver $driver - * - * @return bool */ protected function fireAuditingEvent(Auditable $model, AuditDriver $driver): bool { diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index 87dac382..763ef122 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -20,7 +20,7 @@ class InstallCommand extends Command /** * {@inheritdoc} */ - public function handle() + public function handle(): void { $this->comment('Publishing Auditing Configuration...'); $this->callSilent('vendor:publish', ['--tag' => 'config']); diff --git a/src/Contracts/AttributeRedactor.php b/src/Contracts/AttributeRedactor.php index 91440bd5..2d87d888 100644 --- a/src/Contracts/AttributeRedactor.php +++ b/src/Contracts/AttributeRedactor.php @@ -8,8 +8,6 @@ interface AttributeRedactor extends AttributeModifier * Redact an attribute value. * * @param mixed $value - * - * @return string */ public static function redact($value): string; } diff --git a/src/Contracts/Audit.php b/src/Contracts/Audit.php index 5b3e911e..7c909586 100644 --- a/src/Contracts/Audit.php +++ b/src/Contracts/Audit.php @@ -38,7 +38,7 @@ public function user(); /** * Audit data resolver. * - * @return array + * @return array */ public function resolveData(): array; @@ -55,10 +55,10 @@ public function getDataValue(string $key); * Get the Audit metadata. * * @param bool $json - * @param int $options - * @param int $depth + * @param int $options + * @param int<1, max> $depth * - * @return array|string + * @return array|string */ public function getMetadata(bool $json = false, int $options = 0, int $depth = 512); @@ -66,10 +66,10 @@ public function getMetadata(bool $json = false, int $options = 0, int $depth = 5 * Get the Auditable modified attributes. * * @param bool $json - * @param int $options - * @param int $depth + * @param int $options + * @param int<1, max> $depth * - * @return array|string + * @return array|string */ public function getModified(bool $json = false, int $options = 0, int $depth = 512); } diff --git a/src/Contracts/AuditDriver.php b/src/Contracts/AuditDriver.php index 01477652..96338878 100644 --- a/src/Contracts/AuditDriver.php +++ b/src/Contracts/AuditDriver.php @@ -6,19 +6,11 @@ interface AuditDriver { /** * Perform an audit. - * - * @param \OwenIt\Auditing\Contracts\Auditable $model - * - * @return \OwenIt\Auditing\Contracts\Audit */ public function audit(Auditable $model): ?Audit; /** * Remove older audits that go over the threshold. - * - * @param \OwenIt\Auditing\Contracts\Auditable $model - * - * @return bool */ public function prune(Auditable $model): bool; } diff --git a/src/Contracts/Auditable.php b/src/Contracts/Auditable.php index 83d725ed..fd1ddd60 100644 --- a/src/Contracts/Auditable.php +++ b/src/Contracts/Auditable.php @@ -15,10 +15,6 @@ public function audits(): MorphMany; /** * Set the Audit event. - * - * @param string $event - * - * @return Auditable */ public function setAuditEvent(string $event): Auditable; @@ -32,14 +28,12 @@ public function getAuditEvent(); /** * Get the events that trigger an Audit. * - * @return array + * @return array */ public function getAuditEvents(): array; /** * Is the model ready for auditing? - * - * @return bool */ public function readyForAuditing(): bool; @@ -48,35 +42,31 @@ public function readyForAuditing(): bool; * * @throws \OwenIt\Auditing\Exceptions\AuditingException * - * @return array + * @return array */ public function toAudit(): array; /** * Get the (Auditable) attributes included in audit. * - * @return array + * @return array */ public function getAuditInclude(): array; /** * Get the (Auditable) attributes excluded from audit. * - * @return array + * @return array */ public function getAuditExclude(): array; /** * Get the strict audit status. - * - * @return bool */ public function getAuditStrict(): bool; /** * Get the audit (Auditable) timestamps status. - * - * @return bool */ public function getAuditTimestamps(): bool; @@ -89,43 +79,35 @@ public function getAuditDriver(); /** * Get the Audit threshold. - * - * @return int */ public function getAuditThreshold(): int; /** * Get the Attribute modifiers. * - * @return array + * @return array */ public function getAttributeModifiers(): array; /** * Transform the data before performing an audit. * - * @param array $data - * - * @return array + * @param array $data + * @return array */ public function transformAudit(array $data): array; /** * Generate an array with the model tags. * - * @return array + * @return array */ public function generateTags(): array; /** * Transition to another model state from an Audit. * - * @param Audit $audit - * @param bool $old - * * @throws \OwenIt\Auditing\Exceptions\AuditableTransitionException - * - * @return Auditable */ public function transitionTo(Audit $audit, bool $old = false): Auditable; } diff --git a/src/Events/AuditCustom.php b/src/Events/AuditCustom.php index 379abbba..6ef6d780 100644 --- a/src/Events/AuditCustom.php +++ b/src/Events/AuditCustom.php @@ -15,8 +15,6 @@ class AuditCustom /** * Create a new Auditing event instance. - * - * @param \OwenIt\Auditing\Contracts\Auditable $model */ public function __construct(Auditable $model) { diff --git a/src/Events/Audited.php b/src/Events/Audited.php index ad527c71..aaba043e 100644 --- a/src/Events/Audited.php +++ b/src/Events/Audited.php @@ -31,10 +31,6 @@ class Audited /** * Create a new Audited event instance. - * - * @param \OwenIt\Auditing\Contracts\Auditable $model - * @param \OwenIt\Auditing\Contracts\AuditDriver $driver - * @param \OwenIt\Auditing\Contracts\Audit|null $audit */ public function __construct(Auditable $model, AuditDriver $driver, ?Audit $audit = null) { diff --git a/src/Events/Auditing.php b/src/Events/Auditing.php index 47aaea1a..e1a7da01 100644 --- a/src/Events/Auditing.php +++ b/src/Events/Auditing.php @@ -23,9 +23,6 @@ class Auditing /** * Create a new Auditing event instance. - * - * @param \OwenIt\Auditing\Contracts\Auditable $model - * @param \OwenIt\Auditing\Contracts\AuditDriver $driver */ public function __construct(Auditable $model, AuditDriver $driver) { diff --git a/src/Events/DispatchAudit.php b/src/Events/DispatchAudit.php index 3acfd144..3c963673 100644 --- a/src/Events/DispatchAudit.php +++ b/src/Events/DispatchAudit.php @@ -27,7 +27,7 @@ public function __construct(Auditable $model) /** * Prepare the instance values for serialization. * - * @return array + * @return array */ public function __serialize() { @@ -84,8 +84,10 @@ public function __unserialize(array $values) /** * Set the property value for the given property. + * + * @param mixed $value */ - protected function setModelPropertyValue(ReflectionClass $reflection, string $name, $value) + protected function setModelPropertyValue(ReflectionClass $reflection, string $name, $value): void { $property = $reflection->getProperty($name); diff --git a/src/Events/DispatchingAudit.php b/src/Events/DispatchingAudit.php index 837b14e0..ecfe754d 100644 --- a/src/Events/DispatchingAudit.php +++ b/src/Events/DispatchingAudit.php @@ -15,8 +15,6 @@ class DispatchingAudit /** * Create a new DispatchingAudit event instance. - * - * @param Auditable $model */ public function __construct(Auditable $model) { diff --git a/src/Exceptions/AuditableTransitionException.php b/src/Exceptions/AuditableTransitionException.php index bfadf980..e29a22ed 100644 --- a/src/Exceptions/AuditableTransitionException.php +++ b/src/Exceptions/AuditableTransitionException.php @@ -9,14 +9,14 @@ class AuditableTransitionException extends AuditingException /** * Attribute incompatibilities. * - * @var array + * @var array */ protected $incompatibilities = []; /** - * {@inheritdoc} + * @param array $incompatibilities */ - public function __construct($message = '', array $incompatibilities = [], $code = 0, ?Throwable $previous = null) + public function __construct(string $message = '', array $incompatibilities = [], int $code = 0, ?Throwable $previous = null) { parent::__construct($message, $code, $previous); @@ -26,7 +26,7 @@ public function __construct($message = '', array $incompatibilities = [], $code /** * Get the attribute incompatibilities. * - * @return array + * @return array */ public function getIncompatibilities(): array { diff --git a/src/Listeners/ProcessDispatchAudit.php b/src/Listeners/ProcessDispatchAudit.php index ed370a62..ad3a174d 100644 --- a/src/Listeners/ProcessDispatchAudit.php +++ b/src/Listeners/ProcessDispatchAudit.php @@ -24,7 +24,7 @@ public function withDelay(DispatchAudit $event): int return Config::get('audit.queue.delay', 0); } - public function handle(DispatchAudit $event) + public function handle(DispatchAudit $event): void { Auditor::execute($event->model); } diff --git a/src/Listeners/RecordCustomAudit.php b/src/Listeners/RecordCustomAudit.php index b845ed50..d5290b07 100644 --- a/src/Listeners/RecordCustomAudit.php +++ b/src/Listeners/RecordCustomAudit.php @@ -6,7 +6,7 @@ class RecordCustomAudit { - public function handle(\OwenIt\Auditing\Contracts\Auditable $model) + public function handle(\OwenIt\Auditing\Contracts\Auditable $model): void { Auditor::execute($model); } diff --git a/src/Models/Audit.php b/src/Models/Audit.php index 187b01b9..521cea27 100644 --- a/src/Models/Audit.php +++ b/src/Models/Audit.php @@ -37,7 +37,7 @@ class Audit extends Model implements \OwenIt\Auditing\Contracts\Audit // Note: Please do not add 'auditable_id' in here, as it will break non-integer PK models ]; - public function getSerializedDate($date) + public function getSerializedDate(\DateTimeInterface $date): string { return $this->serializeDate($date); } diff --git a/src/Resolvers/UrlResolver.php b/src/Resolvers/UrlResolver.php index 841d1774..93226f1a 100644 --- a/src/Resolvers/UrlResolver.php +++ b/src/Resolvers/UrlResolver.php @@ -8,9 +8,6 @@ class UrlResolver implements \OwenIt\Auditing\Contracts\Resolver { - /** - * @return string - */ public static function resolve(Auditable $auditable): string { if (! empty($auditable->preloadedResolverData['url'] ?? null)) { diff --git a/src/Resolvers/UserAgentResolver.php b/src/Resolvers/UserAgentResolver.php index 2847b214..3a0b93f5 100644 --- a/src/Resolvers/UserAgentResolver.php +++ b/src/Resolvers/UserAgentResolver.php @@ -8,7 +8,7 @@ class UserAgentResolver implements Resolver { - public static function resolve(Auditable $auditable) + public static function resolve(Auditable $auditable): string { return $auditable->preloadedResolverData['user_agent'] ?? Request::header('User-Agent'); }