Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some php81 deprecations #73

Merged
merged 3 commits into from Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Micrometa/Application/Item/PropertyList.php
Expand Up @@ -77,7 +77,7 @@ public function __construct(AliasFactoryInterface $aliasFactory)
* @param \stdClass|string $iri IRI
* @param array $value Property values
*/
public function offsetSet($iri, $value)
public function offsetSet($iri, $value): void
{
$iri = IriFactory::create($iri);
$iriStr = strval($iri);
Expand Down Expand Up @@ -124,7 +124,7 @@ function (ExportableInterface $value) {
*
* @return int Property cursor
*/
protected function getPropertyCursor($name)
protected function getPropertyCursor($name): int
{
// Run through all property names
foreach ($this->names as $cursor => $iri) {
Expand Down
4 changes: 2 additions & 2 deletions src/Micrometa/Domain/Item/Item.php
Expand Up @@ -73,8 +73,8 @@ public function __construct(
$propertyListFactory ?: new PropertyListFactory(),
is_array($type) ? $type : [$type],
$properties,
trim($itemId),
trim($itemLanguage)
$itemId ? trim($itemId) : null,
$itemLanguage ? trim($itemLanguage) : null
);
}

Expand Down
20 changes: 10 additions & 10 deletions src/Micrometa/Domain/Item/PropertyList.php
Expand Up @@ -80,7 +80,7 @@ class PropertyList implements PropertyListInterface
*
* @throws ErrorException
*/
public function offsetUnset($iri)
public function offsetUnset($iri): void
{
throw new ErrorException(
sprintf(ErrorException::CANNOT_UNSET_PROPERTY_STR, $iri),
Expand All @@ -94,7 +94,7 @@ public function offsetUnset($iri)
*
* @return int Number of properties
*/
public function count()
public function count(): int
{
return count($this->values);
}
Expand All @@ -104,23 +104,23 @@ public function count()
*
* @return array Property values
*/
public function current()
public function current(): array
{
return $this->values[$this->cursor];
}

/**
* Move forward to next element
*/
public function next()
public function next(): void
{
++$this->cursor;
}

/**
* Return the current IRI key
*
* @return \stdClass IRI key
* @return mixed IRI key
*/
public function key()
{
Expand All @@ -132,15 +132,15 @@ public function key()
*
* @return boolean The current position is valid
*/
public function valid()
public function valid(): bool
{
return isset($this->values[$this->cursor]);
}

/**
* Rewind the Iterator to the first element
*/
public function rewind()
public function rewind(): void
{
$this->cursor = 0;
}
Expand Down Expand Up @@ -173,7 +173,7 @@ public function add($property)
*
* @return boolean Property exists
*/
public function offsetExists($iri)
public function offsetExists($iri): bool
{
$iri = IriFactory::create($iri);
try {
Expand Down Expand Up @@ -246,7 +246,7 @@ protected function getPropertyCursor($name)
* @param \stdClass|Iri|string $iri IRI
* @param array $value Property values
*/
public function offsetSet($iri, $value)
public function offsetSet($iri, $value): void
{
$iri = IriFactory::create($iri);
$iriStr = strval($iri);
Expand All @@ -264,7 +264,7 @@ public function offsetSet($iri, $value)
* @return array Property values
* @throws OutOfBoundsException If the property name is unknown
*/
public function &offsetGet($iri)
public function &offsetGet($iri): array
{
$iri = IriFactory::create($iri);
$cursor = ($iri->profile !== '') ?
Expand Down
8 changes: 4 additions & 4 deletions src/Micrometa/Domain/Item/PropertyListInterface.php
Expand Up @@ -51,7 +51,7 @@ interface PropertyListInterface extends \ArrayAccess, \Iterator, \Countable
*
* @return boolean Property exists
*/
public function offsetExists($iri);
public function offsetExists($iri): bool;

/**
* Get a particular property
Expand All @@ -60,22 +60,22 @@ public function offsetExists($iri);
*
* @return array Property values
*/
public function &offsetGet($iri);
public function &offsetGet($iri): array;

/**
* Set a particular property
*
* @param \stdClass|string $iri IRI
* @param array $value Property values
*/
public function offsetSet($iri, $value);
public function offsetSet($iri, $value): void;

/**
* Unset a property
*
* @param \stdClass|string $iri IRI
*/
public function offsetUnset($iri);
public function offsetUnset($iri): void;

/**
* Add a property
Expand Down
2 changes: 1 addition & 1 deletion src/Micrometa/Ports/Item/Item.php
Expand Up @@ -363,7 +363,7 @@ public function getFirstItem(...$types)
*
* @return int
*/
public function count()
public function count(): int
{
return $this->itemList->count();
}
Expand Down
16 changes: 8 additions & 8 deletions src/Micrometa/Ports/Item/ItemList.php
Expand Up @@ -91,7 +91,7 @@ public function current()
* @return void
* @api
*/
public function next()
public function next(): void
{
++$this->pointer;
}
Expand All @@ -102,7 +102,7 @@ public function next()
* @return int Position of the current element
* @api
*/
public function key()
public function key(): int
{
return $this->pointer;
}
Expand All @@ -113,7 +113,7 @@ public function key()
* @return boolean The current position is valid
* @api
*/
public function valid()
public function valid(): bool
{
return isset($this->items[$this->pointer]);
}
Expand All @@ -124,7 +124,7 @@ public function valid()
* @return void
* @api
*/
public function rewind()
public function rewind(): void
{
$this->pointer = 0;
}
Expand All @@ -137,7 +137,7 @@ public function rewind()
* @return boolean Offset exists
* @api
*/
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return isset($this->items[$offset]);
}
Expand All @@ -164,7 +164,7 @@ public function offsetGet($offset)
*
* @api
*/
public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
throw new RuntimeException(RuntimeException::IMMUTABLE_ITEM_LIST_STR, RuntimeException::IMMUTABLE_ITEM_LIST);
}
Expand All @@ -175,7 +175,7 @@ public function offsetSet($offset, $value)
* @param int $offset Offset
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function offsetUnset($offset)
public function offsetUnset($offset): void
{
throw new RuntimeException(RuntimeException::IMMUTABLE_ITEM_LIST_STR, RuntimeException::IMMUTABLE_ITEM_LIST);
}
Expand Down Expand Up @@ -250,7 +250,7 @@ function (ItemInterface $item) use ($types) {
* @return int Number of items
* @api
*/
public function count()
public function count(): int
{
return count($this->items);
}
Expand Down