1 | <?php |
||
27 | class HashMap extends AbstractMap |
||
28 | { |
||
29 | /** |
||
30 | * @var HashProducerInterface |
||
31 | */ |
||
32 | protected static $defaultHashProducer; |
||
33 | |||
34 | 38 | protected static function getHashProducer() : HashProducerInterface |
|
35 | { |
||
36 | 38 | if (!static::$defaultHashProducer) |
|
37 | { |
||
38 | 1 | static::$defaultHashProducer = new HashProducer(); |
|
39 | } |
||
40 | |||
41 | 38 | return static::$defaultHashProducer; |
|
42 | } |
||
43 | |||
44 | public static function setDefaultHashProducer |
||
52 | |||
53 | /** |
||
54 | * @var Pair<KeyType, ValueType>[] |
||
55 | */ |
||
56 | protected $data = []; |
||
57 | |||
58 | /** |
||
59 | * @var HashProducerInterface |
||
60 | */ |
||
61 | protected $hashProducer; |
||
62 | |||
63 | 38 | public function __construct |
|
71 | |||
72 | /** |
||
73 | * {@inheritDoc} |
||
74 | */ |
||
75 | 10 | public function getIterator() |
|
79 | |||
80 | /** |
||
81 | * {@inheritDoc} |
||
82 | */ |
||
83 | 38 | public function containsKey($key) : bool |
|
84 | { |
||
85 | 38 | return isset($this->data[$this->hashProducer->getHash($key)]); |
|
86 | } |
||
87 | |||
88 | /** |
||
89 | * {@inheritDoc} |
||
90 | */ |
||
91 | 42 | public function getPair($key) : Pair |
|
92 | { |
||
93 | 42 | return $this->data[$this->hashProducer->getHash($key)]; |
|
94 | } |
||
95 | |||
96 | /** |
||
97 | * {@inheritDoc} |
||
98 | */ |
||
99 | 35 | public function insert(Pair $pair) |
|
100 | { |
||
101 | 35 | $this->data[$this->hashProducer->getHash($pair->key)] = $pair; |
|
|
|||
102 | 35 | } |
|
103 | |||
104 | /** |
||
105 | * {@inheritDoc} |
||
106 | */ |
||
107 | 2 | public function remove($key) |
|
108 | { |
||
109 | 2 | unset($this->data[$this->hashProducer->getHash($key)]); |
|
110 | 2 | } |
|
111 | |||
112 | /** |
||
113 | * {@inheritDoc} |
||
114 | */ |
||
115 | 8 | public function size() : int |
|
119 | } |
||
120 |
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.