1717
1818class HandlerResolverTest extends TestCase
1919{
20- public function testResolvesClosuresToReflectionFunction ()
20+ public function testResolvesClosuresToReflectionFunction (): void
2121 {
2222 $ closure = static function (string $ input ): string {
2323 return "processed: $ input " ;
@@ -29,7 +29,7 @@ public function testResolvesClosuresToReflectionFunction()
2929 $ this ->assertEquals ('string ' , $ returnType ->getName ());
3030 }
3131
32- public function testResolvesValidArrayHandler ()
32+ public function testResolvesValidArrayHandler (): void
3333 {
3434 $ handler = [ValidHandlerClass::class, 'publicMethod ' ];
3535 $ resolved = HandlerResolver::resolve ($ handler );
@@ -38,7 +38,7 @@ public function testResolvesValidArrayHandler()
3838 $ this ->assertEquals (ValidHandlerClass::class, $ resolved ->getDeclaringClass ()->getName ());
3939 }
4040
41- public function testResolvesValidInvokableClassStringHandler ()
41+ public function testResolvesValidInvokableClassStringHandler (): void
4242 {
4343 $ handler = ValidInvokableClass::class;
4444 $ resolved = HandlerResolver::resolve ($ handler );
@@ -47,7 +47,7 @@ public function testResolvesValidInvokableClassStringHandler()
4747 $ this ->assertEquals (ValidInvokableClass::class, $ resolved ->getDeclaringClass ()->getName ());
4848 }
4949
50- public function testResolvesStaticMethodsForManualRegistration ()
50+ public function testResolvesStaticMethodsForManualRegistration (): void
5151 {
5252 $ handler = [ValidHandlerClass::class, 'staticMethod ' ];
5353 $ resolved = HandlerResolver::resolve ($ handler );
@@ -56,84 +56,84 @@ public function testResolvesStaticMethodsForManualRegistration()
5656 $ this ->assertTrue ($ resolved ->isStatic ());
5757 }
5858
59- public function testThrowsForInvalidArrayHandlerFormatCount ()
59+ public function testThrowsForInvalidArrayHandlerFormatCount (): void
6060 {
6161 $ this ->expectException (InvalidArgumentException::class);
6262 $ this ->expectExceptionMessage ("Invalid array handler format. Expected [ClassName::class, 'methodName']. " );
6363 HandlerResolver::resolve ([ValidHandlerClass::class]); /* @phpstan-ignore argument.type */
6464 }
6565
66- public function testThrowsForInvalidArrayHandlerFormatTypes ()
66+ public function testThrowsForInvalidArrayHandlerFormatTypes (): void
6767 {
6868 $ this ->expectException (InvalidArgumentException::class);
6969 $ this ->expectExceptionMessage ("Invalid array handler format. Expected [ClassName::class, 'methodName']. " );
7070 HandlerResolver::resolve ([ValidHandlerClass::class, 123 ]); /* @phpstan-ignore argument.type */
7171 }
7272
73- public function testThrowsForNonExistentClassInArrayHandler ()
73+ public function testThrowsForNonExistentClassInArrayHandler (): void
7474 {
7575 $ this ->expectException (InvalidArgumentException::class);
7676 $ this ->expectExceptionMessage ('Handler class "NonExistentClass" not found ' );
7777 HandlerResolver::resolve (['NonExistentClass ' , 'method ' ]);
7878 }
7979
80- public function testThrowsForNonExistentMethodInArrayHandler ()
80+ public function testThrowsForNonExistentMethodInArrayHandler (): void
8181 {
8282 $ this ->expectException (InvalidArgumentException::class);
8383 $ this ->expectExceptionMessage ('Handler method "nonExistentMethod" not found in class ' );
8484 HandlerResolver::resolve ([ValidHandlerClass::class, 'nonExistentMethod ' ]);
8585 }
8686
87- public function testThrowsForNonExistentClassInStringHandler ()
87+ public function testThrowsForNonExistentClassInStringHandler (): void
8888 {
8989 $ this ->expectException (InvalidArgumentException::class);
9090 $ this ->expectExceptionMessage ('Invalid handler format. Expected Closure, [ClassName::class, \'methodName \'] or InvokableClassName::class string. ' );
9191 HandlerResolver::resolve ('NonExistentInvokableClass ' );
9292 }
9393
94- public function testThrowsForNonInvokableClassStringHandler ()
94+ public function testThrowsForNonInvokableClassStringHandler (): void
9595 {
9696 $ this ->expectException (InvalidArgumentException::class);
9797 $ this ->expectExceptionMessage ('Invokable handler class "Mcp\Tests\Unit\Capability\Discovery\NonInvokableClass" must have a public "__invoke" method. ' );
9898 HandlerResolver::resolve (NonInvokableClass::class);
9999 }
100100
101- public function testThrowsForProtectedMethodHandler ()
101+ public function testThrowsForProtectedMethodHandler (): void
102102 {
103103 $ this ->expectException (InvalidArgumentException::class);
104104 $ this ->expectExceptionMessage ('must be public ' );
105105 HandlerResolver::resolve ([ValidHandlerClass::class, 'protectedMethod ' ]);
106106 }
107107
108- public function testThrowsForPrivateMethodHandler ()
108+ public function testThrowsForPrivateMethodHandler (): void
109109 {
110110 $ this ->expectException (InvalidArgumentException::class);
111111 $ this ->expectExceptionMessage ('must be public ' );
112112 HandlerResolver::resolve ([ValidHandlerClass::class, 'privateMethod ' ]);
113113 }
114114
115- public function testThrowsForConstructorAsHandler ()
115+ public function testThrowsForConstructorAsHandler (): void
116116 {
117117 $ this ->expectException (InvalidArgumentException::class);
118118 $ this ->expectExceptionMessage ('cannot be a constructor or destructor ' );
119119 HandlerResolver::resolve ([ValidHandlerClass::class, '__construct ' ]);
120120 }
121121
122- public function testThrowsForDestructorAsHandler ()
122+ public function testThrowsForDestructorAsHandler (): void
123123 {
124124 $ this ->expectException (InvalidArgumentException::class);
125125 $ this ->expectExceptionMessage ('cannot be a constructor or destructor ' );
126126 HandlerResolver::resolve ([ValidHandlerClass::class, '__destruct ' ]);
127127 }
128128
129- public function testThrowsForAbstractMethodHandler ()
129+ public function testThrowsForAbstractMethodHandler (): void
130130 {
131131 $ this ->expectException (InvalidArgumentException::class);
132132 $ this ->expectExceptionMessage ('Handler method "Mcp\Tests\Unit\Capability\Discovery\AbstractHandlerClass::abstractMethod" must be abstract. ' );
133133 HandlerResolver::resolve ([AbstractHandlerClass::class, 'abstractMethod ' ]);
134134 }
135135
136- public function testResolvesClosuresWithDifferentSignatures ()
136+ public function testResolvesClosuresWithDifferentSignatures (): void
137137 {
138138 $ noParams = static function () {
139139 return 'test ' ;
@@ -152,7 +152,7 @@ public function testResolvesClosuresWithDifferentSignatures()
152152 $ this ->assertTrue (HandlerResolver::resolve ($ variadic )->isVariadic ());
153153 }
154154
155- public function testDistinguishesBetweenClosuresAndCallableArrays ()
155+ public function testDistinguishesBetweenClosuresAndCallableArrays (): void
156156 {
157157 $ closure = static function () {
158158 return 'closure ' ;
0 commit comments