MCPcopy Index your code
hub / github.com/php/frankenphp / TestMethodParameterParsing

Function TestMethodParameterParsing

internal/extgen/classparser_test.go:188–266  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

186}
187
188func TestMethodParameterParsing(t *testing.T) {
189 tests := []struct {
190 name string
191 paramStr string
192 expectedParam phpParameter
193 expectError bool
194 }{
195 {
196 name: "simple int parameter",
197 paramStr: "int $age",
198 expectedParam: phpParameter{
199 Name: "age",
200 PhpType: phpInt,
201 IsNullable: false,
202 HasDefault: false,
203 },
204 expectError: false,
205 },
206 {
207 name: "nullable string parameter",
208 paramStr: "?string $name",
209 expectedParam: phpParameter{
210 Name: "name",
211 PhpType: phpString,
212 IsNullable: true,
213 HasDefault: false,
214 },
215 expectError: false,
216 },
217 {
218 name: "parameter with default value",
219 paramStr: `string $prefix = "default"`,
220 expectedParam: phpParameter{
221 Name: "prefix",
222 PhpType: phpString,
223 IsNullable: false,
224 HasDefault: true,
225 DefaultValue: "default",
226 },
227 expectError: false,
228 },
229 {
230 name: "nullable parameter with default null",
231 paramStr: "?int $count = null",
232 expectedParam: phpParameter{
233 Name: "count",
234 PhpType: phpInt,
235 IsNullable: true,
236 HasDefault: true,
237 DefaultValue: "null",
238 },
239 expectError: false,
240 },
241 {
242 name: "invalid parameter format",
243 paramStr: "invalid",
244 expectError: true,
245 },

Callers

nothing calls this directly

Calls 2

parseParameterFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected