diff --git a/composer.json b/composer.json index 6c1688e..c7f686b 100755 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ } ], "require" : { - "php-curl-class/php-curl-class": "^8.3", + "php-curl-class/php-curl-class": "^8.3 || ^9.0", "psr/cache": "^1.0 || ^2.0 || ^3.0" }, "suggest": { diff --git a/src/Model.php b/src/Model.php index 5bd4722..bfb4605 100755 --- a/src/Model.php +++ b/src/Model.php @@ -2,16 +2,16 @@ namespace Cristal\ApiWrapper; -use ArrayAccess; use Closure; +use Exception; +use ArrayAccess; +use JsonSerializable; use Cristal\ApiWrapper\Concerns\HasAttributes; -use Cristal\ApiWrapper\Concerns\HasRelationships; +use Cristal\ApiWrapper\Exceptions\ApiException; use Cristal\ApiWrapper\Concerns\HasGlobalScopes; use Cristal\ApiWrapper\Concerns\HidesAttributes; -use Cristal\ApiWrapper\Exceptions\ApiException; +use Cristal\ApiWrapper\Concerns\HasRelationships; use Cristal\ApiWrapper\Exceptions\MissingApiException; -use Exception; -use JsonSerializable; abstract class Model implements ArrayAccess, JsonSerializable { @@ -184,7 +184,8 @@ public function fill(array $attributes = []) // start_measure('fill-model', 'Création de l\'objet '.static::class); foreach ($attributes as $key => $value) { if (is_array($value) && method_exists($this, $key)) { - $this->setRelation($key, + $this->setRelation( + $key, $this->$key()->getRelationsFromArray($value) ); } else { @@ -318,7 +319,7 @@ public function toArray() * * @return array */ - public function jsonSerialize() + public function jsonSerialize(): mixed { return $this->toArray(); } @@ -330,7 +331,7 @@ public function jsonSerialize() * * @return bool */ - public function offsetExists($offset) + public function offsetExists($offset): bool { return !is_null($this->getAttribute($offset)); } @@ -342,7 +343,7 @@ public function offsetExists($offset) * * @return mixed */ - public function offsetGet($offset) + public function offsetGet($offset): mixed { return $this->getAttribute($offset); } @@ -355,7 +356,7 @@ public function offsetGet($offset) * * @return void */ - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { $this->setAttribute($offset, $value); } @@ -367,7 +368,7 @@ public function offsetSet($offset, $value) * * @return void */ - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->attributes[$offset]); }