| @@ -9,13 +9,15 @@ | ||
| 9 | 9 | |
| 10 | 10 | use Packetery\Nette; |
| 11 | 11 | /** |
| 12 | 12 | * Provides objects to work as array. |
| 13 | + * @template T | |
| 13 | 14 | */ |
| 14 | 15 | class ArrayHash extends \stdClass implements \ArrayAccess, \Countable, \IteratorAggregate |
| 15 | 16 | { |
| 16 | 17 | /** |
| 17 | 18 | * Transforms array to ArrayHash. |
| 19 | + * @param array<T> $array | |
| 18 | 20 | * @return static |
| 19 | 21 | */ |
| 20 | 22 | public static function from(array $array, bool $recursive = \true) |
| 21 | 23 | { |
| @@ -26,8 +28,9 @@ | ||
| 26 | 28 | return $obj; |
| 27 | 29 | } |
| 28 | 30 | /** |
| 29 | 31 | * Returns an iterator over all items. |
| 32 | + * @return \RecursiveArrayIterator<array-key, T> | |
| 30 | 33 | */ |
| 31 | 34 | public function getIterator() : \RecursiveArrayIterator |
| 32 | 35 | { |
| 33 | 36 | return new \RecursiveArrayIterator((array) $this); |
| @@ -41,9 +44,9 @@ | ||
| 41 | 44 | } |
| 42 | 45 | /** |
| 43 | 46 | * Replaces or appends a item. |
| 44 | 47 | * @param string|int $key |
| 45 | - * @param mixed $value | |
| 48 | + * @param T $value | |
| 46 | 49 | */ |
| 47 | 50 | public function offsetSet($key, $value) : void |
| 48 | 51 | { |
| 49 | 52 | if (!\is_scalar($key)) { |
| @@ -54,10 +57,11 @@ | ||
| 54 | 57 | } |
| 55 | 58 | /** |
| 56 | 59 | * Returns a item. |
| 57 | 60 | * @param string|int $key |
| 58 | - * @return mixed | |
| 61 | + * @return T | |
| 59 | 62 | */ |
| 63 | + #[\ReturnTypeWillChange] | |
| 60 | 64 | public function offsetGet($key) |
| 61 | 65 | { |
| 62 | 66 | return $this->{$key}; |
| 63 | 67 | } |