@@ -14,12 +14,8 @@ class Helper
1414{
1515 /**
1616 * Places item of extra columns into results by care of their order.
17- *
18- * @param array $item
19- * @param array $array
20- * @return array
2117 */
22- public static function includeInArray ($ item , $ array )
18+ public static function includeInArray (array $ item , array $ array ): array
2319 {
2420 if (self ::isItemOrderInvalid ($ item , $ array )) {
2521 return array_merge ($ array , [$ item ['name ' ] => $ item ['content ' ]]);
@@ -44,12 +40,8 @@ public static function includeInArray($item, $array)
4440
4541 /**
4642 * Check if item order is valid.
47- *
48- * @param array $item
49- * @param array $array
50- * @return bool
5143 */
52- protected static function isItemOrderInvalid ($ item , $ array )
44+ protected static function isItemOrderInvalid (array $ item , array $ array ): bool
5345 {
5446 return $ item ['order ' ] === false || $ item ['order ' ] >= count ($ array );
5547 }
@@ -122,11 +114,10 @@ public static function compileContent(mixed $content, array $data, array|object
122114 /**
123115 * Parses and compiles strings by using Blade Template System.
124116 *
125- * @param string $str
126- * @param array $data
127- * @return false|string
117+ *
118+ * @throws \Throwable
128119 */
129- public static function compileBlade ($ str , $ data = [])
120+ public static function compileBlade (string $ str , array $ data = []): false | string
130121 {
131122 if (view ()->exists ($ str )) {
132123 /** @var view-string $str */
@@ -143,10 +134,8 @@ public static function compileBlade($str, $data = [])
143134
144135 /**
145136 * Get a mixed value of custom data and the parameters.
146- *
147- * @return array
148137 */
149- public static function getMixedValue (array $ data , array |object $ param )
138+ public static function getMixedValue (array $ data , array |object $ param ): array
150139 {
151140 $ casted = self ::castToArray ($ param );
152141
@@ -175,11 +164,8 @@ public static function castToArray(array|object $param): array
175164
176165 /**
177166 * Get equivalent or method of query builder.
178- *
179- * @param string $method
180- * @return string
181167 */
182- public static function getOrMethod ($ method )
168+ public static function getOrMethod (string $ method ): string
183169 {
184170 if (! Str::contains (Str::lower ($ method ), 'or ' )) {
185171 return 'or ' .ucfirst ($ method );
@@ -190,11 +176,8 @@ public static function getOrMethod($method)
190176
191177 /**
192178 * Converts array object values to associative array.
193- *
194- * @param array $filters
195- * @return array
196179 */
197- public static function convertToArray (mixed $ row , $ filters = [])
180+ public static function convertToArray (mixed $ row , array $ filters = []): array
198181 {
199182 if (Arr::get ($ filters , 'ignore_getters ' ) && is_object ($ row ) && method_exists ($ row , 'getAttributes ' )) {
200183 $ data = $ row ->getAttributes ();
@@ -230,10 +213,7 @@ public static function convertToArray(mixed $row, $filters = [])
230213 return $ data ;
231214 }
232215
233- /**
234- * @return array
235- */
236- public static function transform (array $ data )
216+ public static function transform (array $ data ): array
237217 {
238218 return array_map (fn ($ row ) => self ::transformRow ($ row ), $ data );
239219 }
@@ -242,9 +222,8 @@ public static function transform(array $data)
242222 * Transform row data into an array.
243223 *
244224 * @param array $row
245- * @return array
246225 */
247- protected static function transformRow ($ row )
226+ protected static function transformRow ($ row ): array
248227 {
249228 foreach ($ row as $ key => $ value ) {
250229 if ($ value instanceof DateTime) {
@@ -263,10 +242,8 @@ protected static function transformRow($row)
263242
264243 /**
265244 * Build parameters depending on # of arguments passed.
266- *
267- * @return array
268245 */
269- public static function buildParameters (array $ args )
246+ public static function buildParameters (array $ args ): array
270247 {
271248 $ parameters = [];
272249
@@ -286,12 +263,8 @@ public static function buildParameters(array $args)
286263
287264 /**
288265 * Replace all pattern occurrences with keyword.
289- *
290- * @param string $keyword
291- * @param string $pattern
292- * @return array
293266 */
294- public static function replacePatternWithKeyword (array $ subject , $ keyword , $ pattern = '$1 ' )
267+ public static function replacePatternWithKeyword (array $ subject , string $ keyword , string $ pattern = '$1 ' ): array
295268 {
296269 $ parameters = [];
297270 foreach ($ subject as $ param ) {
@@ -307,12 +280,8 @@ public static function replacePatternWithKeyword(array $subject, $keyword, $patt
307280
308281 /**
309282 * Get column name from string.
310- *
311- * @param string $str
312- * @param bool $wantsAlias
313- * @return string
314283 */
315- public static function extractColumnName ($ str , $ wantsAlias )
284+ public static function extractColumnName (string $ str , bool $ wantsAlias ): string
316285 {
317286 $ matches = explode (' as ' , Str::lower ($ str ));
318287
@@ -333,25 +302,16 @@ public static function extractColumnName($str, $wantsAlias)
333302
334303 /**
335304 * Adds % wildcards to the given string.
336- *
337- * @param string $str
338- * @param bool $lowercase
339- * @return string
340305 */
341- public static function wildcardLikeString ($ str , $ lowercase = true )
306+ public static function wildcardLikeString (string $ str , bool $ lowercase = true ): string
342307 {
343308 return static ::wildcardString ($ str , '% ' , $ lowercase );
344309 }
345310
346311 /**
347312 * Adds wildcards to the given string.
348- *
349- * @param string $str
350- * @param string $wildcard
351- * @param bool $lowercase
352- * @return string
353313 */
354- public static function wildcardString ($ str , $ wildcard , $ lowercase = true )
314+ public static function wildcardString (string $ str , string $ wildcard , bool $ lowercase = true ): string
355315 {
356316 $ wild = $ wildcard ;
357317 $ chars = (array ) preg_split ('//u ' , $ str , -1 , PREG_SPLIT_NO_EMPTY );
0 commit comments