diff --git a/package.json b/package.json index 8bde38c..c9435f0 100755 --- a/package.json +++ b/package.json @@ -154,7 +154,8 @@ }, "phpstan.tmpDir": { "type": "string", - "description": "Path to the PHPStan TMP directory. Defaults to PHPStan's default (which is /tmp/phpstan)" + "description": "Path to the PHPStan TMP directory. Defaults to PHPStan's default (which is /tmp/phpstan)", + "default": "/tmp/phpstan" }, "phpstan.checkValidity": { "type": "boolean", diff --git a/server/src/lib/editorConfig.ts b/server/src/lib/editorConfig.ts index 9716fcd..51eda20 100644 --- a/server/src/lib/editorConfig.ts +++ b/server/src/lib/editorConfig.ts @@ -1,5 +1,6 @@ import type { ConfigSettingsWithoutPrefix } from '../../../shared/config'; import type { ClassConfig, WorkspaceFolders } from './types'; +import { DEFAULT_TMP_DIR } from '../../../shared/constants'; import type { Disposable } from 'vscode-languageserver'; import { fromEntries } from '../../../shared/util'; @@ -15,6 +16,10 @@ export async function getEditorConfiguration( section: 'phpstan', })) as ConfigSettingsWithoutPrefix; + let tmpDir = editorConfig.tmpDir; + if (tmpDir === DEFAULT_TMP_DIR) { + tmpDir = editorConfig.proTmpDir || editorConfig.tmpDir; + } return { ...editorConfig, binPath: replaceVariables(editorConfig.binPath, workspaceFolders), @@ -28,10 +33,7 @@ export async function getEditorConfiguration( replaceVariables(value, workspaceFolders), ]) ), - tmpDir: replaceVariables( - editorConfig.tmpDir || editorConfig.proTmpDir || '', - workspaceFolders - ), + tmpDir: replaceVariables(tmpDir, workspaceFolders), rootDir: replaceVariables(editorConfig.rootDir, workspaceFolders), options: editorConfig.options.map((option) => replaceVariables(option, workspaceFolders) diff --git a/shared/commands/defs.ts b/shared/commands/defs.ts index 4d5376e..1f134c4 100644 --- a/shared/commands/defs.ts +++ b/shared/commands/defs.ts @@ -3,6 +3,7 @@ import type { ViewDefinition, ConfigurationDefinition, } from 'vscode-generate-package-json'; +import { DEFAULT_TMP_DIR } from '../constants'; export enum Commands { SCAN_FILE_FOR_ERRORS = 'phpstan.scanFileForErrors', @@ -204,6 +205,7 @@ export const config = { type: 'string', description: "Path to the PHPStan TMP directory. Defaults to PHPStan's default (which is /tmp/phpstan)", + default: DEFAULT_TMP_DIR, }, }, 'phpstan.checkValidity': { diff --git a/shared/constants.ts b/shared/constants.ts index 6807f98..323ff20 100644 --- a/shared/constants.ts +++ b/shared/constants.ts @@ -19,3 +19,4 @@ export const SPAWN_ARGS = { shell: process.platform === 'win32', windowsVerbatimArguments: true, }; +export const DEFAULT_TMP_DIR = '/tmp/phpstan';