@@ -46,6 +46,71 @@ protected function getRule(): Rule
4646 ],
4747 'visibilityScope ' => 'public ' ,
4848 ],
49+ [
50+ 'pattern ' => '/^TestClass::testMaxParams$/ ' ,
51+ 'minParameters ' => 1 ,
52+ 'maxParameters ' => 2 ,
53+ 'signature ' => [],
54+ 'visibilityScope ' => 'public ' ,
55+ ],
56+ [
57+ 'pattern ' => '/^TestClass::testNameMismatch$/ ' ,
58+ 'minParameters ' => 2 ,
59+ 'maxParameters ' => 2 ,
60+ 'signature ' => [
61+ ['type ' => 'int ' , 'pattern ' => '/^param/ ' ], // Name pattern doesn't match
62+ ['type ' => 'string ' , 'pattern ' => '/^param/ ' ], // Name pattern doesn't match
63+ ],
64+ 'visibilityScope ' => 'public ' ,
65+ ],
66+ [
67+ 'pattern ' => '/^TestClass::testNullableTypes$/ ' ,
68+ 'minParameters ' => 2 ,
69+ 'maxParameters ' => 2 ,
70+ 'signature ' => [
71+ ['type ' => '?int ' , 'pattern ' => '/^nullable/ ' ],
72+ ['type ' => '?string ' , 'pattern ' => '/^nullable/ ' ],
73+ ],
74+ 'visibilityScope ' => 'public ' ,
75+ ],
76+ [
77+ 'pattern ' => '/^TestClass::testClassTypes$/ ' ,
78+ 'minParameters ' => 2 ,
79+ 'maxParameters ' => 2 ,
80+ 'signature ' => [
81+ ['type ' => 'DummyClass ' , 'pattern ' => '/^dummy/ ' ],
82+ ['type ' => 'string ' , 'pattern ' => '/^name/ ' ],
83+ ],
84+ 'visibilityScope ' => 'public ' ,
85+ ],
86+ [
87+ 'pattern ' => '/^TestClass::testProtectedMethod$/ ' ,
88+ 'minParameters ' => 1 ,
89+ 'maxParameters ' => 1 ,
90+ 'signature ' => [
91+ ['type ' => 'int ' , 'pattern ' => '/^value/ ' ],
92+ ],
93+ 'visibilityScope ' => 'protected ' ,
94+ ],
95+ [
96+ 'pattern ' => '/^TestClass::testNoVisibilityReq$/ ' ,
97+ 'minParameters ' => 1 ,
98+ 'maxParameters ' => 1 ,
99+ 'signature ' => [
100+ ['type ' => 'int ' , 'pattern ' => '/^x/ ' ],
101+ ],
102+ // No visibilityScope specified
103+ ],
104+ [
105+ 'pattern ' => '/^TestClass::testValidMethod$/ ' ,
106+ 'minParameters ' => 2 ,
107+ 'maxParameters ' => 2 ,
108+ 'signature ' => [
109+ ['type ' => 'int ' , 'pattern ' => '/^alpha/ ' ],
110+ ['type ' => 'string ' , 'pattern ' => '/^beta/ ' ],
111+ ],
112+ 'visibilityScope ' => 'public ' ,
113+ ],
49114 ]);
50115 }
51116
@@ -55,15 +120,15 @@ public function testRule(): void
55120 // Errors for testMethod (type checking enabled)
56121 [
57122 'Method TestClass::testMethod has 1 parameters, but at least 2 required. ' ,
58- 5 ,
123+ 9 ,
59124 ],
60125 [
61126 'Method TestClass::testMethod is missing parameter #2 of type string. ' ,
62- 5 ,
127+ 9 ,
63128 ],
64129 [
65130 'Method TestClass::testMethod must be private. ' ,
66- 5 ,
131+ 9 ,
67132 ],
68133 // No errors for testMethodNoType since:
69134 // - First parameter has no type specified, so type checking is skipped
@@ -76,8 +141,34 @@ public function testRule(): void
76141 // - Second parameter has no type specified, so type checking is skipped
77142 [
78143 'Method TestClass::testMethodWithWrongType parameter #1 should be of type string, int given. ' ,
79- 13 ,
144+ 17 ,
145+ ],
146+
147+ // Errors for testMaxParams - exceeds max parameters
148+ [
149+ 'Method TestClass::testMaxParams has 4 parameters, but at most 2 allowed. ' ,
150+ 22 ,
151+ ],
152+
153+ // Errors for testNameMismatch - parameter names don't match patterns
154+ [
155+ 'Method TestClass::testNameMismatch parameter #1 name "wrongName" does not match pattern /^param/. ' ,
156+ 27 ,
157+ ],
158+ [
159+ 'Method TestClass::testNameMismatch parameter #2 name "anotherWrong" does not match pattern /^param/. ' ,
160+ 27 ,
80161 ],
162+
163+ // No errors for testNullableTypes - nullable types should match correctly
164+
165+ // No errors for testClassTypes - class types should match correctly
166+
167+ // No errors for testProtectedMethod - protected visibility matches
168+
169+ // No errors for testNoVisibilityReq - no visibility requirement specified
170+
171+ // No errors for testValidMethod - everything matches correctly
81172 ]);
82173 }
83174}
0 commit comments