@@ -15,17 +15,18 @@ final class Helpers
1515{
1616 public function joinArray (string $ separator = '' ): Pipeline
1717 {
18+ /** @psalm-suppress MixedArgumentTypeCoercion */
1819 return new Pipeline (
1920 new AssertType (AssertType::ARRAY ),
20- new Call (fn ($ value ) => implode ($ separator , $ value ))
21+ new Call (fn (array $ value ) => implode ($ separator , $ value ))
2122 );
2223 }
2324
2425 public function sortArray (bool $ descending = false , int $ options = SORT_REGULAR ): Pipeline
2526 {
2627 return new Pipeline (
2728 new AssertType (AssertType::ARRAY ),
28- new Call (function ($ value ) use ($ descending , $ options ) {
29+ new Call (function (array $ value ) use ($ descending , $ options ) {
2930 if ($ descending ) {
3031 rsort ($ value , $ options );
3132 } else {
@@ -41,7 +42,7 @@ public function uniqueArray(bool $keepKeys = false, int $options = SORT_STRING):
4142 {
4243 return new Pipeline (
4344 new AssertType (AssertType::ARRAY ),
44- new Call (function ($ value ) use ($ keepKeys , $ options ) {
45+ new Call (function (array $ value ) use ($ keepKeys , $ options ) {
4546 $ items = array_unique ($ value , $ options );
4647
4748 return $ keepKeys ? $ items : array_values ($ items );
@@ -51,12 +52,12 @@ public function uniqueArray(bool $keepKeys = false, int $options = SORT_STRING):
5152
5253 public function ifNotFound (ProcessorInterface $ true , ?ProcessorInterface $ false = null ): Condition
5354 {
54- return new Condition (fn ($ value ) => $ value instanceof NotFoundValue, $ true , $ false ?? new Pass ());
55+ return new Condition (fn (mixed $ value ) => $ value instanceof NotFoundValue, $ true , $ false ?? new Pass ());
5556 }
5657
5758 public function ifEmpty (ProcessorInterface $ true , ?ProcessorInterface $ false = null ): Condition
5859 {
59- return new Condition (fn ($ value ) => empty ($ value ), $ true , $ false ?? new Pass ());
60+ return new Condition (fn (mixed $ value ) => empty ($ value ), $ true , $ false ?? new Pass ());
6061 }
6162
6263 public function ifNull (ProcessorInterface $ true , ?ProcessorInterface $ false = null ): Condition
@@ -66,27 +67,31 @@ public function ifNull(ProcessorInterface $true, ?ProcessorInterface $false = nu
6667
6768 public function ifEqual (mixed $ to , ProcessorInterface $ true , ?ProcessorInterface $ false = null , bool $ strict = true ): Condition
6869 {
69- return new Condition (fn ($ value ) => $ strict ? $ value === $ to : $ value == $ to , $ true , $ false ?? new Pass ());
70+ return new Condition (fn (mixed $ value ) => $ strict ? $ value === $ to : $ value == $ to , $ true , $ false ?? new Pass ());
7071 }
7172
7273 public function ifNotEqual (mixed $ to , ProcessorInterface $ true , ?ProcessorInterface $ false = null , bool $ strict = true ): Condition
7374 {
74- return $ this -> ifEqual ( $ to , $ false , $ true , $ strict );
75+ return new Condition ( fn ( mixed $ value ) => $ strict ? $ value !== $ to : $ value != $ to , $ true , $ false ?? new Pass () );
7576 }
7677
78+ /**
79+ * @param non-empty-string $separator
80+ * @return Pipeline
81+ */
7782 public function explodeString (string $ separator ): Pipeline
7883 {
7984 return new Pipeline (
8085 new AssertType (AssertType::STRING ),
81- new Call (fn ($ value ) => explode ($ separator , $ value ))
86+ new Call (fn (string $ value ) => explode ($ separator , $ value ))
8287 );
8388 }
8489
8590 public function trimString (string $ characters = " \t\n\r\0\x0B" ): Pipeline
8691 {
8792 return new Pipeline (
8893 new AssertType (AssertType::STRING ),
89- new Call (fn ($ value ) => trim ($ value , $ characters ))
94+ new Call (fn (string $ value ) => trim ($ value , $ characters ))
9095 );
9196 }
9297
@@ -99,15 +104,15 @@ public function toFloat(): Pipeline
99104 {
100105 return new Pipeline (
101106 new AssertType (AssertType::NULL , AssertType::SCALAR ),
102- new Call (fn ($ value ) => is_null ($ value ) ? 0.0 : floatval ($ value ))
107+ new Call (fn (mixed $ value ) => is_null ($ value ) ? 0.0 : floatval ($ value ))
103108 );
104109 }
105110
106111 public function toInt (): Pipeline
107112 {
108113 return new Pipeline (
109114 new AssertType (AssertType::NULL , AssertType::SCALAR ),
110- new Call (fn ($ value ) => is_null ($ value ) ? 0 : intval ($ value ))
115+ new Call (fn (mixed $ value ) => is_null ($ value ) ? 0 : intval ($ value ))
111116 );
112117 }
113118
@@ -121,7 +126,7 @@ public function toString(): Pipeline
121126
122127 public function toArray (): Call
123128 {
124- return new Call (function ($ value ) {
129+ return new Call (function (mixed $ value ) {
125130 if ($ value instanceof Traversable) {
126131 return iterator_to_array ($ value );
127132 }
0 commit comments