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

Function determineConstantType

internal/extgen/constparser.go:181–203  ·  view source on GitHub ↗

determineConstantType analyzes the value and determines its type

(value string)

Source from the content-addressed store, hash-verified

179
180// determineConstantType analyzes the value and determines its type
181func 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}

Callers 2

parseMethod · 0.85

Calls

no outgoing calls

Tested by 1