Skip to content

Commit b749f52

Browse files
committed
chore: simplify string using backticks
# Conflicts: # internal/extgen/classparser.go # internal/extgen/gofile_test.go
1 parent e917ab7 commit b749f52

6 files changed

Lines changed: 13 additions & 13 deletions

File tree

caddy/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type FrankenPHPApp struct {
4242
logger *slog.Logger
4343
}
4444

45-
var iniError = errors.New("'php_ini' must be in the format: php_ini \"<key>\" \"<value>\"")
45+
var iniError = errors.New(`"php_ini" must be in the format: php_ini "<key>" "<value>"`)
4646

4747
// CaddyModule returns the Caddy module information.
4848
func (f FrankenPHPApp) CaddyModule() caddy.ModuleInfo {

internal/extgen/cfile_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ func TestCFileSpecialCharacters(t *testing.T) {
313313
content, err := cGen.buildContent()
314314
require.NoError(t, err)
315315

316-
expectedInclude := "#include \"" + tt.expected + ".h\""
316+
expectedInclude := `#include "` + tt.expected + `.h"`
317317
assert.Contains(t, content, expectedInclude, "Content should contain include: %s", expectedInclude)
318318
})
319319
}
@@ -424,8 +424,8 @@ func TestCFileConstants(t *testing.T) {
424424
},
425425
},
426426
contains: []string{
427-
"REGISTER_LONG_CONSTANT(\"GLOBAL_INT\", 42, CONST_CS | CONST_PERSISTENT);",
428-
"REGISTER_STRING_CONSTANT(\"GLOBAL_STRING\", \"test\", CONST_CS | CONST_PERSISTENT);",
427+
`REGISTER_LONG_CONSTANT("GLOBAL_INT", 42, CONST_CS | CONST_PERSISTENT);`,
428+
`REGISTER_STRING_CONSTANT("GLOBAL_STRING", "test", CONST_CS | CONST_PERSISTENT);`,
429429
},
430430
},
431431
}

internal/extgen/constparser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (cp *ConstantParser) parse(filename string) (constants []phpConstant, err e
9999
func determineConstantType(value string) phpType {
100100
value = strings.TrimSpace(value)
101101

102-
if (strings.HasPrefix(value, "\"") && strings.HasSuffix(value, "\"")) ||
102+
if (strings.HasPrefix(value, `"`) && strings.HasSuffix(value, `"`)) ||
103103
(strings.HasPrefix(value, "`") && strings.HasSuffix(value, "`")) {
104104
return phpString
105105
}

internal/extgen/constparser_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func TestConstantParserTypeDetection(t *testing.T) {
250250
value string
251251
expectedType phpType
252252
}{
253-
{"string with double quotes", "\"hello world\"", phpString},
253+
{"string with double quotes", `"hello world"`, phpString},
254254
{"string with backticks", "`hello world`", phpString},
255255
{"boolean true", "true", phpBool},
256256
{"boolean false", "false", phpBool},
@@ -443,13 +443,13 @@ func TestConstantParserDeclRegex(t *testing.T) {
443443
name string
444444
value string
445445
}{
446-
{"const MyConst = \"value\"", true, "MyConst", "\"value\""},
446+
{`const MyConst = "value"`, true, "MyConst", `"value"`},
447447
{"const IntConst = 42", true, "IntConst", "42"},
448448
{"const BoolConst = true", true, "BoolConst", "true"},
449449
{"const IotaConst = iota", true, "IotaConst", "iota"},
450450
{"const ComplexValue = someFunction()", true, "ComplexValue", "someFunction()"},
451-
{"const SpacedName = \"with spaces\"", true, "SpacedName", "\"with spaces\""},
452-
{"var notAConst = \"value\"", false, "", ""},
451+
{`const SpacedName = "with spaces"`, true, "SpacedName", `"with spaces"`},
452+
{`var notAConst = "value"`, false, "", ""},
453453
{"const", false, "", ""},
454454
{"const =", false, "", ""},
455455
}
@@ -518,10 +518,10 @@ func TestPHPConstantCValue(t *testing.T) {
518518
name: "string constant",
519519
constant: phpConstant{
520520
Name: "StringConst",
521-
Value: "\"hello\"",
521+
Value: `"hello"`,
522522
PhpType: phpString,
523523
},
524-
expected: "\"hello\"", // strings should remain unchanged
524+
expected: `"hello"`, // strings should remain unchanged
525525
},
526526
{
527527
name: "boolean constant",

internal/extgen/stub_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func TestStubGenerator_BuildContent(t *testing.T) {
134134
contains: []string{
135135
"<?php",
136136
"/** @generate-class-entries */",
137-
"const GLOBAL_CONST = \"test\";",
137+
`const GLOBAL_CONST = "test";`,
138138
},
139139
},
140140
{

internal/extgen/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func NamespacedName(namespace, name string) string {
2626
if namespace == "" {
2727
return name
2828
}
29-
namespacePart := strings.ReplaceAll(namespace, "\\", "_")
29+
namespacePart := strings.ReplaceAll(namespace, `\`, "_")
3030
return namespacePart + "_" + name
3131
}
3232

0 commit comments

Comments
 (0)