determineConstantType analyzes the value and determines its type
(value string)
| 179 | |
| 180 | // determineConstantType analyzes the value and determines its type |
| 181 | func determineConstantType(value string) phpType { |
| 182 | value = strings.TrimSpace(value) |
| 183 | |
| 184 | if (strings.HasPrefix(value, `"`) && strings.HasSuffix(value, `"`)) || |
| 185 | (strings.HasPrefix(value, "`") && strings.HasSuffix(value, "`")) { |
| 186 | return phpString |
| 187 | } |
| 188 | |
| 189 | if value == "true" || value == "false" { |
| 190 | return phpBool |
| 191 | } |
| 192 | |
| 193 | // check for integer literals, including hex, octal, binary |
| 194 | if _, err := strconv.ParseInt(value, 0, 64); err == nil { |
| 195 | return phpInt |
| 196 | } |
| 197 | |
| 198 | if _, err := strconv.ParseFloat(value, 64); err == nil { |
| 199 | return phpFloat |
| 200 | } |
| 201 | |
| 202 | return phpInt |
| 203 | } |
no outgoing calls