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

Method validateTypes

internal/extgen/validator.go:107–119  ·  view source on GitHub ↗

validateTypes checks if PHP signature contains only supported types

(fn phpFunction)

Source from the content-addressed store, hash-verified

105
106// validateTypes checks if PHP signature contains only supported types
107func (v *Validator) validateTypes(fn phpFunction) error {
108 for i, param := range fn.Params {
109 if !slices.Contains(supportedTypes, param.PhpType) {
110 return fmt.Errorf("parameter %d %q has unsupported type %q, supported typed: string, int, float, bool, array and mixed, can be nullable", i+1, param.Name, param.PhpType)
111 }
112 }
113
114 if fn.ReturnType != phpVoid && !slices.Contains(supportedTypes, fn.ReturnType) {
115 return fmt.Errorf("return type %q is not supported, supported typed: string, int, float, bool, array and mixed, can be nullable", fn.ReturnType)
116 }
117
118 return nil
119}
120
121// validateGoFunctionSignatureWithOptions validates with option for method vs function
122func (v *Validator) validateGoFunctionSignatureWithOptions(phpFunc phpFunction, isMethod bool) error {

Callers 3

parseMethod · 0.95
parseMethodsMethod · 0.95
TestValidateTypesFunction · 0.95

Calls

no outgoing calls

Tested by 1

TestValidateTypesFunction · 0.76