Skip to content

The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.

fix(editor): colour PHP variables and function calls (#1581)

l0ng-ai846ac97650f1
diff --git a/src/platform/colorScheme.test.ts b/src/platform/colorScheme.test.ts
index 08e95786e..b3766fe3f 100644
--- a/src/platform/colorScheme.test.ts
+++ b/src/platform/colorScheme.test.ts
@@ -14,6 +14,22 @@ describe("color schemes", () => {
expect(schemeTokens("light").get("--bg-editor")).not.toMatch(/var\(/);
});
+ it("gives PHP variables and function calls their own colours, as PhpStorm (#1532)", () => {
+ expect(schemeTokens("dark").get("--syn-php-variable")).toBe("#c77dbb");
+ expect(schemeTokens("dark").get("--syn-php-function-call")).toBe("#56a8f5");
+ expect(schemeTokens("light").get("--syn-php-variable")).toBe("#871094");
+ expect(schemeTokens("light").get("--syn-php-function-call")).toBe("#00627a");
+ const css = readFileSync("src/styles/tokens.css", "utf8");
+ expect(css).toMatch(/\.cm-editor\[data-language="PHP"\] \{\s*--syn-variable: var\(--syn-php-variable\);/);
+ // An imported PHP_VAR still wins: language overrides are emitted for the same element, !important.
+ const imported = schemeCss(
+ "theme-default",
+ { dark: { "php.identifier": { foreground: "#48d8ee" } } },
+ document.documentElement,
+ );
+ expect(imported).toMatch(/\.cm-editor\[data-language="PHP"\] \{\n {2}--syn-variable: #48d8ee !important;/);
+ });
+
it("emits scheme and override declarations", () => {
const root = document.documentElement;
root.dataset.theme = "light";
diff --git a/src/styles/tokens.css b/src/styles/tokens.css
index 42822f634..a4d1f88ac 100644
--- a/src/styles/tokens.css
+++ b/src/styles/tokens.css
@@ -132,6 +132,9 @@ html {
--syn-python-constant: var(--syn-constant);
--syn-python-property: var(--syn-property);
--syn-python-type-parameter: var(--syn-type);
+ /* PhpStorm colours PHP variables and function calls on their own */
+ --syn-php-variable: var(--syn-property);
+ --syn-php-function-call: var(--syn-function);
--syn-builtin: #8888c6;
--syn-self: #94558d;
--syn-keyword-arg: #aa4926;
@@ -523,6 +526,8 @@ html {
--syn-python-constant: var(--syn-constant);
--syn-python-property: var(--syn-property);
--syn-python-type-parameter: var(--syn-type);
+ --syn-php-variable: var(--syn-property);
+ --syn-php-function-call: var(--syn-function);
--syn-builtin: #000080;
--syn-self: #94558d;
--syn-keyword-arg: #660099;
@@ -789,6 +794,8 @@ html {
--syn-python-constant: var(--syn-constant);
--syn-python-property: var(--syn-property);
--syn-python-type-parameter: var(--syn-type);
+ --syn-php-variable: var(--syn-property);
+ --syn-php-function-call: var(--syn-function);
--syn-builtin: #b0b0f0;
--syn-self: #d08ac8;
--syn-keyword-arg: #e0805c;
@@ -1140,6 +1147,8 @@ html {
--syn-python-constant: var(--syn-constant);
--syn-python-property: var(--syn-property);
--syn-python-type-parameter: var(--syn-type);
+ --syn-php-variable: var(--syn-property);
+ --syn-php-function-call: var(--syn-function);
--syn-builtin: var(--palette-cyan);
--syn-self: var(--palette-red);
--syn-keyword-arg: var(--palette-red);
@@ -1429,3 +1438,8 @@ html {
--db-connected: var(--success);
--db-connected-ring: var(--success);
}
+/* PHP editors: variables and function calls use the PHP colours (PHP_VAR / PHP_FUNCTION_CALL). */
+.cm-editor[data-language="PHP"] {
+ --syn-variable: var(--syn-php-variable);
+ --syn-function-call: var(--syn-php-function-call);
+}