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

Method validateFunction

internal/extgen/validator.go:27–47  ·  view source on GitHub ↗
(fn phpFunction)

Source from the content-addressed store, hash-verified

25type Validator struct{}
26
27func (v *Validator) validateFunction(fn phpFunction) error {
28 if fn.Name == "" {
29 return fmt.Errorf("function name cannot be empty")
30 }
31
32 if !functionNameRegex.MatchString(fn.Name) {
33 return fmt.Errorf("invalid function name: %s", fn.Name)
34 }
35
36 for i, param := range fn.Params {
37 if err := v.validateParameter(param); err != nil {
38 return fmt.Errorf("parameter %d (%s): %w", i, param.Name, err)
39 }
40 }
41
42 if err := v.validateReturnType(fn.ReturnType); err != nil {
43 return fmt.Errorf("return type: %w", err)
44 }
45
46 return nil
47}
48
49func (v *Validator) validateParameter(param phpParameter) error {
50 if param.Name == "" {

Callers 2

parseMethod · 0.95
TestValidateFunctionFunction · 0.95

Calls 2

validateParameterMethod · 0.95
validateReturnTypeMethod · 0.95

Tested by 1

TestValidateFunctionFunction · 0.76