дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 19:25:54 +02:00
feat(php): list PHP versions newest first (#1587)
Detected PHP interpreters are sorted newest first, number by number and stable (PATH install first among equal versions), and the language level select and status bar menu list Auto, then 8.5 down to 5.6. With Default selected, the Version row now shows the version of the php found on PATH instead of the first list entry. Closes #1557 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Цей коміт міститься в:
1 джерело
97177486e9
коміт
2c6131999c
6 files changed
+71
-19
No files matched your search
@@ -78,7 +78,9 @@ describe("languages settings", () => {
|
||||
}
|
||||
expect(PHP_LANGUAGE_LEVELS[0]).toBe("");
|
||||
expect(PHP_LANGUAGE_LEVELS).toContain("5.6");
|
||||
expect(PHP_LANGUAGE_LEVELS.at(-1)).toBe("8.5");
|
||||
// Newest first after Auto (#1557).
|
||||
expect(PHP_LANGUAGE_LEVELS[1]).toBe("8.5");
|
||||
expect(PHP_LANGUAGE_LEVELS.at(-1)).toBe("5.6");
|
||||
});
|
||||
|
||||
it("finds the PHP page by its language level", () => {
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* Build Tools › Maven: the toolchain each language's server and run configurations
|
||||
* use (applied by `ide-sdk` when language servers start and when run configurations load).
|
||||
*/
|
||||
import { useId, useMemo } from "react";
|
||||
import { useEffect, useId, useMemo, useState } from "react";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { IconButton, Input, type SelectOption } from "@/ui";
|
||||
import { PHP_LANGUAGE_LEVELS } from "@/platform/languageSettings";
|
||||
import { GlobListEditor, Row, Section, Select, Toggle } from "../components/Form";
|
||||
@@ -117,13 +118,31 @@ const PHP_LEVEL_OPTIONS: SelectOption[] = PHP_LANGUAGE_LEVELS.map((level) =>
|
||||
level ? { value: level, label: level } : { value: "", label: "Auto", detail: "from composer.json" },
|
||||
);
|
||||
|
||||
/** The `php` on `PATH` (what the Default interpreter runs), looked up while `enabled`. */
|
||||
function usePathPhp(enabled: boolean): string | null {
|
||||
const [path, setPath] = useState<string | null>(null);
|
||||
useEffect(() => {
|
||||
if (!enabled) return;
|
||||
let live = true;
|
||||
call(commands.sdkLocateTools(["php"], null))
|
||||
.then((r) => live && setPath(r.tools[0]?.path ?? null))
|
||||
.catch(() => {});
|
||||
return () => {
|
||||
live = false;
|
||||
};
|
||||
}, [enabled]);
|
||||
return path;
|
||||
}
|
||||
|
||||
export function PhpPage() {
|
||||
const [interpreter] = useSetting<string>("languages.php.interpreter");
|
||||
const [level, setLevel] = useSetting<string>("languages.php.languageLevel");
|
||||
const [includePaths, setIncludePaths] = useSetting<string[]>("languages.php.includePaths");
|
||||
const [stubs, setStubs] = useSetting<string[]>("languages.php.stubs");
|
||||
const { list } = useDetected("php");
|
||||
const selected = list.find((s) => s.path === interpreter) ?? (interpreter ? undefined : list[0]);
|
||||
const pathPhp = usePathPhp(!interpreter);
|
||||
// Default runs the `php` on PATH: the list is newest first, so it isn't necessarily `list[0]`.
|
||||
const selected = list.find((s) => s.path === (interpreter || pathPhp));
|
||||
return (
|
||||
<div className={styles.page}>
|
||||
<Section>
|
||||
|
||||
@@ -62,21 +62,21 @@ const DEFAULT_RUFF_FORMATTER: ExternalFormatterValid = {
|
||||
languages: ["python"],
|
||||
};
|
||||
|
||||
/** `languages.php.languageLevel` values; `""` = Auto (from `composer.json`). */
|
||||
/** `languages.php.languageLevel` values, newest first; `""` = Auto (from `composer.json`). */
|
||||
export const PHP_LANGUAGE_LEVELS = [
|
||||
"",
|
||||
"5.6",
|
||||
"7.0",
|
||||
"7.1",
|
||||
"7.2",
|
||||
"7.3",
|
||||
"7.4",
|
||||
"8.0",
|
||||
"8.1",
|
||||
"8.2",
|
||||
"8.3",
|
||||
"8.4",
|
||||
"8.5",
|
||||
"8.4",
|
||||
"8.3",
|
||||
"8.2",
|
||||
"8.1",
|
||||
"8.0",
|
||||
"7.4",
|
||||
"7.3",
|
||||
"7.2",
|
||||
"7.1",
|
||||
"7.0",
|
||||
"5.6",
|
||||
] as const;
|
||||
|
||||
export interface LanguagesValid {
|
||||
|
||||
Reference in new issue
Заблокувати користувача