(fieldName string, field *ast.Field)
| 147 | } |
| 148 | |
| 149 | func (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 | |
| 166 | func (cp *classParser) typeToString(expr ast.Expr) string { |
| 167 | switch t := expr.(type) { |
no test coverage detected