From 991ae41fa5428b045cc20f741cbd2704f2e7287b Mon Sep 17 00:00:00 2001 From: Antonio Carlos Ribeiro Date: Sat, 17 Aug 2024 00:24:26 +0200 Subject: [PATCH] Fix all PHPStan level MAX errors --- phpstan.neon | 8 ++++---- src/Services/EdgeFlush.php | 2 +- src/Services/Entity.php | 12 ++++++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 02e8ef1..915fb74 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -10,15 +10,15 @@ parameters: # The level 8 is the highest level level: max - checkMissingIterableValueType: false - - checkGenericClassInNonGenericObjectType: false - reportUnmatchedIgnoredErrors: false ignoreErrors: - '#Internal.*#' - '#Cannot access offset .* on array\{scheme.*#' + - + identifier: missingType.iterableValue + - + identifier: missingType.generics strictRules: disallowedLooseComparison: true diff --git a/src/Services/EdgeFlush.php b/src/Services/EdgeFlush.php index 7dbca20..aae6173 100644 --- a/src/Services/EdgeFlush.php +++ b/src/Services/EdgeFlush.php @@ -108,7 +108,7 @@ public function packageName(): string return Helpers::configString('edge-flush.package.name') ?? 'edge-flush'; } - public function boot() + public function boot(): void { $this->tags->boot(); diff --git a/src/Services/Entity.php b/src/Services/Entity.php index 8493d44..22aa37a 100644 --- a/src/Services/Entity.php +++ b/src/Services/Entity.php @@ -35,15 +35,19 @@ public function __construct(Model $model, string|null $event = null) $this->makeEvent($model, $event); } - public function absorb(Model $model) + public function absorb(Model $model): void { $model = EdgeFlushFacade::getInternalModel($model); - $this->modelClass = get_class($model); + if (is_string($class = get_class($model))) { + $this->modelClass = $class; + } $this->id = $model->getKey(); - $this->modelName = $this->makeModelName($model); + if (is_string($name = $this->makeModelName($model))) { + $this->modelName = $name; + } $this->attributes = $this->absorbAttributes($model->getAttributes()); @@ -193,7 +197,7 @@ public function setRelation(array $relation): void public function isRelationDirty(string|null $key): bool { - if (empty($key)) { + if (blank($key)) { return false; }