@@ -46,9 +46,9 @@ public function getKeys(): array
4646
4747 /**
4848 * Return array of values in the ascending keys order
49- * @returns {Array}
49+ * @return array
5050 */
51- public function getValues ()
51+ public function getValues (): array
5252 {
5353 $ res = [];
5454 $ this ->treeWalk ($ this ->root , function ($ node ) use (&$ res ) {
@@ -59,9 +59,10 @@ public function getValues()
5959
6060 /**
6161 * Returns array of items (<key,value> pairs) in the ascended keys order
62- * @returns {Array}
62+ *
63+ * @return array
6364 */
64- public function getItems ()
65+ public function getItems (): array
6566 {
6667 $ res = [];
6768 $ this ->treeWalk ($ this ->root , function ($ node ) use (&$ res ) {
@@ -144,11 +145,12 @@ public function insert(array $key, $value = null)
144145
145146 /**
146147 * Returns true if item {key,value} exist in the tree
148+ *
147149 * @param key - interval correspondent to keys stored in the tree
148150 * @param value - value object to be checked
149- * @returns {boolean} - true if item {key, value} exist in the tree, false otherwise
151+ * @return bool - true if item {key, value} exist in the tree, false otherwise
150152 */
151- public function exist ($ key , $ value )
153+ public function exist ($ key , $ value ): bool
152154 {
153155 $ searchNode = new Node ($ key , $ value );
154156 return $ this ->treeSearch ($ this ->root , $ searchNode ) ? true : false ;
@@ -158,9 +160,9 @@ public function exist($key, $value)
158160 * Remove entry {key, value} from the tree
159161 * @param key - interval correspondent to keys stored in the tree
160162 * @param value - - value object
161- * @returns {boolean} - true if item {key, value} deleted, false if not found
163+ * @return bool - true if item {key, value} deleted, false if not found
162164 */
163- public function remove ($ key , $ value )
165+ public function remove ($ key , $ value ): bool
164166 {
165167 $ searchNode = new Node ($ key , $ value );
166168 $ deleteNode = $ this ->treeSearch ($ this ->root , $ searchNode );
@@ -175,13 +177,16 @@ public function remove($key, $value)
175177 * Method calls a callback function with two parameters (key, value)
176178 * @param visitor(key,value) - function to be called for each tree item
177179 */
178- function foreach ($ visitor ) {
180+ public function foreach ($ visitor )
181+ {
179182 $ this ->treeWalk ($ this ->root , function ($ node ) {
180183 return $ visitor ($ node ->item ->key , $ node ->item ->value );
181184 });
182185 }
183186
184- /** Value Mapper. Walk through every node and map node value to another value
187+ /**
188+ * Value Mapper. Walk through every node and map node value to another value
189+ *
185190 * @param callback(value, key) - function to be called for each tree item
186191 */
187192 public function map ($ callback )
@@ -320,13 +325,12 @@ public function treeDelete($deleteNode)
320325
321326 $ this ->recalcMax ($ fixNode ); // update max property upward from fix_node to root
322327
323- // COPY DATA !!!
324- // Delete_node becomes cut_node, it means that we cannot hold reference
328+ // deleteNode becomes cutNode, it means that we cannot hold reference
325329 // to node in outer structure and we will have to delete by key, additional search need
326330 if ($ cutNode !== $ deleteNode ) {
327331 $ deleteNode ->copyData ($ cutNode );
328332 $ deleteNode ->updateMax (); // update max property of the cut node at the new place
329- $ this ->recalcMax ($ deleteNode ); // update max property upward from delete_node to root
333+ $ this ->recalcMax ($ deleteNode ); // update max property upward from deleteNode to root
330334 }
331335
332336 if ( /*fix_node !== this.nil_node && */ $ cutNode ->color === Node::COLOR_BLACK ) {
0 commit comments