From aa77d4057708e741ee3884df2ec7f94a53e99ebe Mon Sep 17 00:00:00 2001 From: erikn69 Date: Wed, 23 Aug 2023 09:16:16 -0500 Subject: [PATCH] PhpStan fixes --- src/Audit.php | 2 +- src/Console/InstallCommand.php | 3 +-- src/Contracts/Audit.php | 3 +++ src/Contracts/Auditable.php | 2 +- src/Events/AuditCustom.php | 2 -- src/Models/Audit.php | 8 ++++++++ 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Audit.php b/src/Audit.php index 00de95d0..ebbdc71b 100644 --- a/src/Audit.php +++ b/src/Audit.php @@ -289,6 +289,6 @@ public function getModified(bool $json = false, int $options = 0, int $depth = 5 */ public function getTags(): array { - return preg_split('/,/', $this->tags, null, PREG_SPLIT_NO_EMPTY); + return preg_split('/,/', $this->tags, -1, PREG_SPLIT_NO_EMPTY); } } diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index a8caa124..87dac382 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -3,7 +3,6 @@ namespace OwenIt\Auditing\Console; use Illuminate\Console\Command; -use Illuminate\Container\Container; use Illuminate\Support\Str; class InstallCommand extends Command @@ -41,7 +40,7 @@ public function handle() */ protected function registerAuditingServiceProvider() { - $namespace = Str::replaceLast('\\', '', Container::getInstance()->getNamespace()); + $namespace = Str::replaceLast('\\', '', app()->getNamespace()); $appConfig = file_get_contents(config_path('app.php')); diff --git a/src/Contracts/Audit.php b/src/Contracts/Audit.php index 10cb95aa..5b3e911e 100644 --- a/src/Contracts/Audit.php +++ b/src/Contracts/Audit.php @@ -2,6 +2,9 @@ namespace OwenIt\Auditing\Contracts; +/** + * @mixin \OwenIt\Auditing\Models\Audit + */ interface Audit { /** diff --git a/src/Contracts/Auditable.php b/src/Contracts/Auditable.php index e19371e6..83d725ed 100644 --- a/src/Contracts/Auditable.php +++ b/src/Contracts/Auditable.php @@ -9,7 +9,7 @@ interface Auditable /** * Auditable Model audits. * - * @return \Illuminate\Database\Eloquent\Relations\MorphMany + * @return MorphMany<\OwenIt\Auditing\Models\Audit> */ public function audits(): MorphMany; diff --git a/src/Events/AuditCustom.php b/src/Events/AuditCustom.php index 4b15fa0c..379abbba 100644 --- a/src/Events/AuditCustom.php +++ b/src/Events/AuditCustom.php @@ -17,8 +17,6 @@ class AuditCustom * Create a new Auditing event instance. * * @param \OwenIt\Auditing\Contracts\Auditable $model - * @param array $old - * @param array $new */ public function __construct(Auditable $model) { diff --git a/src/Models/Audit.php b/src/Models/Audit.php index 570ba68e..62ac6cd3 100644 --- a/src/Models/Audit.php +++ b/src/Models/Audit.php @@ -4,6 +4,14 @@ use Illuminate\Database\Eloquent\Model; +/** + * @property string $tags + * @property string $event + * @property array $new_values + * @property array $old_values + * @property mixed $user + * @property mixed $auditable. + */ class Audit extends Model implements \OwenIt\Auditing\Contracts\Audit { use \OwenIt\Auditing\Audit;