File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed
Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -61,17 +61,17 @@ public static function boolean(callable $filter): void
6161
6262 $ returnTypeName = $ returnType ->getName ();
6363
64- if ($ returnTypeName !== ' bool ' ) {
64+ if ($ returnType -> allowsNull () ) {
6565 throw new InvalidArgumentException (sprintf (
6666 self ::MESSAGE ,
67- $ returnTypeName
67+ ' ? ' . $ returnTypeName
6868 ));
6969 }
7070
71- if ($ returnType -> allowsNull () ) {
71+ if ($ returnTypeName !== ' bool ' ) {
7272 throw new InvalidArgumentException (sprintf (
7373 self ::MESSAGE ,
74- ' ? ' . $ returnTypeName
74+ $ returnTypeName
7575 ));
7676 }
7777 }
Original file line number Diff line number Diff line change @@ -85,6 +85,22 @@ public function __invoke(int $datum): ?bool
8585 AtLeast::once ($ data , $ filter );
8686 }
8787
88+ public function testWithNullableReturnNonBoolTypeCallable (): void
89+ {
90+ $ this ->expectException (InvalidArgumentException::class);
91+ $ this ->expectExceptionMessage ('Expected a bool return type on callable filter, ?string given ' );
92+
93+ $ data = [1 , 2 , 3 ];
94+ $ filter = new class {
95+ public function __invoke (int $ datum ): ?string
96+ {
97+ return 'test ' ;
98+ }
99+ };
100+
101+ AtLeast::once ($ data , $ filter );
102+ }
103+
88104 public function testWithUnionReturnTypeCallable (): void
89105 {
90106 $ this ->expectException (InvalidArgumentException::class);
You can’t perform that action at this time.
0 commit comments