1 | <?php |
||
24 | class HashMap extends AbstractMap |
||
25 | { |
||
26 | /** |
||
27 | * @var Pair<KeyType, ValueType>[] |
||
28 | */ |
||
29 | protected $data = []; |
||
30 | |||
31 | /** |
||
32 | * {@inheritDoc} |
||
33 | */ |
||
34 | 3 | public function getIterator() |
|
38 | |||
39 | /** |
||
40 | * {@inheritDoc} |
||
41 | */ |
||
42 | 31 | public function containsKey($key) : bool |
|
46 | |||
47 | /** |
||
48 | * {@inheritDoc} |
||
49 | */ |
||
50 | 33 | public function get($key) |
|
54 | |||
55 | /** |
||
56 | * {@inheritDoc} |
||
57 | */ |
||
58 | 26 | public function insert(Pair $pair) |
|
62 | |||
63 | /** |
||
64 | * {@inheritDoc} |
||
65 | */ |
||
66 | 1 | public function remove($key) |
|
67 | { |
||
68 | 1 | unset($this->data[$this->getScalar($key)]); |
|
69 | 1 | } |
|
70 | |||
71 | /** |
||
72 | * {@inheritDoc} |
||
73 | */ |
||
74 | 7 | public function size() : int |
|
78 | |||
79 | /** |
||
80 | * Returns a good scalar value to use for a native PHP array |
||
81 | * |
||
82 | * @param KeyType $value The key to convert to a scalar |
||
83 | * @return string Scalar value |
||
84 | */ |
||
85 | 39 | private function getScalar($value) |
|
97 | } |
||
98 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.