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

Method parseStructField

internal/extgen/classparser.go:149–164  ·  view source on GitHub ↗
(fieldName string, field *ast.Field)

Source from the content-addressed store, hash-verified

147}
148
149func (cp *classParser) parseStructField(fieldName string, field *ast.Field) phpClassProperty {
150 prop := phpClassProperty{Name: fieldName}
151
152 // check if field is a pointer (nullable)
153 if starExpr, isPointer := field.Type.(*ast.StarExpr); isPointer {
154 prop.IsNullable = true
155 prop.GoType = cp.typeToString(starExpr.X)
156 } else {
157 prop.IsNullable = false
158 prop.GoType = cp.typeToString(field.Type)
159 }
160
161 prop.PhpType = cp.goTypeToPHPType(prop.GoType)
162
163 return prop
164}
165
166func (cp *classParser) typeToString(expr ast.Expr) string {
167 switch t := expr.(type) {

Callers 1

parseStructFieldsMethod · 0.95

Calls 2

typeToStringMethod · 0.95
goTypeToPHPTypeMethod · 0.95

Tested by

no test coverage detected