diff --git a/src/Micrometa/Application/Item/PropertyList.php b/src/Micrometa/Application/Item/PropertyList.php index acb7fdc..addc173 100755 --- a/src/Micrometa/Application/Item/PropertyList.php +++ b/src/Micrometa/Application/Item/PropertyList.php @@ -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); @@ -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) { diff --git a/src/Micrometa/Domain/Item/Item.php b/src/Micrometa/Domain/Item/Item.php index 97949c7..b2b5b04 100755 --- a/src/Micrometa/Domain/Item/Item.php +++ b/src/Micrometa/Domain/Item/Item.php @@ -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 ); } diff --git a/src/Micrometa/Domain/Item/PropertyList.php b/src/Micrometa/Domain/Item/PropertyList.php index cf9b591..71fd6de 100755 --- a/src/Micrometa/Domain/Item/PropertyList.php +++ b/src/Micrometa/Domain/Item/PropertyList.php @@ -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), @@ -94,7 +94,7 @@ public function offsetUnset($iri) * * @return int Number of properties */ - public function count() + public function count(): int { return count($this->values); } @@ -104,7 +104,7 @@ public function count() * * @return array Property values */ - public function current() + public function current(): array { return $this->values[$this->cursor]; } @@ -112,7 +112,7 @@ public function current() /** * Move forward to next element */ - public function next() + public function next(): void { ++$this->cursor; } @@ -120,7 +120,7 @@ public function next() /** * Return the current IRI key * - * @return \stdClass IRI key + * @return mixed IRI key */ public function key() { @@ -132,7 +132,7 @@ public function key() * * @return boolean The current position is valid */ - public function valid() + public function valid(): bool { return isset($this->values[$this->cursor]); } @@ -140,7 +140,7 @@ public function valid() /** * Rewind the Iterator to the first element */ - public function rewind() + public function rewind(): void { $this->cursor = 0; } @@ -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 { @@ -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); @@ -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 !== '') ? diff --git a/src/Micrometa/Domain/Item/PropertyListInterface.php b/src/Micrometa/Domain/Item/PropertyListInterface.php index 43091a2..348e8a5 100755 --- a/src/Micrometa/Domain/Item/PropertyListInterface.php +++ b/src/Micrometa/Domain/Item/PropertyListInterface.php @@ -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 @@ -60,7 +60,7 @@ public function offsetExists($iri); * * @return array Property values */ - public function &offsetGet($iri); + public function &offsetGet($iri): array; /** * Set a particular property @@ -68,14 +68,14 @@ public function &offsetGet($iri); * @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 diff --git a/src/Micrometa/Ports/Item/Item.php b/src/Micrometa/Ports/Item/Item.php index 89ee4fb..1e584f5 100755 --- a/src/Micrometa/Ports/Item/Item.php +++ b/src/Micrometa/Ports/Item/Item.php @@ -363,7 +363,7 @@ public function getFirstItem(...$types) * * @return int */ - public function count() + public function count(): int { return $this->itemList->count(); } diff --git a/src/Micrometa/Ports/Item/ItemList.php b/src/Micrometa/Ports/Item/ItemList.php index 5acfbfb..d42c889 100755 --- a/src/Micrometa/Ports/Item/ItemList.php +++ b/src/Micrometa/Ports/Item/ItemList.php @@ -91,7 +91,7 @@ public function current() * @return void * @api */ - public function next() + public function next(): void { ++$this->pointer; } @@ -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; } @@ -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]); } @@ -124,7 +124,7 @@ public function valid() * @return void * @api */ - public function rewind() + public function rewind(): void { $this->pointer = 0; } @@ -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]); } @@ -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); } @@ -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); } @@ -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); }