Skip to content

Commit 523b2a5

Browse files
committed
Use self instead of Collection as a return type for Collection::copy()
1 parent 323cf2f commit 523b2a5

File tree

7 files changed

+8
-10
lines changed

7 files changed

+8
-10
lines changed

src/Collection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ function count(): int;
2525
/**
2626
* Returns a shallow copy of the collection.
2727
*
28-
* @return Collection a copy of the collection.
28+
* @return static a copy of the collection.
2929
*/
30-
function copy(): Collection;
30+
function copy();
3131

3232
/**
3333
* Returns whether the collection is empty.

src/Pair.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,8 @@ public function __unset($name)
5252

5353
/**
5454
* Returns a copy of the Pair
55-
*
56-
* @return Pair
5755
*/
58-
public function copy(): Pair
56+
public function copy(): self
5957
{
6058
return new self($this->key, $this->value);
6159
}

src/PriorityQueue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function clear()
5050
/**
5151
* @inheritDoc
5252
*/
53-
public function copy(): \Ds\Collection
53+
public function copy(): self
5454
{
5555
$copy = new PriorityQueue();
5656

src/Queue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function clear()
6363
/**
6464
* @inheritDoc
6565
*/
66-
public function copy(): \Ds\Collection
66+
public function copy(): self
6767
{
6868
return new self($this->deque);
6969
}

src/Set.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function contains(...$values): bool
101101
/**
102102
* @inheritDoc
103103
*/
104-
public function copy(): \Ds\Collection
104+
public function copy(): self
105105
{
106106
return new self($this);
107107
}

src/Stack.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function clear()
4040
/**
4141
* @inheritdoc
4242
*/
43-
public function copy(): Collection
43+
public function copy(): self
4444
{
4545
return new self($this->vector);
4646
}

src/Traits/GenericCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function jsonSerialize()
3939
*/
4040
public function copy(): self
4141
{
42-
return new self($this);
42+
return new static($this);
4343
}
4444

4545
/**

0 commit comments

Comments
 (0)