| 25 | type Validator struct{} |
| 26 | |
| 27 | func (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 | |
| 49 | func (v *Validator) validateParameter(param phpParameter) error { |
| 50 | if param.Name == "" { |