@@ -18,7 +18,7 @@ final class Underscore extends UnderscoreFunction
1818 *
1919 * @param array|mixed $data
2020 */
21- public function __construct ($ data = [])
21+ public function __construct (mixed $ data = [])
2222 {
2323 parent ::__construct ($ data );
2424 }
@@ -30,44 +30,31 @@ public function __construct($data = [])
3030 *
3131 * @return self
3232 */
33- public static function _ ($ data = null )
33+ public static function _ ($ data = null ): self
3434 {
3535 return new static ($ data );
3636 }
3737
3838 /**
3939 * Generates a function that always returns a constant value.
40- *
41- * @param mixed $value
42- *
43- * @return callable
4440 */
45- public function constant ($ value )
41+ public function constant (mixed $ value ): callable
4642 {
47- return function () use ($ value ) {
48- return $ value ;
49- };
43+ return fn () => $ value ;
5044 }
5145
5246 /**
5347 * No operation!
54- *
55- * @return void
5648 */
57- public function noop ()
49+ public function noop (): void
5850 {
5951 // ;)
6052 }
6153
6254 /**
6355 * Run callable n times and create new collection.
64- *
65- * @param int $n
66- * @param callable $fn
67- *
68- * @return self
6956 */
70- public function times ($ n , callable $ fn )
57+ public function times (int $ n , callable $ fn ): self
7158 {
7259 $ data = [];
7360
@@ -80,25 +67,16 @@ public function times($n, callable $fn)
8067
8168 /**
8269 * Return a random integer between min and max (inclusive).
83- *
84- * @param int $min
85- * @param int $max
86- *
87- * @return int
8870 */
89- public function random ($ min , $ max )
71+ public function random (int $ min , int $ max ): int
9072 {
9173 return \mt_rand ($ min , $ max );
9274 }
9375
9476 /**
9577 * Generate unique ID (unique for current go/session).
96- *
97- * @param string $prefix
98- *
99- * @return string
10078 */
101- public function uniqueId ($ prefix = '' )
79+ public function uniqueId (string $ prefix = '' ): string
10280 {
10381 static $ id = 0 ;
10482
0 commit comments