diff --git a/internal/extgen/constparser.go b/internal/extgen/constparser.go index 86f80337cf..fea8c8c9cb 100644 --- a/internal/extgen/constparser.go +++ b/internal/extgen/constparser.go @@ -12,6 +12,8 @@ import ( var constRegex = regexp.MustCompile(`//\s*export_php:const$`) var classConstRegex = regexp.MustCompile(`//\s*export_php:classconst\s+(\w+)$`) var constDeclRegex = regexp.MustCompile(`const\s+(\w+)\s*=\s*(.+)`) +var constBlockDeclRegex = regexp.MustCompile(`^(\w+)\s*=\s*(.+)$`) +var constNameRegex = regexp.MustCompile(`^(\w+)$`) type ConstantParser struct{} @@ -109,7 +111,6 @@ func (cp *ConstantParser) parse(filename string) (constants []phpConstant, err e expectConstDecl = false expectClassConstDecl = false } else if inConstBlock && (expectConstDecl || expectClassConstDecl || exportAllInBlock) { - constBlockDeclRegex := regexp.MustCompile(`^(\w+)\s*=\s*(.+)$`) if matches := constBlockDeclRegex.FindStringSubmatch(line); len(matches) == 3 { name := matches[1] value := strings.TrimSpace(matches[2]) @@ -139,7 +140,6 @@ func (cp *ConstantParser) parse(filename string) (constants []phpConstant, err e expectConstDecl = false expectClassConstDecl = false } else { - constNameRegex := regexp.MustCompile(`^(\w+)$`) if matches := constNameRegex.FindStringSubmatch(line); len(matches) == 2 { name := matches[1]