Skip to content

Commit

Permalink
Merge pull request #93 from spatie/php81
Browse files Browse the repository at this point in the history
add typehinting
  • Loading branch information
Nielsvanpach authored Dec 6, 2021
2 parents 3243e52 + d5f7d9a commit c37289c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
25 changes: 13 additions & 12 deletions src/SchemalessAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Illuminate\Support\Collection;
use IteratorAggregate;
use JsonSerializable;
use Traversable;

/**
* @mixin Collection
Expand Down Expand Up @@ -52,19 +53,19 @@ public function __get($name)
return $this->get($name);
}

public function __set($name, $value)
public function __set($name, $value): void
{
$this->set($name, $value);
}

public function __isset($name)
public function __isset($name): bool
{
$property = $this->get($name);

return isset($property);
}

public function __empty($name)
public function __empty($name): bool
{
$property = $this->get($name);

Expand Down Expand Up @@ -128,47 +129,47 @@ public function modelScope(): Builder
return $builder;
}

public function offsetGet($offset)
public function offsetGet($offset): mixed
{
return $this->get($offset);
}

public function offsetExists($offset)
public function offsetExists($offset): bool
{
return $this->collection->offsetExists($offset);
}

public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
$this->set($offset, $value);
}

public function offsetUnset($offset)
public function offsetUnset($offset): void
{
$this->forget($offset);
}

public function toArray()
public function toArray(): array
{
return $this->collection->toArray();
}

public function toJson($options = 0)
public function toJson($options = 0): string
{
return $this->collection->toJson($options);
}

public function jsonSerialize()
public function jsonSerialize(): mixed
{
return $this->collection->jsonSerialize();
}

public function count()
public function count(): int
{
return $this->collection->count();
}

public function getIterator()
public function getIterator(): Traversable
{
return $this->collection->getIterator();
}
Expand Down
2 changes: 1 addition & 1 deletion src/SchemalessAttributesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function configurePackage(Package $package): void
->name('laravel-schemaless-attributes');
}

public function registeringPackage()
public function registeringPackage(): void
{
Blueprint::macro('schemalessAttributes', function (string $columnName = 'schemaless_attributes') {
return $this->json($columnName)->nullable();
Expand Down

0 comments on commit c37289c

Please sign in to comment.