Hinting up Entity API to PHP 7.2 standards

This commit is contained in:
Dylan K. Taylor
2018-05-19 10:46:47 +01:00
parent 389990e0a8
commit 0bb5e88b5c
17 changed files with 181 additions and 171 deletions

View File

@@ -27,7 +27,7 @@ class AttributeMap implements \ArrayAccess{
/** @var Attribute[] */
private $attributes = [];
public function addAttribute(Attribute $attribute){
public function addAttribute(Attribute $attribute) : void{
$this->attributes[$attribute->getId()] = $attribute;
}
@@ -36,7 +36,7 @@ class AttributeMap implements \ArrayAccess{
*
* @return Attribute|null
*/
public function getAttribute(int $id){
public function getAttribute(int $id) : ?Attribute{
return $this->attributes[$id] ?? null;
}
@@ -56,19 +56,28 @@ class AttributeMap implements \ArrayAccess{
});
}
public function offsetExists($offset){
public function offsetExists($offset) : bool{
return isset($this->attributes[$offset]);
}
public function offsetGet($offset){
/**
* @param int $offset
*
* @return float
*/
public function offsetGet($offset) : float{
return $this->attributes[$offset]->getValue();
}
public function offsetSet($offset, $value){
/**
* @param int $offset
* @param float $value
*/
public function offsetSet($offset, $value) : void{
$this->attributes[$offset]->setValue($value);
}
public function offsetUnset($offset){
public function offsetUnset($offset) : void{
throw new \RuntimeException("Could not unset an attribute from an attribute map");
}
}