Skip to content

Commit 3e2ad09

Browse files
authored
Merge pull request #12 from CrimsonNynja/minor-update
changed callable syntax to php 7
2 parents d84251e + 753d815 commit 3e2ad09

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/PhpTrees/BinaryHeap.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private function bubbleUp(int $index) : void
182182
$parentIndex = (int)($index - 1) / 2;
183183

184184
if ($this->comparator !== null) {
185-
if ($this->comparator->__invoke($this->heap[$parentIndex], $this->heap[$index])) {
185+
if (($this->comparator)($this->heap[$parentIndex], $this->heap[$index])) {
186186
$dummy = $this->heap[$parentIndex];
187187
$this->heap[$parentIndex] = $this->heap[$index];
188188
$this->heap[$index] = $dummy;
@@ -218,7 +218,7 @@ private function bubbleDown(int $index) : void
218218
$minIndex = $index;
219219

220220
if ($this->comparator !== null) {
221-
if ($this->comparator->__invoke($this->heap[$index], $this->heap[$leftIndex])) {
221+
if (($this->comparator)($this->heap[$index], $this->heap[$leftIndex])) {
222222
$minIndex = $leftIndex;
223223
}
224224
}
@@ -230,7 +230,7 @@ private function bubbleDown(int $index) : void
230230

231231
if (($rightIndex < $length)) {
232232
if ($this->comparator !== null) {
233-
if ($this->comparator->__invoke($this->heap[$minIndex], $this->heap[$rightIndex])) {
233+
if (($this->comparator)($this->heap[$minIndex], $this->heap[$rightIndex])) {
234234
$minIndex = $rightIndex;
235235
}
236236
}

src/PhpTrees/BinarySearchTree.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function find($value, BstNode $node = null) : ?BstNode
139139
*/
140140
private function findComparator($value, BstNode $node = null) : ?BstNode
141141
{
142-
$cmp = $this->comparator->__invoke($node->getValue(), $value);
142+
$cmp = ($this->comparator)($node->getValue(), $value);
143143
if ($cmp === true && $node->getRightChild() !== null) {
144144
return $this->find($value, $node->getRightChild());
145145
}

src/PhpTrees/BstNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function addChild($value) : void
7777
*/
7878
private function addChildComparator($value) : void
7979
{
80-
$cmp = $this->comparator->__invoke($this->value, $value);
80+
$cmp = ($this->comparator)($this->value, $value);
8181
if ($cmp === true) {
8282
if ($this->right === null) {
8383
$this->right = new BstNode($value, $this);

0 commit comments

Comments
 (0)