mirror of
https://github.com/php/frankenphp.git
synced 2026-03-24 00:52:11 +01:00
chore: simplify string using backticks
# Conflicts: # internal/extgen/classparser.go # internal/extgen/gofile_test.go
This commit is contained in:
@@ -42,7 +42,7 @@ type FrankenPHPApp struct {
|
||||
logger *slog.Logger
|
||||
}
|
||||
|
||||
var iniError = errors.New("'php_ini' must be in the format: php_ini \"<key>\" \"<value>\"")
|
||||
var iniError = errors.New(`"php_ini" must be in the format: php_ini "<key>" "<value>"`)
|
||||
|
||||
// CaddyModule returns the Caddy module information.
|
||||
func (f FrankenPHPApp) CaddyModule() caddy.ModuleInfo {
|
||||
|
||||
@@ -313,7 +313,7 @@ func TestCFileSpecialCharacters(t *testing.T) {
|
||||
content, err := cGen.buildContent()
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedInclude := "#include \"" + tt.expected + ".h\""
|
||||
expectedInclude := `#include "` + tt.expected + `.h"`
|
||||
assert.Contains(t, content, expectedInclude, "Content should contain include: %s", expectedInclude)
|
||||
})
|
||||
}
|
||||
@@ -424,8 +424,8 @@ func TestCFileConstants(t *testing.T) {
|
||||
},
|
||||
},
|
||||
contains: []string{
|
||||
"REGISTER_LONG_CONSTANT(\"GLOBAL_INT\", 42, CONST_CS | CONST_PERSISTENT);",
|
||||
"REGISTER_STRING_CONSTANT(\"GLOBAL_STRING\", \"test\", CONST_CS | CONST_PERSISTENT);",
|
||||
`REGISTER_LONG_CONSTANT("GLOBAL_INT", 42, CONST_CS | CONST_PERSISTENT);`,
|
||||
`REGISTER_STRING_CONSTANT("GLOBAL_STRING", "test", CONST_CS | CONST_PERSISTENT);`,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ func (cp *ConstantParser) parse(filename string) (constants []phpConstant, err e
|
||||
func determineConstantType(value string) phpType {
|
||||
value = strings.TrimSpace(value)
|
||||
|
||||
if (strings.HasPrefix(value, "\"") && strings.HasSuffix(value, "\"")) ||
|
||||
if (strings.HasPrefix(value, `"`) && strings.HasSuffix(value, `"`)) ||
|
||||
(strings.HasPrefix(value, "`") && strings.HasSuffix(value, "`")) {
|
||||
return phpString
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ func TestConstantParserTypeDetection(t *testing.T) {
|
||||
value string
|
||||
expectedType phpType
|
||||
}{
|
||||
{"string with double quotes", "\"hello world\"", phpString},
|
||||
{"string with double quotes", `"hello world"`, phpString},
|
||||
{"string with backticks", "`hello world`", phpString},
|
||||
{"boolean true", "true", phpBool},
|
||||
{"boolean false", "false", phpBool},
|
||||
@@ -443,13 +443,13 @@ func TestConstantParserDeclRegex(t *testing.T) {
|
||||
name string
|
||||
value string
|
||||
}{
|
||||
{"const MyConst = \"value\"", true, "MyConst", "\"value\""},
|
||||
{`const MyConst = "value"`, true, "MyConst", `"value"`},
|
||||
{"const IntConst = 42", true, "IntConst", "42"},
|
||||
{"const BoolConst = true", true, "BoolConst", "true"},
|
||||
{"const IotaConst = iota", true, "IotaConst", "iota"},
|
||||
{"const ComplexValue = someFunction()", true, "ComplexValue", "someFunction()"},
|
||||
{"const SpacedName = \"with spaces\"", true, "SpacedName", "\"with spaces\""},
|
||||
{"var notAConst = \"value\"", false, "", ""},
|
||||
{`const SpacedName = "with spaces"`, true, "SpacedName", `"with spaces"`},
|
||||
{`var notAConst = "value"`, false, "", ""},
|
||||
{"const", false, "", ""},
|
||||
{"const =", false, "", ""},
|
||||
}
|
||||
@@ -518,10 +518,10 @@ func TestPHPConstantCValue(t *testing.T) {
|
||||
name: "string constant",
|
||||
constant: phpConstant{
|
||||
Name: "StringConst",
|
||||
Value: "\"hello\"",
|
||||
Value: `"hello"`,
|
||||
PhpType: phpString,
|
||||
},
|
||||
expected: "\"hello\"", // strings should remain unchanged
|
||||
expected: `"hello"`, // strings should remain unchanged
|
||||
},
|
||||
{
|
||||
name: "boolean constant",
|
||||
|
||||
@@ -134,7 +134,7 @@ func TestStubGenerator_BuildContent(t *testing.T) {
|
||||
contains: []string{
|
||||
"<?php",
|
||||
"/** @generate-class-entries */",
|
||||
"const GLOBAL_CONST = \"test\";",
|
||||
`const GLOBAL_CONST = "test";`,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ func NamespacedName(namespace, name string) string {
|
||||
if namespace == "" {
|
||||
return name
|
||||
}
|
||||
namespacePart := strings.ReplaceAll(namespace, "\\", "_")
|
||||
namespacePart := strings.ReplaceAll(namespace, `\`, "_")
|
||||
return namespacePart + "_" + name
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user