Skip to content

Commit 5652e58

Browse files
authored
Merge pull request #69 from simPod/templating
Add templating annotations
2 parents 494494c + c3ea437 commit 5652e58

File tree

14 files changed

+324
-76
lines changed

14 files changed

+324
-76
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010
],
1111
"require": {
12-
"php": ">=7.0.0",
12+
"php": ">=7.1.0",
1313
"ext-json": "*"
1414
},
1515
"require-dev": {

src/Collection.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
* traversable, countable, and can be converted to json using json_encode().
88
*
99
* @package Ds
10+
*
11+
* @template-covariant TKey
12+
* @template-covariant TValue
13+
* @extends Traversable<TKey, TValue>
1014
*/
1115
interface Collection extends \IteratorAggregate, \Countable, \JsonSerializable
1216
{
@@ -26,6 +30,8 @@ function count(): int;
2630
* Returns a shallow copy of the collection.
2731
*
2832
* @return static a copy of the collection.
33+
*
34+
* @psalm-return static<TKey, TValue>
2935
*/
3036
function copy();
3137

@@ -34,8 +40,6 @@ function copy();
3440
*
3541
* This should be equivalent to a count of zero, but is not required.
3642
* Implementations should define what empty means in their own context.
37-
*
38-
* @return bool
3943
*/
4044
function isEmpty(): bool;
4145

@@ -46,7 +50,7 @@ function isEmpty(): bool;
4650
* Some implementations may throw an exception if an array representation
4751
* could not be created.
4852
*
49-
* @return array
53+
* @return array<TKey, TValue>
5054
*/
5155
function toArray(): array;
5256
}

src/Deque.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
* at both ends of the buffer, ie. shift, unshift, push and pop are all O(1).
1111
*
1212
* @package Ds
13+
*
14+
* @template TValue
15+
* @implements Sequence<TValue>
1316
*/
1417
final class Deque implements Sequence
1518
{

src/Hashable.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ function hash();
2626
* Determines if two objects should be considered equal. Both objects will
2727
* be instances of the same class but may not be the same instance.
2828
*
29-
* @param $obj An instance of the same class to compare to.
30-
*
31-
* @return bool
29+
* @param mixed $obj An instance of the same class to compare to.
3230
*/
3331
function equals($obj): bool;
3432
}

0 commit comments

Comments
 (0)