@@ -47,8 +47,8 @@ public function removed(mixed $element): Set;
4747 * => [2]
4848 * ```
4949 *
50- * @psalm- param callable(TV): bool $predicate
51- * @psalm- return Set<TV>
50+ * @param callable(TV): bool $predicate
51+ * @return Set<TV>
5252 */
5353 public function filter (callable $ predicate ): Set ;
5454
@@ -60,10 +60,10 @@ public function filter(callable $predicate): Set;
6060 * => [Foo(2)]
6161 * ```
6262 *
63- * @psalm- template TVO
64- * @psalm- param class-string<TVO> $fqcn fully qualified class name
65- * @psalm- param bool $invariant if turned on then subclasses are not allowed
66- * @psalm- return Set<TVO>
63+ * @template TVO
64+ * @param class-string<TVO> $fqcn fully qualified class name
65+ * @param bool $invariant if turned on then subclasses are not allowed
66+ * @return Set<TVO>
6767 */
6868 public function filterOf (string $ fqcn , bool $ invariant = false ): Set ;
6969
@@ -75,7 +75,7 @@ public function filterOf(string $fqcn, bool $invariant = false): Set;
7575 * => [1]
7676 * ```
7777 *
78- * @psalm- return Set<TV>
78+ * @return Set<TV>
7979 */
8080 public function filterNotNull (): Set ;
8181
@@ -92,9 +92,9 @@ public function filterNotNull(): Set;
9292 * => [1, 2]
9393 * ```
9494 *
95- * @psalm- template TVO
96- * @psalm- param callable(TV): Option<TVO> $callback
97- * @psalm- return Set<TVO>
95+ * @template TVO
96+ * @param callable(TV): Option<TVO> $callback
97+ * @return Set<TVO>
9898 */
9999 public function filterMap (callable $ callback ): Set ;
100100
@@ -104,9 +104,9 @@ public function filterMap(callable $callback): Set;
104104 * => [1, 2, 3, 4, 5, 6]
105105 * ```
106106 *
107- * @psalm- template TVO
108- * @psalm- param callable(TV): iterable<TVO> $callback
109- * @psalm- return Set<TVO>
107+ * @template TVO
108+ * @param callable(TV): iterable<TVO> $callback
109+ * @return Set<TVO>
110110 */
111111 public function flatMap (callable $ callback ): Set ;
112112
@@ -120,8 +120,8 @@ public function flatMap(callable $callback): Set;
120120 * ```
121121 *
122122 * @template TVO
123- * @psalm- param callable(TV): TVO $callback
124- * @psalm- return Set<TVO>
123+ * @param callable(TV): TVO $callback
124+ * @return Set<TVO>
125125 */
126126 public function map (callable $ callback ): Set ;
127127
@@ -137,7 +137,7 @@ public function map(callable $callback): Set;
137137 * ```
138138 *
139139 * @param callable(TV): void $callback
140- * @psalm- return Set<TV>
140+ * @return Set<TV>
141141 */
142142 public function tap (callable $ callback ): Set ;
143143
@@ -149,7 +149,37 @@ public function tap(callable $callback): Set;
149149 * => [2, 3]
150150 * ```
151151 *
152- * @psalm- return Set<TV>
152+ * @return Set<TV>
153153 */
154154 public function tail (): Set ;
155+
156+ /**
157+ * Computes the intersection between this set and another set.
158+ *
159+ * ```php
160+ * >>> HashSet::collect([1, 2, 3])
161+ * ->intersect(HashSet::collect([2, 3]))->toArray();
162+ * => [2, 3]
163+ * ```
164+ *
165+ * @param Set<TV>|NonEmptySet<TV> $that the set to intersect with.
166+ * @return Set<TV> a new set consisting of all elements that are both in this
167+ * set and in the given set `that`.
168+ */
169+ public function intersect (Set |NonEmptySet $ that ): Set ;
170+
171+ /**
172+ * Computes the difference of this set and another set.
173+ *
174+ * ```php
175+ * >>> HashSet::collect([1, 2, 3])
176+ * ->diff(HashSet::collect([2, 3]))->toArray();
177+ * => [1]
178+ * ```
179+ *
180+ * @param Set<TV>|NonEmptySet<TV> $that the set of elements to exclude.
181+ * @return Set<TV> a set containing those elements of this
182+ * set that are not also contained in the given set `that`.
183+ */
184+ public function diff (Set |NonEmptySet $ that ): Set ;
155185}
0 commit comments