(t *testing.T)
| 350 | } |
| 351 | |
| 352 | func TestFunctionParserUnsupportedTypes(t *testing.T) { |
| 353 | tests := []struct { |
| 354 | name string |
| 355 | input string |
| 356 | expected int |
| 357 | hasWarning bool |
| 358 | }{ |
| 359 | { |
| 360 | name: "function with array parameter should be rejected", |
| 361 | input: `package main |
| 362 | |
| 363 | //export_php:function arrayFunc(array $data): string |
| 364 | func arrayFunc(data any) unsafe.Pointer { |
| 365 | return String("processed") |
| 366 | }`, |
| 367 | expected: 0, |
| 368 | hasWarning: true, |
| 369 | }, |
| 370 | { |
| 371 | name: "function with object parameter should be rejected", |
| 372 | input: `package main |
| 373 | |
| 374 | //export_php:function objectFunc(object $obj): string |
| 375 | func objectFunc(obj any) unsafe.Pointer { |
| 376 | return String("processed") |
| 377 | }`, |
| 378 | expected: 0, |
| 379 | hasWarning: true, |
| 380 | }, |
| 381 | { |
| 382 | name: "function with mixed parameter should be rejected", |
| 383 | input: `package main |
| 384 | |
| 385 | //export_php:function mixedFunc(mixed $value): string |
| 386 | func mixedFunc(value any) unsafe.Pointer { |
| 387 | return String("processed") |
| 388 | }`, |
| 389 | expected: 0, |
| 390 | hasWarning: true, |
| 391 | }, |
| 392 | { |
| 393 | name: "function with array return type should be rejected", |
| 394 | input: `package main |
| 395 | |
| 396 | //export_php:function arrayReturnFunc(string $name): array |
| 397 | func arrayReturnFunc(name *C.zend_string) any { |
| 398 | return []string{"result"} |
| 399 | }`, |
| 400 | expected: 0, |
| 401 | hasWarning: true, |
| 402 | }, |
| 403 | { |
| 404 | name: "function with object return type should be rejected", |
| 405 | input: `package main |
| 406 | |
| 407 | //export_php:function objectReturnFunc(string $name): object |
| 408 | func objectReturnFunc(name *C.zend_string) any { |
| 409 | return map[string]any{"key": "value"} |
nothing calls this directly
no test coverage detected