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

Function TestFunctionParserGoTypeMismatch

internal/extgen/funcparser_test.go:460–555  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

458}
459
460func TestFunctionParserGoTypeMismatch(t *testing.T) {
461 tests := []struct {
462 name string
463 input string
464 expected int
465 hasWarning bool
466 }{
467 {
468 name: "parameter count mismatch should be rejected",
469 input: `package main
470
471//export_php:function countMismatch(string $name, int $count): string
472func countMismatch(name *C.zend_string) unsafe.Pointer {
473 return nil
474}`,
475 expected: 0,
476 hasWarning: true,
477 },
478 {
479 name: "parameter type mismatch should be rejected",
480 input: `package main
481
482//export_php:function typeMismatch(string $name, int $count): string
483func typeMismatch(name *C.zend_string, count string) unsafe.Pointer {
484 return nil
485}`,
486 expected: 0,
487 hasWarning: true,
488 },
489 {
490 name: "return type mismatch should be rejected",
491 input: `package main
492
493//export_php:function returnMismatch(string $name): int
494func returnMismatch(name *C.zend_string) string {
495 return ""
496}`,
497 expected: 0,
498 hasWarning: true,
499 },
500 {
501 name: "valid matching types should pass",
502 input: `package main
503
504//export_php:function validMatch(string $name, int $count): string
505func validMatch(name *C.zend_string, count int64) unsafe.Pointer {
506 return nil
507}`,
508 expected: 1,
509 hasWarning: false,
510 },
511 {
512 name: "valid bool types should pass",
513 input: `package main
514
515//export_php:function validBool(bool $flag): bool
516func validBool(flag bool) bool {
517 return flag

Callers

nothing calls this directly

Calls 3

parseMethod · 0.95
captureWarningsFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected