@@ -67,7 +67,8 @@ public function count(): int {
6767 *
6868 * @since 2.0.0
6969 *
70- * @param $mode The mode as used in array_filter() which determines the arguments passed to the callback.
70+ * @param callable(ModelProperty,string):bool $callback
71+ * @param int $mode The mode as used in array_filter() which determines the arguments passed to the callback.
7172 */
7273 public function filter ( callable $ callback , $ mode = 0 ): ModelPropertyCollection {
7374 return new self ( array_filter ( $ this ->properties , $ callback , $ mode ) );
@@ -134,6 +135,8 @@ public function getDirtyProperties(): ModelPropertyCollection {
134135 * Get the dirty values of the properties.
135136 *
136137 * @since 2.0.0
138+ *
139+ * @return array<string,mixed>
137140 */
138141 public function getDirtyValues (): array {
139142 return $ this ->getDirtyProperties ()->map ( fn ( ModelProperty $ property ) => $ property ->getValue () );
@@ -185,6 +188,8 @@ public function getRequiredOnSaveProperties(): ModelPropertyCollection {
185188 * Get the values of the properties.
186189 *
187190 * @since 2.0.0
191+ *
192+ * @return array<string,mixed>
188193 */
189194 public function getValues (): array {
190195 return $ this ->map ( fn ( ModelProperty $ property ) => $ property ->getValue () );
@@ -230,7 +235,10 @@ public function isSet( string $key ): bool {
230235 * Map the properties. This does not use array_map because we want to preserve the keys.
231236 *
232237 * @since 2.0.0
233- * @return array<string,mixed>
238+ *
239+ * @template TMapValue
240+ * @param callable(ModelProperty):TMapValue $callback
241+ * @return array<string,TMapValue>
234242 */
235243 public function map ( callable $ callback ) {
236244 return $ this ->reduce ( static function ( $ carry , ModelProperty $ property ) use ( $ callback ) {
@@ -244,6 +252,12 @@ public function map( callable $callback ) {
244252 * Reduce the properties.
245253 *
246254 * @since 2.0.0
255+ *
256+ * @template TReduceInitial
257+ * @template TReduceResult
258+ * @param callable(TReduceResult,ModelProperty):TReduceResult $callback
259+ * @param TReduceInitial $initial
260+ * @return TReduceResult|TReduceInitial
247261 */
248262 public function reduce ( callable $ callback , $ initial = null ) {
249263 return array_reduce ( $ this ->properties , $ callback , $ initial );
@@ -271,6 +285,8 @@ public function revertProperty( string $key ): void {
271285 * Set the values of the properties.
272286 *
273287 * @since 2.0.0
288+ *
289+ * @param array<string,mixed> $values
274290 */
275291 public function setValues ( array $ values ) {
276292 foreach ( $ values as $ key => $ value ) {
@@ -282,6 +298,13 @@ public function setValues( array $values ) {
282298 }
283299 }
284300
301+ /**
302+ * Execute a callback on each property and return the collection.
303+ *
304+ * @since 2.0.0
305+ *
306+ * @param callable(ModelProperty):void $callback
307+ */
285308 public function tap ( callable $ callback ): self {
286309 foreach ( $ this ->properties as $ property ) {
287310 $ callback ( $ property );
0 commit comments