From 354187dcb1459fb4f2f68f0344d47f0365b3fa18 Mon Sep 17 00:00:00 2001 From: Sasha B Date: Wed, 3 May 2023 23:18:21 +0700 Subject: [PATCH] fix php 8.1 warnings --- .gitignore | 1 + src/Model.php | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 84bf2c8..fc75387 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ build/logs phpunit.phar composer.lock .phpunit.result.cache +.idea diff --git a/src/Model.php b/src/Model.php index cfc73a0..03bc74a 100644 --- a/src/Model.php +++ b/src/Model.php @@ -410,7 +410,7 @@ public function isFillable($key) * @param string $key * @return bool */ - public function isGuarded($key) + public function isGuarded($key): bool { return in_array($key, $this->guarded) || $this->guarded == ['*']; } @@ -420,7 +420,7 @@ public function isGuarded($key) * * @return bool */ - public function totallyGuarded() + public function totallyGuarded(): bool { return count($this->fillable) == 0 && $this->guarded == ['*']; } @@ -431,7 +431,7 @@ public function totallyGuarded() * @param int $options * @return string */ - public function toJson($options = 0) + public function toJson($options = 0): string { return json_encode($this->jsonSerialize(), $options); } @@ -441,7 +441,7 @@ public function toJson($options = 0) * * @return array */ - public function jsonSerialize() + public function jsonSerialize(): array { return $this->toArray(); } @@ -654,7 +654,7 @@ protected function isJsonCastable($key) { $castables = ['array', 'json', 'object', 'collection']; return $this->hasCast($key) && - in_array($this->getCastType($key), $castables, true); + in_array($this->getCastType($key), $castables, true); } /** @@ -863,7 +863,7 @@ public function __set($key, $value) * @param mixed $offset * @return bool */ - public function offsetExists($offset) + public function offsetExists($offset): bool { return isset($this->$offset); } @@ -874,7 +874,7 @@ public function offsetExists($offset) * @param mixed $offset * @return mixed */ - public function offsetGet($offset) + public function offsetGet($offset): mixed { return $this->$offset; } @@ -886,7 +886,7 @@ public function offsetGet($offset) * @param mixed $value * @return void */ - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { $this->$offset = $value; } @@ -897,7 +897,7 @@ public function offsetSet($offset, $value) * @param mixed $offset * @return void */ - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->$offset); } @@ -911,7 +911,7 @@ public function offsetUnset($offset) public function __isset($key) { return (isset($this->attributes[$key]) || isset($this->relations[$key])) || - ($this->hasGetMutator($key) && ! is_null($this->getAttributeValue($key))); + ($this->hasGetMutator($key) && ! is_null($this->getAttributeValue($key))); } /**