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

Method phpTypeToGoType

internal/extgen/validator.go:197–223  ·  view source on GitHub ↗
(t phpType, isNullable bool)

Source from the content-addressed store, hash-verified

195}
196
197func (v *Validator) phpTypeToGoType(t phpType, isNullable bool) string {
198 var baseType string
199 switch t {
200 case phpString:
201 baseType = "*C.zend_string"
202 case phpInt:
203 baseType = "int64"
204 case phpFloat:
205 baseType = "float64"
206 case phpBool:
207 baseType = "bool"
208 case phpArray:
209 baseType = "*C.zend_array"
210 case phpMixed:
211 baseType = "*C.zval"
212 case phpCallable:
213 baseType = "*C.zval"
214 default:
215 baseType = "any"
216 }
217
218 if isNullable && t != phpString && t != phpArray && t != phpCallable {
219 return "*" + baseType
220 }
221
222 return baseType
223}
224
225// isCompatibleGoType checks if the actual Go type is compatible with the expected type.
226// PHP int maps to Go int64: we also accept plain int for ergonomics on 64-bit platforms

Callers 2

TestPhpTypeToGoTypeFunction · 0.95

Calls

no outgoing calls

Tested by 1

TestPhpTypeToGoTypeFunction · 0.76