1 | <?php |
||
9 | trait Collection |
||
10 | { |
||
11 | /** |
||
12 | * Returns whether the collection is empty. |
||
13 | * |
||
14 | * This should be equivalent to a count of zero, but is not required. |
||
15 | * Implementations should define what empty means in their own context. |
||
16 | * |
||
17 | * @return bool |
||
18 | */ |
||
19 | public function isEmpty(): bool |
||
23 | |||
24 | /** |
||
25 | * Json Serialize |
||
26 | * |
||
27 | * @return string |
||
|
|||
28 | */ |
||
29 | public function jsonSerialize() |
||
33 | |||
34 | /** |
||
35 | * Creates a copy of the collection. |
||
36 | * |
||
37 | * @return self |
||
38 | */ |
||
39 | public function copy(): \Ds\Collection |
||
43 | |||
44 | /** |
||
45 | * Returns an array representation of the collection. |
||
46 | * |
||
47 | * The format of the returned array is implementation-dependent. |
||
48 | * Some implementations may throw an exception if an array representation |
||
49 | * could not be created. |
||
50 | * |
||
51 | * @return array |
||
52 | */ |
||
53 | abstract public function toArray(): array; |
||
54 | |||
55 | /** |
||
56 | * Debug Info |
||
57 | */ |
||
58 | public function __debugInfo() |
||
62 | |||
63 | /** |
||
64 | * To String |
||
65 | */ |
||
66 | public function __toString() |
||
70 | } |
||
71 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.If the return type contains the type array, this check recommends the use of a more specific type like
String[]
orarray<String>
.